Search code examples
mavenmaven-assembly-pluginmaven-shade-plugin

Install über jar with maven-shaded-plugin


I have been using maven assembly plugin to create uber jar and deploy to Artifactory. I switched to maven shade plugin to shade some dependencies. Now my jar is not deployed during install phase.

In the maven assembly plugin documentation:

When the assembly is created it will use the assemblyId as the artifact's classifier and will attach the created assembly to the project so that it will be uploaded into the repository in the install and deploy phase.

This is not a case for shaded plugin. How to configure maven pom to deploy uber jar created with shaded plugin?


Solution

  • You have to tell maven-shade-plugin to attach the shaded artifact which can be done via:

    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.2.2</version>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <shadedArtifactAttached>true</shadedArtifactAttached>
                  <shadedClassifierName>jackofall</shadedClassifierName> <!-- Any name that makes sense -->
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      ...
    </project>