My objective is to include a war to another war. See My Project structure:
+test-parent (here goes all common dependencies for spring & hibernate framework) -- test-core (the collection of all common classes type:jar) -- test-web (the webapp which should run as individual webapp, depends on test-core, type:war) -- test-web-2 (the webapp which depends on test-web,test-core, type:war)
I have used maven war plugin to achieve this.
test-parent/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test-parent</groupId>
<artifactId>test-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>test-core</module>
<module>test-web</module>
<module>test-web-2</module>
</modules>
<dependencies>
<!-- All common spring & hibernate dependencies -->
</dependencies>
</project>
test-core/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test-parent</groupId>
<artifactId>test-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>test-core</artifactId>
</project>
test-web/pom.xml
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test-parent</groupId>
<artifactId>test-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>test-parent</groupId>
<artifactId>test-web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>test-web Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>test-parent</groupId>
<artifactId>test-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<finalName>test-web</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<packagingIncludes>**/*.xml,**/*.properties,**/*.class,**/*.png,**/*.css,**/*.js,**/*.jsp</packagingIncludes>
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
</plugins>
</build>
</project>
test-web-2/pom.xml
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test-parent</groupId>
<artifactId>test-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>test-parent</groupId>
<artifactId>test-web-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>test-web-2 Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>test-parent</groupId>
<artifactId>test-web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>test-parent</groupId>
<artifactId>test-web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<classifier>classes</classifier>
</dependency>
</dependencies>
<build>
<finalName>test-web-2</finalName>
</build>
</project>
As my test-web-2 depends on test-web, I want to merge all classes,resources in test-web-2. when I run mvn install
my all builds are successful, but when I run test-web or test-web-2 on server, it has no lib folder under WEB-INF with all required spring jars from parent.
I have given package & jsp file names different in both projects. I am even able to see the proper merged build as required.
How can I get this lib folder generated in both test-web & test-web-2 project with all dependent jars from parent?