Skip to content

Instantly share code, notes, and snippets.

@wytten
Forked from klausbrunner/two-main-jars-pom.xml
Created April 18, 2018 13:33
Show Gist options
  • Save wytten/b1379c23a643d19cca0954a5a2a65fdf to your computer and use it in GitHub Desktop.
Save wytten/b1379c23a643d19cca0954a5a2a65fdf to your computer and use it in GitHub Desktop.
Creating two different executable JARs with dependencies from the same Maven project - same contents but different Main class in the manifest
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-assembly1</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.ClassName1</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>name1</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
<execution>
<id>make-assembly2</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.ClassName2</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>name2</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment