Using project dependencies for projects which publish multiple artifacts in the same configuration

Multi-project build. Some subprojects are just ‘assembly’ projects: they pull in the output of the other subprojects (jars, zip files, wars, javadoc and sources jars, etc) and assembly them into large distribution archives. The problem is that project dependencies seem to only resolve the first published artifact in a particular configuration, where we expect it to resolve to all files published by that configuration. And there is no extension field in project dependencies, or classifier field, or any of the other fields in a dependency locator that are usually used to narrow down a dependency to a particular file.


projectA: applies ‘java’ plugin, also zips up the jar along with some .html files into a zip. zip artifact is added to the ‘archives’ configuration.

assemblyProject: declares dependency:

configurations {
  dependencies {
  payload project(path: ':projectA', configuration: 'archives')
  task zip(type:Zip) {
  from configurations.payload

The resulting will only contain the jar from projectA, not the zip. Is that intentional? I know I can create additional configurations in projectA, one per published artifact…but not sure that makes sense in all cases.

I guess in general, I’m not clear about how many files a single dependency declaration can/should resolve to. for compile time dependencies, i get that they resolve to one jar…but then, really they resolve to that jar plus all transitive dependencies, and would would the expected behavior be in the subproject published more than one jar file to that configuration?

And when dependencies are used not for the compilation, but just to get handles to sets of files, it’s really more convenient if the dependency resolves to all the files in the set.

This stuff isn’t very clear from the documentation either. Project dependencies work a bit differently than external dependencies (like, you can using classifiers, extensions and other name components to narrow them down), but these differences are not well documented.