How to combine two war files into single deploy-able war.This can be achieved by using Maven overlay as part of Maven war plugin. Below steps can be used to achieve the same
Lets say project 1 wanted to include in project 2.
Step 1:
Declare packing type as war in project 1 in pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>com.merge</groupId>
<artifactId>Test1</artifactId>
<packaging>war</packaging>
Step 2:
Declare project 1 as dependency in project 2 pom.xml
<dependency>
<groupId>com.merge</groupId>
<artifactId>Test1</artifactId>
<version>0.0.2-SNAPSHOT</version>
<type>war</type>
<scope>provided</scope>
</dependency>
And finally add below plugin in project 2 build configuration in pom.xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<overlays>
<overlay>
<groupId>com.merge</groupId>
<artifactId>Test1</artifactId>
</overlay>
</overlays>
</configuration>
</plugin>
Now final war file in project 2 contains files in both the war files. Please note static content in the first project should be under webapp folder to copy properly in the final war.
Lets say project 1 wanted to include in project 2.
Step 1:
Declare packing type as war in project 1 in pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>com.merge</groupId>
<artifactId>Test1</artifactId>
<packaging>war</packaging>
Step 2:
Declare project 1 as dependency in project 2 pom.xml
<dependency>
<groupId>com.merge</groupId>
<artifactId>Test1</artifactId>
<version>0.0.2-SNAPSHOT</version>
<type>war</type>
<scope>provided</scope>
</dependency>
And finally add below plugin in project 2 build configuration in pom.xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<overlays>
<overlay>
<groupId>com.merge</groupId>
<artifactId>Test1</artifactId>
</overlay>
</overlays>
</configuration>
</plugin>
Now final war file in project 2 contains files in both the war files. Please note static content in the first project should be under webapp folder to copy properly in the final war.
0 Comments
Post a Comment