mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
standardize directives
This commit is contained in:
parent
cb101cd410
commit
3c4a703ca1
4 changed files with 22 additions and 16 deletions
|
@ -9,16 +9,20 @@ class TestConfig(val project: Project, val isDefault : Boolean = false) {
|
|||
val testIncludes = arrayListOf("**/*Test.class")
|
||||
val testExcludes = arrayListOf<String>()
|
||||
|
||||
@Directive
|
||||
var name: String = ""
|
||||
|
||||
@Directive
|
||||
fun args(vararg arg: String) {
|
||||
testArgs.addAll(arg)
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun jvmArgs(vararg arg: String) {
|
||||
jvmArgs.addAll(arg)
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun include(vararg arg: String) {
|
||||
testIncludes.apply {
|
||||
clear()
|
||||
|
@ -26,6 +30,7 @@ class TestConfig(val project: Project, val isDefault : Boolean = false) {
|
|||
}
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun exclude(vararg arg: String) {
|
||||
testExcludes.apply {
|
||||
clear()
|
||||
|
@ -35,11 +40,12 @@ class TestConfig(val project: Project, val isDefault : Boolean = false) {
|
|||
}
|
||||
|
||||
@Directive
|
||||
fun Project.test(init: TestConfig.() -> Unit) = let { project ->
|
||||
fun Project.test(init: TestConfig.() -> Unit): TestConfig = let { project ->
|
||||
with(testConfigs) {
|
||||
val tf = TestConfig(project).apply { init() }
|
||||
if (! map { it.name }.contains(tf.name)) {
|
||||
add(tf)
|
||||
tf
|
||||
} else {
|
||||
throw KobaltException("Test configuration \"${tf.name}\" already exists, give it a different "
|
||||
+ "name with test { name = ... }")
|
||||
|
|
|
@ -44,8 +44,8 @@ class GroovyConfig(val project: Project) {
|
|||
}
|
||||
|
||||
@Directive
|
||||
fun Project.groovyCompiler(init: GroovyConfig.() -> Unit) = let {
|
||||
val config = GroovyConfig(it)
|
||||
fun Project.groovyCompiler(init: GroovyConfig.() -> Unit) =
|
||||
GroovyConfig(this).also { config ->
|
||||
config.init()
|
||||
(Kobalt.findPlugin(GroovyPlugin.PLUGIN_NAME) as GroovyPlugin).addConfiguration(this, config)
|
||||
}
|
||||
|
|
|
@ -84,8 +84,8 @@ class JavaConfig(val project: Project) {
|
|||
}
|
||||
|
||||
@Directive
|
||||
fun Project.javaCompiler(init: JavaConfig.() -> Unit) = let {
|
||||
val config = JavaConfig(it)
|
||||
fun Project.javaCompiler(init: JavaConfig.() -> Unit) =
|
||||
JavaConfig(this).also { config ->
|
||||
config.init()
|
||||
(Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as JavaPlugin).addConfiguration(this, config)
|
||||
}
|
|
@ -154,8 +154,8 @@ class KotlinConfig(val project: Project) {
|
|||
}
|
||||
|
||||
@Directive
|
||||
fun Project.kotlinCompiler(init: KotlinConfig.() -> Unit) = let {
|
||||
val config = KotlinConfig(it)
|
||||
fun Project.kotlinCompiler(init: KotlinConfig.() -> Unit) =
|
||||
KotlinConfig(this).also { config ->
|
||||
config.init()
|
||||
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as KotlinPlugin).addConfiguration(this, config)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue