Transitive custom configurations and artifacts


(Jacob Aleksynas) #1

Given the following dependency tree of a multi-module build.

myWar -> myImpl -> myDomain -> myLibrary -> 3rd party external dependencies.

For each of these java projects I am attaching a “resource” zip artifact to the “resource” configuration.

in the myWar project I would like to gather and merge the zip from each dependent project. in this way the configuration files and resources relevant to each subproject is stored with each project. These resources can be configuration templates so just putting them in the jar is not an option. I would like them externalized for further processing.

configurations { deliverables }
dependencies {
        deliverables project(':myApp:myWar')
}
  task deliver << {
   //copy war files to a directory
   //merge the resource.zip files from all transitive children of my 'deliverables'
}

In the case above I get only the jar of myWar. with configuration: archives I get just the war with configuration: resource I get just the resource

with

configurations {
  archives { extendsFrom resource }
 }

I can get both the war and the resource.zip – though I can’t seem to get at the transitive resource.zip files.

something like the ivy <dependency … conf=“config->config(default)” would help.

Is there a way short of listing each sub project resource configuration in the deliverables?

Ideally as the projects add code and configuration other consumers would immediately get them without having to modify the dependencies higher up the stack. This is akin to source jars; but I can’t seem to get those transitively either.

Any ideas are appreciated.


(Luke Daley) #2

Project dependencies are dependencies on a specific configuration (if unspecified this is the “default” configuration, which extends “runtime” for the java, war, ear plugins).

So, a project dependency does not mean a dependency on all configurations of the other project.