Note : It is recommended to create a single from one pom. If possible then try to decompose the package structure to create multiple projects and create one jar for one project. If it is not helpful then use the below process to create multiple jars from single pom.
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>any_Id</id>
<goals><goal>jar</goal></goals>
<phase>package</phase>
<configuration>
<finalName>JarOne</finalName>
<encoding>ISO-8859-1</encoding>
<classifier>Core</classifier> <!-- This will be appended with the jar created with finalName tag value if present-->
<includes>
<include>**/*.*</include>
</includes>
<excludes>
<exclude>**/test.*</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>any_Id</id>
<goals><goal>jar</goal></goals>
<phase>package</phase>
<configuration>
<finalName>JarOne</finalName>
<encoding>ISO-8859-1</encoding>
<classifier>NonCore</classifier> <!-- This will be appended with the jar created-->
<includes>
<include>**/*.*</include>
</includes>
<excludes>
<exclude>**/test.*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
Create more than one <execution> to create individual jars. The names of the jars will be appended with the value of <classifier> tag. If you are including <finalName> tag then the jar name will be as follows.
JarOne-Core.jar
JarOne-NonCore.jar
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>any_Id</id>
<goals><goal>jar</goal></goals>
<phase>package</phase>
<configuration>
<finalName>JarOne</finalName>
<encoding>ISO-8859-1</encoding>
<classifier>Core</classifier> <!-- This will be appended with the jar created with finalName tag value if present-->
<includes>
<include>**/*.*</include>
</includes>
<excludes>
<exclude>**/test.*</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>any_Id</id>
<goals><goal>jar</goal></goals>
<phase>package</phase>
<configuration>
<finalName>JarOne</finalName>
<encoding>ISO-8859-1</encoding>
<classifier>NonCore</classifier> <!-- This will be appended with the jar created-->
<includes>
<include>**/*.*</include>
</includes>
<excludes>
<exclude>**/test.*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
Create more than one <execution> to create individual jars. The names of the jars will be appended with the value of <classifier> tag. If you are including <finalName> tag then the jar name will be as follows.
JarOne-Core.jar
JarOne-NonCore.jar
No comments:
Post a Comment
Thank You for your valuable comment