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

standardize directives

This commit is contained in:
Juan Liska 2017-02-15 08:44:35 -06:00
parent cb101cd410
commit 3c4a703ca1
4 changed files with 22 additions and 16 deletions

View file

@ -9,16 +9,20 @@ class TestConfig(val project: Project, val isDefault : Boolean = false) {
val testIncludes = arrayListOf("**/*Test.class") val testIncludes = arrayListOf("**/*Test.class")
val testExcludes = arrayListOf<String>() val testExcludes = arrayListOf<String>()
@Directive
var name: String = "" var name: String = ""
@Directive
fun args(vararg arg: String) { fun args(vararg arg: String) {
testArgs.addAll(arg) testArgs.addAll(arg)
} }
@Directive
fun jvmArgs(vararg arg: String) { fun jvmArgs(vararg arg: String) {
jvmArgs.addAll(arg) jvmArgs.addAll(arg)
} }
@Directive
fun include(vararg arg: String) { fun include(vararg arg: String) {
testIncludes.apply { testIncludes.apply {
clear() clear()
@ -26,6 +30,7 @@ class TestConfig(val project: Project, val isDefault : Boolean = false) {
} }
} }
@Directive
fun exclude(vararg arg: String) { fun exclude(vararg arg: String) {
testExcludes.apply { testExcludes.apply {
clear() clear()
@ -35,11 +40,12 @@ class TestConfig(val project: Project, val isDefault : Boolean = false) {
} }
@Directive @Directive
fun Project.test(init: TestConfig.() -> Unit) = let { project -> fun Project.test(init: TestConfig.() -> Unit): TestConfig = let { project ->
with(testConfigs) { with(testConfigs) {
val tf = TestConfig(project).apply { init() } val tf = TestConfig(project).apply { init() }
if (! map { it.name }.contains(tf.name)) { if (! map { it.name }.contains(tf.name)) {
add(tf) add(tf)
tf
} else { } else {
throw KobaltException("Test configuration \"${tf.name}\" already exists, give it a different " throw KobaltException("Test configuration \"${tf.name}\" already exists, give it a different "
+ "name with test { name = ... }") + "name with test { name = ... }")

View file

@ -44,8 +44,8 @@ class GroovyConfig(val project: Project) {
} }
@Directive @Directive
fun Project.groovyCompiler(init: GroovyConfig.() -> Unit) = let { fun Project.groovyCompiler(init: GroovyConfig.() -> Unit) =
val config = GroovyConfig(it) GroovyConfig(this).also { config ->
config.init() config.init()
(Kobalt.findPlugin(GroovyPlugin.PLUGIN_NAME) as GroovyPlugin).addConfiguration(this, config) (Kobalt.findPlugin(GroovyPlugin.PLUGIN_NAME) as GroovyPlugin).addConfiguration(this, config)
} }

View file

@ -84,8 +84,8 @@ class JavaConfig(val project: Project) {
} }
@Directive @Directive
fun Project.javaCompiler(init: JavaConfig.() -> Unit) = let { fun Project.javaCompiler(init: JavaConfig.() -> Unit) =
val config = JavaConfig(it) JavaConfig(this).also { config ->
config.init() config.init()
(Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as JavaPlugin).addConfiguration(this, config) (Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as JavaPlugin).addConfiguration(this, config)
} }

View file

@ -154,11 +154,11 @@ class KotlinConfig(val project: Project) {
} }
@Directive @Directive
fun Project.kotlinCompiler(init: KotlinConfig.() -> Unit) = let { fun Project.kotlinCompiler(init: KotlinConfig.() -> Unit) =
val config = KotlinConfig(it) KotlinConfig(this).also { config ->
config.init() config.init()
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as KotlinPlugin).addConfiguration(this, config) (Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as KotlinPlugin).addConfiguration(this, config)
} }
//class SourceLinkMapItem { //class SourceLinkMapItem {
// var dir: String = "" // var dir: String = ""