Add overridable method "setup" for defining properties
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@ abstract class MyScriptWithMavenDeps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object MyScriptProperties : ScriptingProperties() {
|
object MyScriptProperties : ScriptingProperties() {
|
||||||
init {
|
override fun setup() {
|
||||||
include(jvmJavaHomeScriptingProperties)
|
include(jvmJavaHomeScriptingProperties)
|
||||||
scriptDefinition {
|
scriptDefinition {
|
||||||
defaultImports<DependsOn>()
|
defaultImports<DependsOn>()
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ open class ScriptingProperties(body: ScriptingProperties.() -> Unit = {}) {
|
|||||||
body()
|
body()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun setup() {}
|
||||||
|
|
||||||
internal fun makePropertyBag(): ChainedPropertyBag =
|
internal fun makePropertyBag(): ChainedPropertyBag =
|
||||||
ChainedPropertyBag.createOptimized(parentPropertiesBag ?: parentPropertiesBuilder?.makePropertyBag(), data)
|
ChainedPropertyBag.createOptimized(parentPropertiesBag ?: parentPropertiesBuilder?.makePropertyBag(), data)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@ fun createScriptDefinitionFromAnnotatedBaseClass(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun scriptingPropsInstance(kclass: KClass<out ScriptingProperties>): ScriptingProperties = try {
|
fun scriptingPropsInstance(kclass: KClass<out ScriptingProperties>): ScriptingProperties = try {
|
||||||
kclass.objectInstance ?: kclass.createInstance()
|
kclass.objectInstance ?: kclass.createInstance().also { it.setup() }
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
throw IllegalArgumentException(ILLEGAL_CONFIG_ANN_ARG, e)
|
throw IllegalArgumentException(ILLEGAL_CONFIG_ANN_ARG, e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user