Skip to content

Instantly share code, notes, and snippets.

@klausbrunner
Last active February 2, 2020 15:17
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save klausbrunner/9954309 to your computer and use it in GitHub Desktop.
Save klausbrunner/9954309 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>
@laddushashavali123
Copy link

hi i have two main classes and i need to run the main classes as the entry points like one for tests and one for MQ injections
please let me know how can i run those using pom.xml
i tried using the above code and manifest multiple entries

@shalk
Copy link

shalk commented May 30, 2019

hi i have two main classes and i need to run the main classes as the entry points like one for tests and one for MQ injections
please let me know how can i run those using pom.xml
i tried using the above code and manifest multiple entries

mvn package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment