Slackbot
11/09/2022, 11:47 AMVampire
11/09/2022, 11:50 AMbuildSrc
result is automatically prepended to all build script class paths, which also is one of its biggest drawbacks. (invalidating everything if something changes).
You have to bring your included build to the build script classpath where you want to use the class.
You can either do that explicitly using buildscript { dependencies { classpath(...) } }
, or you can have some dummy plugin that does no actions and apply that dummy project to your build script, because that brings the classes onto the classpath.Alphonse Bendt
11/09/2022, 12:23 PMbuildscript
Is this always needed or is there also a way to reference the artifact without the substitution?
i have also tried to set group/name just in the included build but that does not seem to work.
// settings.gradle
includeBuild('buildLogic/helper-function') {
dependencySubstitution {
substitute module("demo:helper-function") using(project(':'))
}
}
// build.gradle
buildscript { dependencies { classpath("demo:helper-function") } }
task demo {
doLast {
// this is the imported helper function
println demo.Helper.sayHelloTo("foo")
}
}
Vampire
11/09/2022, 12:54 PMVampire
11/09/2022, 12:54 PM