Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save achintya-kumar/7f89713e55a8c724d94aebfba3c3e8b6 to your computer and use it in GitHub Desktop.
Save achintya-kumar/7f89713e55a8c724d94aebfba3c3e8b6 to your computer and use it in GitHub Desktop.
Shaded jar with main-class in jar's manifest
<profiles>
        <profile>
            <id>shade</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                	<!-- In case your 'mvn dependency:analyze' is failing. It may be skipped -->
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>3.0.2</version>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                                <configuration>
                                    <transformers>
                                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                            <mainClass>com.achintya.kumar.ClassWithMainMethod</mainClass>
                                        </transformer>
                                    </transformers>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment