Dependencies with conflicting name:version jar filenames

(Hien Le) #1

A rare corner appears with Google’s cloud-trace-java library. Given two (poorly named) dependencies:

one will be lost when packaging sink-0.3.2.jar into a WAR. Using this project in Eclipse gives the error:

Invalid classpath .../sink-0.3.2.jar. The project contains another dependency with the same archive name.

There’s a discussion where the proposed solution is having the maintainers rename one library to sink-api. That seems reasonable but can anything be done right now by the Gradle user? Is there something like Jar.archiveName or ArtifactHandler that applies to Eclipse / WAR generation or the initial JAR download?

(Sterling Greene) #2

This is a bit hacky, but you can rename the jar as it goes into the war file:

war {
    duplicatesStrategy = DuplicatesStrategy.FAIL
    rootSpec.eachFile { fcd ->
        if (fcd.sourcePath =~ /sink/) {
            // Path looks like GRADLE_USER_HOME caches/
            def groupName =
   = groupName + "-" +

This makes the jars named and respectively.

(Hien Le) #3

Thanks! I’ll give that a try.

Any thoughts on how to fix the Eclipse side? The Eclipse plugin generates .classpath entries pointing right into the Gradle cache so renaming seems like it’d have to happen at the source. Is that directory/file layout format of the dependency cache configurable?