https://kotlinlang.org logo
#gradle
Title
# gradle
n

nuhkoca

06/28/2022, 8:59 PM
Hello, I have set up
build-logic
instead of
buildSrc
and moved some code in there. However, I am getting an exception when I try to use something from
build-logic
Copy code
fun VariantDimension.stringField(name: String, value: String) {
    buildConfigField("String", name, "\"$value\"")
}
Copy code
ScriptCompilationException(errors=[ScriptCompilationError(message=Unresolved reference: stringField, location=/Users/nuhkoca/.gradle/.tmp/gradle-kotlin-dsl-16705359721542638789.tmp/build.gradle.kts (27:9))
m

MR3Y

06/28/2022, 9:51 PM
You need a no-op plugin in order to access
stringField
in your gradle scripts from
build-logic
because
build-logic
isn't on gradle hot classpath by default unlike
buildSrc
. For more information, see: https://kotlinlang.slack.com/archives/C19FD9681/p1655824505656089
n

nuhkoca

06/29/2022, 10:22 AM
Thanks! Asked there 🙂 but seems there is no way except creating a convention plugin to expose an extension function to other
Gradle
scripts, right?
m

MR3Y

06/29/2022, 10:25 AM
Yeah, I guess so
12 Views