4

I add maven-shaded-plugin into my project and it correctly built the shaded uber jar, but still installed the original thin jar. I'd like to install the shaded uber jar so that downstream projects can depend on this shaded uber jar. How can I do it? Thanks.

Here's my pom file.

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>${plugin.shade.version}</version>
        <configuration>
          <shadeTestJar>true</shadeTestJar>
          <shadedClassifierName>SHADED</shadedClassifierName>
          <shadedArtifactAttached>true</shadedArtifactAttached>
          <filters>
            <filter>
              <artifact>*:*</artifact>
            </filter>
          </filters>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
              <resource>reference.conf</resource>
            </transformer>
          </transformers>
          <artifactSet>

          </artifactSet>
          <!--<outputDirectory>${project.build.directory}/../../interpreter/python</outputDirectory>-->
          <outputFile>${project.build.directory}/../../interpreter/python/${interpreter.jar.name}-${project.version}.jar</outputFile>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
cb4
  • 6,689
  • 7
  • 45
  • 57
zjffdu
  • 25,496
  • 45
  • 109
  • 159

1 Answers1

1

I'm looking for the same answer. I'm using this workaround for now... Don't specify <outputFile> or <finalName> in the maven shade plugin when attaching the shaded artifact. Maven will then install both jars, using the classifier as the differentiator between the two.

Downstream projects can depend on the shaded jar this way:

<dependency>
    <groupId>abc</groupId>
    <artifactId>xyz</artifactId>
    <version>${project.version}</version>
    <classifier>SHADED</classifier>
</dependency>
cb4
  • 6,689
  • 7
  • 45
  • 57