Subprojects don't see resolved dependency versions of siblings

I have a gradle project with several sub-projects.

Let’s call them “SomeApp” and “Distribution”

SomeApp is a standard Java project.
Distribution is a project that creates a zip containing an image of the installation folder for SoemApp. It includes the jar for SomeApp, some external resources, and all the dependencies of SomeApp.

The Distribution build.gradle file looks like this:

apply plugin: 'base'
apply plugin: 'maven-publish'
configurations {
dependencies {
    dist project (':SomeApp')
task zipDistribution(type: Zip) {
    destinationDir buildDir
    baseName = 'SomeApp'
    classifier = 'dist'
    version = project.version
    // Strip version info from name of main jar
    from { configurations.dist.findAll {'SomeApp-') &&".jar") }.collect { it } } { rename {'SomeApp.jar'} }
    // put dependencies in a 'lib' subfolder
    from { configurations.dist.findAll { !'SomeApp-') &&".jar") }.collect { it } } { into 'lib' }

Now the problem is that the zip file contains the wrong versions of the dependencies.
It contains the versions of the dependencies that are explicitly declared in SomeApp, even though dependency resolution has bumped some of them to newer versions.
The manifest in SomeApp references the correct, resolved, version with a newer version number, so the install images fails because the classpath in the main Jar manifest doen’t match the name of the files in the distribution. E.g SomeApp declares a dependency on helper-1.0.1, and coollib-2.5.4. coollib-2.5.4 depends on helper-1.0.7, so ultimately SomeApp gets a helper-1.0.7 and the manifest classpath shows lib/helper-1.0.7.jar lib/coollib-2.5.4.jar. However the files copied into the zip by the Distribution project are helper-1.0.1,jar and coollib-2.5.4.jar.


Here is a simpified demonstration of the problem:

This task in my Distribution project will dump different versions of the libraries …

task dumpDist() << {
    configurations.dist.each {
        println "Depends on: ${}"

… than this task in SomeApp:

task dumpRuntime() << {
    configurations.runtime.each {
        println "Depends on: ${}"

Anyone know how I can fix it?


I think I discovered the issue. excludes in one project changed the resolved version.