title: gradle installDist: How do I prepend the group id to dependency jar name (clashing due to different group id but same artifact id and version)?
body: <h3>The problem in Gradle</h3>
  
  <p>I have this <code>build.gradle</code> in a directory named <code>proj</code>:</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'java-library-distribution'
  repositories {
      mavenCentral()
  }
  dependencies {
      compile 'com.davfx:util:1.0.0'
      compile 'org.johnnei:util:1.0.0'
  }
  </code></pre>
  
  <p>I then run <code>gradle installDist</code> and find that the directory <code>build/install/proj/lib</code> contains only one <code>util-1.0.0.jar</code>. I am expecting two <code>util-1.0.0.jar</code> files, but I think this is impossible due to the way file systems work.</p>
  
  <p>The question is: <strong>How do I prefix the jar names with the group id?</strong> Does Gradle have something like Maven's <a href="https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html#prependGroupId" rel="nofollow noreferrer">prependGroupId</a>?</p>
  
  <h3>The same problem in Maven</h3>
  
  <p>To reproduce the problem, copy the following fragment to <code>pom.xml</code>, and run <code>mvn dependencies:copy-dependencies</code> in the same directory. Observe that the <code>target/dependency</code> directory contains only one file <code>util-1.0.0.jar</code>. However, unlike Gradle, Maven can solve this by <a href="https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html#prependGroupId" rel="nofollow noreferrer">prependGroupId</a>. (Credit goes to Tunaki in the comment section.)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.spacetimecat&lt;/groupId&gt;
      &lt;artifactId&gt;example&lt;/artifactId&gt;
      &lt;version&gt;0.0.0-SNAPSHOT&lt;/version&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.davfx&lt;/groupId&gt;
              &lt;artifactId&gt;util&lt;/artifactId&gt;
              &lt;version&gt;1.0.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.johnnei&lt;/groupId&gt;
              &lt;artifactId&gt;util&lt;/artifactId&gt;
              &lt;version&gt;1.0.0&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <h3>Old (more general) problem description</h3>
  
  <p>Let there be two projects with these coordinates:</p>
  
  <ul>
  <li><code>G:A:1.2.3</code>,</li>
  <li><code>H:A:1.2.3</code>,</li>
  </ul>
  
  <p>that is, they have different group id but the same artifact id and version.</p>
  
  <p>Suppose that I create a project <code>P</code> that depends on both of those. I am getting only one <code>web-1.7.0.jar</code> file when I assemble a distribution package (a package containing my project jar and all its transitive dependencies). The problem is: one of the jar files in the dependencies get overwritten because they have the same file name, because Gradle/Maven by default names the jars like <code>artifactId-version-classifier.jar</code>, although they have different groups.</p>