Maven将战争模块构建到耳中

时间:2018-03-29 15:21:41

标签: maven packaging maven-ear-plugin

我有一个带有耳包的maven项目,包括两个webModule和maven WAR包的依赖项。每当我构建更改时,我首先需要通过“maven clean install”手动构建两个war,最后我总是通过“maven clean install”构建耳朵。

<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>it.test.esempio.fe</groupId>
        <artifactId>ESEMPIO_FE_PTL_PARENT</artifactId>
        <version>1.32.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>ESEMPIO_FE_TEMA_COMPLETO</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>ear</packaging>
    <dependencies>
        <!-- START: PROJECT DEPENDENCIES -->
        <dependency>
            <groupId>it.test.esempio.fe</groupId>
            <artifactId>ESEMPIO_FE_TEMA_COMPLETO_STATICO</artifactId>
            <version>1.0.0-SNAPSHOT</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>it.test.esempio.fe</groupId>
            <artifactId>ESEMPIO_FE_TEMA_COMPLETO_DINAMICO</artifactId>
            <version>1.0.0-SNAPSHOT</version>
            <type>war</type>
        </dependency>
        <!-- END: PROJECT DEPENDENCIES -->
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.10.1</version>
                <configuration>
                    <version>6</version>
                    <modules>
                        <webModule>
                            <groupId>it.test.esempio.fe</groupId>
                            <artifactId>ESEMPIO_FE_TEMA_COMPLETO_DINAMICO</artifactId>
                            <bundleFileName>ESEMPIO_FE_TEMA_COMPLETO_DINAMICO.war</bundleFileName>
                            <contextRoot>wps/ESEMPIO_FE_TEMA_COMPLETO_DINAMICO</contextRoot>
                        </webModule>
                        <webModule>
                            <groupId>it.test.esempio.fe</groupId>
                            <artifactId>ESEMPIO_FE_TEMA_COMPLETO_STATICO</artifactId>
                            <bundleFileName>ESEMPIO_FE_TEMA_COMPLETO_STATICO.war</bundleFileName>
                            <contextRoot>wps/ESEMPIO_FE_TEMA_COMPLETO_STATICO</contextRoot>
                        </webModule>
                    </modules>
                    <defaultLibBundleDir>lib</defaultLibBundleDir>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

是否有可能只用一个构建命令自动构建2战和耳朵?

非常感谢

1 个答案:

答案 0 :(得分:0)

创建适当的目录结构:

 +-- root (pom.xml)
      +--- war-module1 (pom.xml)
      +--- war-module2 (pom.xml)
      +--- ear-module (pom.xml)

将现有模块列表放入根pom(模块列表)..并定义模块之间的适当依赖关系。现在,您可以通过以下方式一次性构建所有内容:

mvn clean package 

或者如果您需要:

mvn clean install