What are best practices for managing building a distribution in a multi-project tree?

(Emil Sit) #1

I have a project where I am building a tarball distribution out of a number of sub-projects. Right now, I have a set of of component projects (say, A, B, C, D, which have some interdependencies, such as A and B both depend on D), and a separate sibling project Distrib where I am capturing the logic for pulling the files from A, B, C, D together, dropping in some additional scripts and building the distribution.

Right now I have a mish-mash of Copy tasks in the Distrib project with various evaluationDependsOn() clauses to force A, B, C, D to be parsed first so that I can add various sub-tasks in A, B, C, D as dependencies of various Distrib copy tasks. This is not proving to be particularly maintainable.

I’d ideally like to have something where each individual project (A, B, C, D) can specify that some bits of itself should be “pushed” into various locations defined externally (perhaps by Distrib). For example, A and B might put some jars in a lib directory, C might put some resources into some etc directory, D might put jars in a different lib directory.

I have a vague feeling that configurations and maybe artifacts might be appropriate for this but I can’t quite figure out how to specify the dependencies and locations.

Looking at the Gradle build itself, it looks like the dist tasks are rooted at the top of the build but overall it seems slightly less complex than what I’m thinking about here. Though I’d be happy to be told that I’m wrong, or that there is a better way to organize it.