mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -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 = ... }")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue