This message was deleted.
# community-support
s
This message was deleted.
v
Yep,
buildSrc
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.
a
thanks @Vampire, that helped me to make it work. I had to define a dependencySubstitution to be able to reference the included build from
buildscript
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.
Copy code
// 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")
  }
}
v
If your included build is properly set up, you do not need dependency substitutions. Dependency substitutions are always only necessary if the included build is not configured properly, or if it does fancy non-standard things.
Why it does not work in your case is hardly guessable without an MCVE.