To create an executable uber JAR, one simply needs to set the main class that serves as the application entry point:
<project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.7.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>org.sonatype.haven.HavenCli</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins> </build> ... </project>
This snippet configures a special resource transformer which sets the Main-Class entry in the MANIFEST.MF of the shaded JAR. Other entries can be added to the MANIFEST.MF as well via key-value pairs in the <manifestEntries> section:
<project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.7.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <manifestEntries> <Main-Class>org.sonatype.haven.ExodusCli</Main-Class> <Build-Number>123</Build-Number> </manifestEntries> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins> </build> ... </project>