1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Refactor to enable multiple test{} configs.

This commit is contained in:
Cedric Beust 2016-02-20 09:50:02 -08:00
parent 596c6859d9
commit 32b0d12770
10 changed files with 57 additions and 39 deletions

View file

@ -0,0 +1,18 @@
package com.beust.kobalt.api
import java.util.*
/**
* Actors that have one config object per project can use this helper class.
*/
interface IConfigActor<T> {
val configurations : HashMap<String, T>
fun configurationFor(project: Project?) = if (project != null) configurations[project.name] else null
fun addConfiguration(project: Project, configuration: T) = configurations.put(project.name, configuration)
}
open class ConfigActor<T>: IConfigActor<T> {
override val configurations : HashMap<String, T> = hashMapOf()
}

View file

@ -1,12 +0,0 @@
package com.beust.kobalt.api
/**
* A plug-in that has some per-project configuration in the build file.
*/
abstract public class ConfigPlugin<T> : BasePlugin() {
private val configurations = hashMapOf<String, T>()
fun configurationFor(project: Project?) = if (project != null) configurations[project.name] else null
fun addConfiguration(project: Project, configuration: T) = configurations.put(project.name, configuration)
}

View file

@ -0,0 +1,19 @@
package com.beust.kobalt.api
import com.google.common.collect.ArrayListMultimap
import com.google.common.collect.ListMultimap
/**
* Actors that have more than config object per project can use this helper class.
*/
interface IConfigsActor<T> {
val configurations : ListMultimap<String, T>
fun configurationFor(project: Project?) = if (project != null) configurations[project.name] else null
fun addConfiguration(project: Project, configuration: T) = configurations.put(project.name, configuration)
}
open class ConfigsActor<T>: IConfigsActor<T> {
override val configurations = ArrayListMultimap.create<String, T>()
}

View file

@ -1,14 +0,0 @@
package com.beust.kobalt.api
import com.google.common.collect.ArrayListMultimap
/**
* A plug-in that has some per-project list of configurations in the build file.
*/
abstract public class ConfigsPlugin<T> : BasePlugin() {
private val configurations = ArrayListMultimap.create<String, T>()
fun configurationFor(project: Project) = configurations[project.name]
fun addConfiguration(project: Project, configuration: T) = configurations.put(project.name, configuration)
}

View file

@ -1,12 +1,17 @@
package com.beust.kobalt.internal
import com.beust.kobalt.api.ConfigPlugin
import com.beust.kobalt.api.BasePlugin
import com.beust.kobalt.api.ConfigActor
import com.beust.kobalt.api.ICompilerFlagContributor
import com.beust.kobalt.api.IConfigActor
/**
* Base class for JVM language plug-ins.
*/
abstract class BaseJvmPlugin<T> : ConfigPlugin<T>(), ICompilerFlagContributor {
abstract class BaseJvmPlugin<T>(open val configActor: ConfigActor<T>) :
BasePlugin(),
IConfigActor<T> by configActor,
ICompilerFlagContributor {
companion object {
// Run before other flag contributors
val FLAG_CONTRIBUTOR_PRIORITY = ICompilerFlagContributor.DEFAULT_FLAG_PRIORITY - 10