Hi, I have one gradle task that compiles some groovy classes, and have another task that then uses those compiled classes to do some work. How do I add those compiled classes to the runtime classpath of the downstream task? Currently I get an ‘Unable to resolve class’ error. Thanks Tim
Is the downstream task trying to execute those classes?
Exactly. Something like this:
task downsteamTask(dependsOn: compileUpstreamTask) << {
def runner = new com.somewhere.something.MyRunner()
runner.run() }
Depending on your exact needs, you could either use a JavaExec task or move the classes to be compiled into the buildSrc project. In the latter case, Gradle will automatically put them on the build script class path.
Here are some docs on the buildSrc approach, which is the recommended way.
http://gradle.org/current/docs/userguide/organizing_build_logic.html#sec:build_sources
Hi Peter, Luke,
Thanks for the help. I got the buildSrc project approach working nicely.
Tim