mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -07:00
Refactor to enable multiple test{} configs.
This commit is contained in:
parent
596c6859d9
commit
32b0d12770
10 changed files with 57 additions and 39 deletions
|
@ -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()
|
||||||
|
}
|
|
@ -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)
|
|
||||||
}
|
|
|
@ -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>()
|
||||||
|
}
|
|
@ -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)
|
|
||||||
}
|
|
|
@ -1,12 +1,17 @@
|
||||||
package com.beust.kobalt.internal
|
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.ICompilerFlagContributor
|
||||||
|
import com.beust.kobalt.api.IConfigActor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for JVM language plug-ins.
|
* 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 {
|
companion object {
|
||||||
// Run before other flag contributors
|
// Run before other flag contributors
|
||||||
val FLAG_CONTRIBUTOR_PRIORITY = ICompilerFlagContributor.DEFAULT_FLAG_PRIORITY - 10
|
val FLAG_CONTRIBUTOR_PRIORITY = ICompilerFlagContributor.DEFAULT_FLAG_PRIORITY - 10
|
||||||
|
|
|
@ -34,9 +34,10 @@ fun Project.application(init: ApplicationConfig.() -> Unit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class ApplicationPlugin @Inject constructor(val executors: KobaltExecutors,
|
class ApplicationPlugin @Inject constructor(val configActor: ConfigActor<ApplicationConfig>,
|
||||||
|
val executors: KobaltExecutors,
|
||||||
val dependencyManager: DependencyManager, val taskContributor : TaskContributor)
|
val dependencyManager: DependencyManager, val taskContributor : TaskContributor)
|
||||||
: ConfigPlugin<ApplicationConfig>(), IRunnerContributor, ITaskContributor {
|
: BasePlugin(), IRunnerContributor, ITaskContributor, IConfigActor<ApplicationConfig> by configActor {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val PLUGIN_NAME = "Application"
|
const val PLUGIN_NAME = "Application"
|
||||||
|
|
|
@ -18,8 +18,8 @@ import javax.inject.Singleton
|
||||||
* (outputDir, etc...).
|
* (outputDir, etc...).
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AptPlugin @Inject constructor(val depFactory: DepFactory)
|
class AptPlugin @Inject constructor(val depFactory: DepFactory, val configActor: ConfigActor<AptConfig>)
|
||||||
: ConfigPlugin<AptConfig>(), ICompilerFlagContributor, ISourceDirectoryContributor {
|
: BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor, IConfigActor<AptConfig> by configActor {
|
||||||
|
|
||||||
// ISourceDirectoryContributor
|
// ISourceDirectoryContributor
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@ import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler)
|
class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override val configActor: ConfigActor<JavaConfig>)
|
||||||
: BaseJvmPlugin<JavaConfig>(), IDocContributor, ICompilerContributor, ITestSourceDirectoryContributor,
|
: BaseJvmPlugin<JavaConfig>(configActor), IDocContributor, ICompilerContributor,
|
||||||
IBuildConfigContributor {
|
ITestSourceDirectoryContributor, IBuildConfigContributor {
|
||||||
companion object {
|
companion object {
|
||||||
const val PLUGIN_NAME = "Java"
|
const val PLUGIN_NAME = "Java"
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,9 @@ import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class KotlinPlugin @Inject constructor(val executors: KobaltExecutors)
|
class KotlinPlugin @Inject constructor(val executors: KobaltExecutors,
|
||||||
: BaseJvmPlugin<KotlinConfig>(), IDocContributor, IClasspathContributor, ICompilerContributor,
|
override val configActor: ConfigActor<KotlinConfig>)
|
||||||
|
: BaseJvmPlugin<KotlinConfig>(configActor), IDocContributor, IClasspathContributor, ICompilerContributor,
|
||||||
IBuildConfigContributor {
|
IBuildConfigContributor {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -24,8 +24,8 @@ import javax.inject.Singleton
|
||||||
class PackagingPlugin @Inject constructor(val dependencyManager : DependencyManager,
|
class PackagingPlugin @Inject constructor(val dependencyManager : DependencyManager,
|
||||||
val executors: KobaltExecutors, val jarGenerator: JarGenerator, val warGenerator: WarGenerator,
|
val executors: KobaltExecutors, val jarGenerator: JarGenerator, val warGenerator: WarGenerator,
|
||||||
val zipGenerator: ZipGenerator, val taskContributor: TaskContributor,
|
val zipGenerator: ZipGenerator, val taskContributor: TaskContributor,
|
||||||
val pomFactory: PomGenerator.IFactory)
|
val pomFactory: PomGenerator.IFactory, val configActor: ConfigActor<InstallConfig>)
|
||||||
: ConfigPlugin<InstallConfig>(), ITaskContributor {
|
: BasePlugin(), IConfigActor<InstallConfig> by configActor, ITaskContributor {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val PLUGIN_NAME = "Packaging"
|
const val PLUGIN_NAME = "Packaging"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue