2

On running mvn package:shade shade, the log has entry which says:Replacing XYZ.jar with XYZ-shaded.jar but in my target directory, I cannot find shaded jar enter image description here

This is my pom regarding maven shade

enter image description here

After trying , this pom helped me

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.1.1</version>
        <configuration>
            <filters>
                <filter>
                    <artifact>*:*</artifact>
                    <excludes>
                        <exclude>META-INF/*.SF</exclude>
                        <exclude>META-INF/*.DSA</exclude>
                        <exclude>META-INF/*.RSA</exclude>
                    </excludes>
                </filter>
            </filters>
        </configuration>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>shade</goal>
                </goals>
                <configuration>
                    <shadedArtifactAttached>true</shadedArtifactAttached>
                    <shadedClassifierName>shaded</shadedClassifierName>
                    <transformers>
                        <transformer
                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                            <resource>reference.conf</resource>
                        </transformer>
                        <transformer
                            implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <manifestEntries>
                                <Main-Class>akkaexample.Akkmain</Main-Class>
                            </manifestEntries>
                        </transformer>
                        <transformer
                            implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>akkaexample.Akkmain</mainClass>
                        </transformer>
                    </transformers>
                </configuration>
            </execution>
        </executions>
    </plugin>
asherbret
  • 5,439
  • 4
  • 38
  • 58
Roma Jain
  • 333
  • 4
  • 13

1 Answers1

4

Have your checked whether the output jar file is the shaded one?

The Shade plugin is probably replacing the original file here, meaning overwriting it with the shaded version.

If you wish to get both jar files (shaded and unshaded) at the end, you probably need to set the shadedArtifactAttached property to true:

Defines whether the shaded artifact should be attached as classifier to the original artifact. If false, the shaded jar will be the main artifact of the project

See Maven Shade Mojo Documentation.

Patrick
  • 4,720
  • 4
  • 41
  • 71