sorry for a not completely dsl related question. H...
# gradle
g
sorry for a not completely dsl related question. How to extract some of the helper functions from
build.gradle
into a different file, preserving the context of
build.gradle
file? Ex: I have a custom
strField
extension of the
buildConfigField
method:
Copy code
com.android.build.gradle.internal.dsl.BuildType.metaClass.strField = { key, value -> delegate.buildConfigField "String", key, "\"$value\"" }
that allows me to create build type constants without worrying about quotes:
strField(key, value)
Ideally, I'd like to extract this into an external file and import it via
apply from: '../utils.gradle'
but seems like these script files have different context and the same code doesn't work anymore. Also, will be this sort of metaprogramming possible if I switch to kotlin DSL?