Maven 使用概要文件将WAR模块从';mvn安装';

Maven 使用概要文件将WAR模块从';mvn安装';,maven,maven-profiles,maven-install-plugin,Maven,Maven Profiles,Maven Install Plugin,我的父级pom定义了7个模块,其中5个是依赖jars,两个是依赖于这些jar的wars 问题:在对父pom运行mvn安装以排除两个war软件包时,是否可以使用maven配置文件(或其他解决方案)来定义包括哪些模块 然后,我希望有一个不同的配置文件(或其他解决方案)来包装这两场战争。如果该配置文件已运行,则仅当存储库中缺少依赖项jar模块时,才应重建和安装它们。您可以使用父pom.xml文件中的build helper maven plugin创建基于打包的新属性(在运行时,它将从父级的pom更改

我的父级
pom
定义了7个模块,其中5个是依赖
jar
s,两个是依赖于这些jar的
war
s

问题:在对父pom运行
mvn安装
以排除两个war软件包时,是否可以使用maven
配置文件
(或其他解决方案)来定义包括哪些模块


然后,我希望有一个不同的配置文件(或其他解决方案)来包装这两场战争。如果该配置文件已运行,则仅当存储库中缺少依赖项jar模块时,才应重建和安装它们。

您可以使用父
pom.xml
文件中的
build helper maven plugin
创建基于
打包的新属性(在运行时,它将从父级的
pom
更改为模块的
jar
war
)。然后可以使用此新属性动态跳过
maven安装插件

一个简单的例子:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.10</version>
    <executions>
        <execution>
            <id>build-helper-regex-is-packaging-war</id>
            <phase>validate</phase>
            <goals>
                <goal>regex-property</goal>
            </goals>
            <configuration>
                <name>only.when.war.is.used</name>
                <value>${project.packaging}</value>
                <regex>war</regex>
                <replacement>true</replacement>
                <failIfNoMatch>false</failIfNoMatch>
            </configuration>
        </execution>
    </executions>
</plugin>

<plugin>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.5.2</version>
    <configuration>
        <skip>${only.when.war.is.used}</skip>
    </configuration>
</plugin>

你有没有考虑过mvn——项目模块——也可以使依赖关系成为依赖关系?你解决了这个问题吗?答案对你有帮助吗?
<profiles>
  <profile>
    <activation>
      <file>
        <missing>${settings.localRepository}/${project.groupId}/${project.artifactId}/${project.build.fileName}.${project.packaging}</missing>
      </file>
    </activation>
    ...
  </profile>
</profiles>