[GRADLE-3330] Fails to resolve multiple configurations of the same project when 'archiveName' is specified Created: 04/Aug/15  Updated: 15/Nov/15  Resolved: 04/Aug/15

Status: Resolved
Project: Gradle
Affects Version/s: 2.5, 2.6, 2.7, 2.8, 2.9
Fix Version/s: 2.10-rc-1

Type: Bug
Reporter: Sterling Greene Assignee: Unassigned
Resolution: Fixed Votes: 0


 Description   

I have discovered an issue in the gradle 2.5 and 2.6-RC2 with multi-project builds. Or perhaps is a feature. smile Anyway, what works with gradle 2.3 and 2.4 does not work anymore with gradle 2.5+.

I have created a small project that can reproduce the issue. It consists of a root project with two-subprojects

root_project
-> core
-> petshop
settings.gradle

The root project has only the settings.gradle file:

include "core"
include "petshop"

The core project has the following build.gradle:

apply plugin: 'java' 
configurations{
    cats
}
sourceSets {
    cats 
}
dependencies {
    catsCompile project(':core')
}
jar {
    archiveName = "animals.jar"
} 
task createCats(type: Jar) {
    from sourceSets.cats.output
    archiveName "cats.jar"
}
artifacts {
    cats createCats
}

The core sub-project produces two artifacts: the default animals.jar and the cats.jar from the cats configuration.

The petshop project build.gradle:

apply plugin: 'java'
dependencies {
    compile project(':core') // required animals.jar
    compile project(path: ':core', configuration: 'cats')  // required cats.jar
}   
jar {
    archiveName = "petshop.jar"
}

The petshop project requires for compilation both animals.jar and cats.jar. But it seems that gradle places just one of the dependencies in the class-path of the petshop project. Depending of the order of the dependencies, the build fails finding classes from the animal.jar or cats.jar.



 Comments   
Comment by Sterling Greene [ 04/Aug/15 ]

test case https://github.com/gradle/gradle/commit/22ed74e3cb3084ba66be8ba5db3f4bfb2e33c5e7

Comment by Daz DeBoer [ 04/Aug/15 ]

This issue appears when `archiveName` is used to configure the full name of the generated jar. It does not appear if the archive name is set via `baseName` or some other attribute on the `Jar` task.

Comment by Daz DeBoer [ 15/Nov/15 ]

Turns out this was not fixed properly in Gradle 2.7. Applying the 'base' plugin is required to reproduce the failure.

This is related to GRADLE-3362

Generated at Wed Jun 30 12:45:58 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.