How can I invoke or declare dependency to a custom distribution task


(Karl Ivar Dahl) #1

Using the Distribution plugin, I have configured two distributions: “main” and “custom”

Both build using gradle installDist and gradle installCustomDist

Now I want to build all distributions from a single task.

task myCompleteDist(dependsOn: [installDist,installCustomDist]){

The ultimate goal is to have the root project build and merge all distributions of the subprojects into one distribution at the root level, so that the distribution config can be delegated to each sub-project, a feature that is curiously missing from the Distribution plugin.

However, gradle myCompleteDistfails the dependency to installCustomDist, probably because this task is dynamically created by the Distribution plugin:

> Could not find property 'installCustomDist' on root project 'XXX'.

How can I invoke or declare dependency to a custom distribution task?
Is there a better way to build a single merged distribution?

(Karl Ivar Dahl) #2

Just a follow-up to my ultimate goal of having a single merged distribution.

In the root project I have the following declaration:

distributions {
    custom {
	baseName = "custom"
	contents {
		into('') {
			project.subprojects.each { p ->
				p.plugins.withType(DistributionPlugin) {
					from { "${p.buildDir}/install/custom/"}

This should hopefully build all the subproject distributions, and then add these files to the root distribution with the same name. However, I cannot invoke p.tasks.installCustomDist.execute(). I am also unsure if the withType does what I want.

To be honest, this is what I expeted the default Distribution behaviour to be. The distribution config in my root project currently have to reach into all the subprojects in one messy config:

into('deploy/exampleconf') {
    from { "${project(':A').projectDir}/src/main/conf/" }
    from { "${project(':B').projectDir}/src/main/conf/b.xml" }

I would rather have the subprojects themselves declare what should go into a particular distribution.

(Karl Ivar Dahl) #3

Any pointers are appreciated.