I'm trying to make a dist of a multi project build. The root project looks something like this:
apply plugin: 'distribution'
version 1.0
distributions {
main {
baseName = 'someName'
contents {
from 'nodes'
into 'nodes'
}
}
}
It just copies a folder with some files to the dist.
I now want each subproject to inject its stuff into the dist. I want to add each subprojects jar, any dependecies, and possibly some other files etc...
I have no idea how to inject from the subproject to the root. Should I even do something like that? What i mean is something like this:
subprojects {
apply java...
...
// pseudocode
jack into the root project dist plugin
put my produced jars and dependencies in a folder with my name
...
}
Does anyone have any examples, or just point me in the right direction?
thanks!
I was looking for the same thing. With some peeking at the API docs and Gradle' own build files, I came to the following:
apply plugin: 'distribution'
distributions {
main {
contents {
into('bin') {
from { project(':subproject1').startScripts.outputs.files }
from { project(':subproject2').startScripts.outputs.files }
fileMode = 0755
}
into('lib') {
def libs = []
libs << project(':subproject1').configurations.runtime - project(':runner').configurations.runtime
libs << project(':subproject2').configurations.runtime
from libs
from project(':subproject1').jar
from project(':subproject2').jar
}
}
}
}
The contents {} closure is a CopySpec, knowing that makes using the distribution plugin way simpler :)
Check out Gradle' own subprojects/distributions/distributions.gradle file for some great examples of using the CopySpec.
This works.
Sadly, currently I've no clue on how to scale this to more than two projects in a clean way. Atleast we're one step closer :)