Reputation: 52
I'm facing behavior that I can't explain, using gradle 1.10 I have:
settings.gradle:
include('lib1', 'lib2', 'web')
build.gradle:
subprojects {
apply plugin: 'java'
}
project(':web') {
apply plugin: 'war'
dependencies {
compile project(':lib1')
}
task myTask(type: JavaExec, dependsOn: 'compileJava') {
main = "some.thirdparty.Class"
args "--searchPath", configurations.runtime.asPath
}
}
project(':lib1') {
dependencies {
compile project(':lib2')
}
}
project(':lib2') {
}
When I run gradle clean war
I only have lib1.jar
in war/build/libs/web.war/WEB-INF/lib
.
To make WEB-INF/lib
contain both lib1.jar
and lib2.jar
I have to:
project('web')
block to the end of the fileconfigurations.runtime.asPath
to configurations.runtime
(but I need to provide class path as a path, so it is not a solution)I read the build lifecycle description, tried to compare --debug outputs but that didn't help.
Why is this happening? And what would be a good solution to provide the module runtime class path as a path in JavaExec task please?
Upvotes: 1
Views: 782
Reputation: 123910
asPath
resolves the configuration, but resolution will only work correctly if it happens at execution time rather than configuration time (in particular in the presence of project dependencies). Try to wrap the args
line with doFirst { ... }
.
Upvotes: 2