Reputation: 2715
I've got a multi-project setup, where I'd like to build Rpm files from certain subprojects, containing artefacts from other subprojects. Seems like I need help with some Gradle basics.
The project layout is like the below:
rootProject
|
|-commonLibs
|
|---serviceA
| |
| |--module1
| \--module2
|
\---serviceB
|
|--module3
\--module4
Both services depend on commonLibs.
I'm using nebula.os-package 2.0.2 and a Gradle 2.2 snapshot release.
Since services A and B will run on different machines, of course I want them in different RPM.
What I'd like to accomplish is to have each of the Rpms include:
I prefer to avoid listing each file to include, because I'll be adding more submodules later. And we could surely take advantage of Gradle's build-by-convention mechanics here.
So, I was thinking I'd do something like this in the build.gradle
of serviceA and serviceB:
apply plugin: 'os-package'
ospackage {
ext.outputFiles = []
project.childProjects.each {
jar.outputs.files.each { File f ->
outputs.add (f)
}
}
from files(outputFiles) {
into '/opt/mybusiness/product/lib'
}
}
Clearly, this doesn't work:
gradlew serviceA:buildRpm
[...]
* What went wrong:
A problem occurred evaluating project ':serviceA'.
> Could not find property 'jar' on com.netflix.gradle.plugins.packaging.ProjectPackagingExtension_Decorated@2805c769.
OK, serviceA is not a Java project, so I didn't apply the java plugin to it, only the os-package plugin. The submodules, however, are both applying the 'java' plugin, so I was assuming that I could access their jar tasks from the each
closure. This must be a build order problem. Right?
What should I be doing instead, in my position? Any examples of strategies for multi-project builds using nebula.os-package are welcome. I've been searching the web, but I'm having problems finding anything.
Upvotes: 0
Views: 5211
Reputation: 1857
I guess, something like this should do the trick - to be added in build.gradle of :serviceA & :serviceB
configurations {
commonJars
}
dependencies {
commonJars project( path: ':commonLibs' ) // might be needed to add 'configuration' as well
}
ospackage {
from configurations.commonJars
..
}
Upvotes: 1