Gradle: Using string interpolation in model DSL -
how can substitute project property in string in model dsl? tried following:
apply plugin: 'com.android.model.native' model { android { ... sources { main { jni { source { srcdirs "src" include "*.cpp" } exportedheaders { srcdir "${project.rootdir}/include" } } } } } }
but got error:
error:attempt read write view of model of type 'org.gradle.model.modelmap<org.gradle.language.base.functionalsourceset>' given rule 'android { ... } @ android/build.gradle line 6, column 5'
it works if assign property value variable outside of model block , substitute variable instead:
def foodir = project.rootdir ... srcdir "${foodir}/include"
but that's bit inconvenient.
it's weird error, means trying access property has not been declared input rule creating. declare input have use "special syntax" model dsl. example, access project.builddir
, must use:
$.builddir
unfortunately, project.rootdir
not bound model path yet. caching value in variable accessible model rules (as have done) seems decent workaround now.
Comments
Post a Comment