【问题标题】:Maven build war modules into an earMaven 将战争模块构建到耳朵中
【发布时间】:2018-03-29 15:21:41
【问题描述】:

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

<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 战争和耳朵?

非常感谢

【问题讨论】:

  • 能否请您出示完整的 pom 文件...
  • 已编辑,感谢有趣:)

标签: maven packaging maven-ear-plugin


【解决方案1】:

创建合适的目录结构:

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

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

mvn clean package 

或者如果你需要:

mvn clean install

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-12
    • 2012-08-28
    • 1970-01-01
    • 2012-05-07
    相关资源
    最近更新 更多