I have a multi-project build that’s laid out like this:
rosjava_core/build.gradle rosjava_core/rosjava/build.gradle rosjava_core/rosjava_bootstrap/build.gradle
rosjava depends on rosjava_bootstrap.
I’d like to deploy the artifacts to my .m2 cache. When I run gradle install, however, the install task is skipped for the rosjava_bootstrap project (it gets as far as rosjava_boostrap:jar) and the rosjava:compileJava task is started. The rosjava project depends on some artifacts in my .m2 cache that depend on rosjava_bootstrap being in the .m2 cache. So, the build fails.
I don’t understand why the rosjava_bootstrap:install task isn’t being called immediately after rosjava_bootstrap:jar? If I call gradle rosjava_boostrap:install, it executes as expect.
I believe my question on stackoverflow (http://stackoverflow.com/questions/9483924/gradle-eclipse-plugin) may also have something to do with this.
The code and build scripts are visible here: http://code.google.com/r/damonkohler-rosjava-unstable/source/browse
I added a hack to rosjava/build.gradle that fixes this problem:
afterEvaluate {
classes.dependsOn project(':rosjava_bootstrap').tasks.install
}
However, I still have issues with eclipse generation (as described in detail on stackoverflow). So, I think this is probably the wrong solution.
I don’t understand why the rosjava_bootstrap:install task isn’t being called immediately after rosjava_bootstrap:jar?
Probably because there is no task dependency that tells Gradle to do so.
I don’t have the full picture, but it seems like you should exclude rosjava_bootstrap when declaring a dependency from rosjava on that other module in the .m2 cache. Then you might not even have to install rosjava_bootstrap to the .m2 cache - at least not for building rosjava. The project dependency from rosjava on rosjava_bootstrap is enough to get the latter on the former’s class path.
Thanks for the help. Perhaps I don’t quite understand your suggestion, but I tried removing the dependency on rosjava_bootstrap from rosjava. As expected, the build still fails like so (I removed logging about irrelevant packages):
~/ros/workspace/rosjava_core$ gradle clean install
:rosjava:clean
:rosjava_bootstrap:clean
:rosjava:compileJava
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':rosjava:compile'.
> Could not find group:ros.rosjava_core, module:rosjava_bootstrap, version:0.0.0-SNAPSHOT.
Required by:
ros.rosjava_core:rosjava:0.0.0-SNAPSHOT > ros:message.std_msgs:0.0.0-SNAPSHOT
ros.rosjava_core:rosjava:0.0.0-SNAPSHOT > ros:message.rosgraph_msgs:0.0.0-SNAPSHOT
BUILD FAILED
std_msgs and rosgraph_msgs are installed in my .m2 cache and have a pom that specifies a dependency on rosjava_bootstrap. So, rosjava has a transitive dependency on rosjava_bootstrap through std_msgs and rosgraph_msgs.
Maybe I’m going about this all wrong. I’m open to suggestions about how to do this in the most gradle-y way possible. However, I’d like to avoid converting std_msgs and rosgraph_msgs to gradle for the moment.
You have to exclude ‘rosjava_bootstrap’ when you bring in ‘std_msgs’ and ‘rosgraph_msgs’. You are already getting ‘rosjava_bootstrap’ from the project dependency, so there is no need to also get it from the local Maven repository. Something like:
dependencies {
compile("xxx:std_msgs:1.0") {
exclude module: "rosjava_bootstrap"
}
}
Thanks, that works great.
Is there a concise way to group the dependencies that should exclude rosjava_bootstrap? I tried:
dependencies {
compile(["xxx:std_msgs:1.0", "xxx:rosgraph_msgs:1.0"]) {
exclude module: "rosjava_bootstrap"
}
}
A simple solution is to exclude ‘rosjava_bootstrap’ globally with ‘configurations.compile.exclude module: “rosjava_bootstrap”’ or ‘configurations.all*.exclude module: “rosjava_bootstrap”’.
Wouldn’t that also exclude it where it’s necessary (i.e. in the rosjava project)? Or did you mean that I should do that on a per subproject basis?
Is this:
exclude module: 'rosjava_bootstrap'
somehow different than this:
exclude project(':rosjava_bootstrap')
In rosjava the dependency is:
dependencies {
compile project(':rosjava_bootstrap')
}