I have a multi-project build, with mainly Java code. I use the “os-package” plugin to build RPM packages in some of the subprojects.
Now, the subprojects are all individually versioned, and I need to make a release archive whenever I build a release version of the whole project. In other words, I want a Gradle task that collects the outputs of all tasks of type Rpm or all tasks called buildRpm.
All the examples I’ve found online either use only jar artifacts, and so can use configurations, or are single-project solutions.
The naive solution is to put the below in the parent project. Doesn’t work, because not all child projects have the buildRpm task.
task dist(type: Zip) {
from {subprojects.buildRpm}
}
$ gradlew dist
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\workspace\temip\build.gradle' line: 35
* What went wrong:
Could not determine the dependencies of task ':dist'.
> Could not find property 'buildRpm' on project ':foo'.
I tried this fancier version but to be honest I’m not 100% sure what I’m doing here. Anyway, it seems not to find any inputs (or outputs?). (I think I have to refer to the plugin by class, since parent project doesn’t (and shouldn’t) load the plugin, so I can’t refer to it by name.)
Hi Francois,
Thanks for the suggestion!
Unfortunately it doesn’t work. Even if I add the right plugin to the root project, to have Rpm defined as a type, I get
No signature of method: java.util.ArrayList.withType() is applicable for argument types: (java.lang.Class) values: [class com.netflix.gradle.plugins.rpm.Rpm]
Possible solutions: asType(java.lang.Class), asType(java.lang.Class), with(groovy.lang.Closure)
Nope. I didn’t even know “subprojects” was a TreeSet, but there you go. Doesn’t seem to have “all”.
No signature of method: java.util.TreeSet.all() is applicable for argument types: (build_dvf3gi1t92weg4b4j2twaad82$_run_closure3_closure6) values: [build_dvf3gi1t92weg4b4j2twaad82$_run_closure3_closure6@55e3dc28]
Possible solutions: any(), last(), last(), add(java.lang.Object), add(java.lang.Object), any(groovy.lang.Closure)