2

I have three projects. The WAR files of first two project are included in the EAR of the third project. Currently I am performing maven build for the three projects individually.

But my requirement is I need to build only the third project which should automatically build the first two projects (WAR files) and then it should build the third project's EAR.

Do any one know how to achieve it.

Below is the POM of the third project.

<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>au.com.mercury</groupId>
  <artifactId>ReplenishmentR4</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>ear</packaging>
  <build>
  <plugins>
    <plugin>
      <artifactId>maven-ear-plugin</artifactId>
      <version>2.6</version>
      <configuration>
        <applicationXML>src/main/application/META-INF/application.xml</applicationXML>
        <generateApplicationXml>false</generateApplicationXml>
        <encoding>UTF-8</encoding>
        <defaultLibBundleDir>lib/</defaultLibBundleDir>
        <filtering>true</filtering>
        <modules>
          <webModule>
            <groupId>au.com.mercury</groupId>
            <artifactId>Replenishment</artifactId>
            <bundleFileName>Replenishment.war</bundleFileName>
          </webModule>
          <webModule>
            <groupId>au.com.mercury</groupId>
            <artifactId>ReplenishmentR3</artifactId>
            <bundleFileName>ReplenishmentR3.war</bundleFileName>
          </webModule>
        </modules>
      </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
            <source>1.6</source>
            <target>1.6</target>
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-toolchains-plugin</artifactId>
        <version>1.1</version>
        <executions>
          <execution>
            <goals>
              <goal>toolchain</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <toolchains>
            <jdk>
              <version>1.6</version>
              <vendor>sun</vendor>
            </jdk>
          </toolchains>
        </configuration>
    </plugin>
  </plugins>
   <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
          <lifecycleMappingMetadata>
               <pluginExecutions>
                  <pluginExecution>
                      <pluginExecutionFilter>
                          <groupId>
                              org.apache.maven.plugins
                          </groupId>
                          <artifactId>
                              maven-toolchains-plugin
                          </artifactId>
                          <versionRange>
                              [1.1,)
                          </versionRange>
                          <goals>
                              <goal>toolchain</goal>
                          </goals>
                      </pluginExecutionFilter>
                      <action>
                          <ignore></ignore>
                      </action>
                  </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <finalName>ReplenishmentR4</finalName>
</build>

<dependencies>

  <dependency>
    <groupId>au.com.mercury</groupId>
    <artifactId>Replenishment</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>war</type>
  </dependency>
  <dependency>
    <groupId>au.com.mercury</groupId>
    <artifactId>ReplenishmentR3</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>war</type>
  </dependency>
  </dependencies>
</project>
Aravind
  • 1,145
  • 6
  • 18
  • 44

2 Answers2

2

Thanks Guys, I have created the fourth pom on top of all the projects. Below is the code.

<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>au.com.woolworths.mercury</groupId>
  <artifactId>ReplenishmentR5</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <modules>
    <module>Replenishment</module>
    <module>ReplenishmentR3</module>
    <module>ReplenishmentR4</module>
  </modules>
</project>
Aravind
  • 1,145
  • 6
  • 18
  • 44
1

In the modulues, you can refer to other web project's pom.xml.

<module>../Replenishment</module>

This will work only if you have them in relative to the parent pom