# Dependencies with conflicting name:version jar filenames

**URL:** <https://discuss.gradle.org/t/dependencies-with-conflicting-name-version-jar-filenames/23344>\
**Category:** Help/Discuss\
**Created:** [July 18, 2017, 6:41pm UTC](https://discuss.gradle.org/t/dependencies-with-conflicting-name-version-jar-filenames/23344 "2017-07-18T18:41:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hienle-hps](https://avatars.discourse-cdn.com/v4/letter/h/c0e974/32.png) [@hienle-hps](https://discuss.gradle.org/u/hienle-hps)\
**Post date:** [July 18, 2017, 6:41pm UTC](https://discuss.gradle.org/t/dependencies-with-conflicting-name-version-jar-filenames/23344/1 "2017-07-18T18:41:01Z")

</div>

A rare corner appears with Google’s [cloud-trace-java](https://github.com/GoogleCloudPlatform/cloud-trace-java) library. Given two (poorly named) dependencies:

```
com.google.cloud.trace.v1:sink:0.3.2
com.google.cloud.trace:sink:0.3.2

```

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](https://github.com/GoogleCloudPlatform/cloud-trace-java/issues/80) 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](https://docs.gradle.org/3.4/dsl/org.gradle.api.tasks.bundling.Jar.html#org.gradle.api.tasks.bundling.Jar:archiveName) or ArtifactHandler that applies to Eclipse / WAR generation or the initial JAR download?

---

<div class="post-metadata">

**Author:** ![sterling](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/sterling/32/5395_2.png) [@sterling](https://discuss.gradle.org/u/sterling)\
**Post date:** [July 19, 2017, 3:38am UTC](https://discuss.gradle.org/t/dependencies-with-conflicting-name-version-jar-filenames/23344/2 "2017-07-19T03:38:19Z")

</div>

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

```gradle
war {
    duplicatesStrategy = DuplicatesStrategy.FAIL
    rootSpec.eachFile { fcd ->
        if (fcd.sourcePath =~ /sink/) {
            // Path looks like GRADLE_USER_HOME caches/com.google.cloud.trace/sink/0.3.2/346ef8b68e7ef86ae2db3b942b8f1f4e6c487a19/sink-0.3.2.jar
            def groupName = fcd.file.parentFile.parentFile.parentFile.parentFile.name
            fcd.name = groupName + "-" + fcd.name
        }
    }
}

```

This makes the jars named `com.google.cloud.trace.v1-sink-0.3.2.jar` and `com.google.cloud.trace-sink-0.3.2.jar` respectively.

---

<div class="post-metadata">

**Author:** ![hienle-hps](https://avatars.discourse-cdn.com/v4/letter/h/c0e974/32.png) [@hienle-hps](https://discuss.gradle.org/u/hienle-hps)\
**Post date:** [July 19, 2017, 5:21pm UTC](https://discuss.gradle.org/t/dependencies-with-conflicting-name-version-jar-filenames/23344/3 "2017-07-19T17:21:50Z")

</div>

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?
