opticyclic
opticyclic

Reputation: 8106

Gradle - Create A Tar Of All Subprojects

I have a multi-project gradle build that builds a war file in each of the sub-projects when I run "gradle war".

I now want to create a dist or a tar task in the root project that adds all the war files into a tar.

How do I run a task that depends on specific tasks of sub-projects?

I tried this but the war tasks don't get run.

task explodedDist() {
    dependsOn tasks.withType(War)
    println "Finish"
}

This runs, however, I would rather not have to explicitly list the names of all the sub-projects in the root task.

task explodedDist()  {
    dependsOn ':first:war'
    dependsOn ':second:war'

    println "Finish"
}

Is there a better way using "subprojects" or the like?

I am essentially building all sub-projects then taring them up as a dist. This seems like it should be fairly common. What is the proper way to do this?

Upvotes: 1

Views: 883

Answers (1)

Peter Niederwieser
Peter Niederwieser

Reputation: 123890

task dist(type: Tar) {
    from { subprojects.war }
}

Upvotes: 1

Related Questions