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

New profile syntax: val debug by profile()

This commit is contained in:
Cedric Beust 2017-03-25 12:45:59 -07:00
parent 8a8b5f638d
commit 86c166ff76
6 changed files with 50 additions and 39 deletions

View file

@ -4,6 +4,8 @@ import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.api.Project
import com.beust.kobalt.api.annotation.Directive
import com.beust.kobalt.internal.JvmCompilerPlugin
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
@Directive
fun project(vararg projects: Project, init: Project.() -> Unit): Project {
@ -19,4 +21,19 @@ fun buildScript(init: BuildScriptConfig.() -> Unit): BuildScriptConfig {
val buildScriptConfig = BuildScriptConfig().apply { init() }
BUILD_SCRIPT_CONFIG = buildScriptConfig
return buildScriptConfig
}
}
@Directive
fun profile(): ReadWriteProperty<Nothing?, Boolean> {
val result = object: ReadWriteProperty<Nothing?, Boolean> {
var value: Boolean = false
override operator fun getValue(thisRef: Nothing?, property: KProperty<*>): Boolean {
return value
}
override operator fun setValue(thisRef: Nothing?, property: KProperty<*>, value: Boolean) {
this.value = value
}
}
return result
}

View file

@ -56,7 +56,7 @@ class BlockExtractor(val regexp: Pattern, val opening: Char, val closing: Char)
startLine = currentLineNumber
foundKeyword = true
count = 1
result.append(topLines.joinToString("\n"))
result.append(topLines.joinToString("\n")).append("\n")
result.append(line).append("\n")
} else {
val allowedImports = listOf("com.beust", "java")