我对我的 Jenkins 输出感到有些困惑。
关于 Jenkins 的工作:(在底部缩短了 pom.xml)
mvn deploy -Pprofile1
我所有的插件将运行 4 次:
我需要:
为什么:
父 pom.xml
<project ...>
<groupId>com.test.parent</groupId>
<modelVersion>4.0.0</modelVersion>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>parent</name>
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
</modules>
<profiles>
<profile>
<id>profile1</id>
<build>
<plugins>
<plugin>
<groupId>com.test.plugin</groupId>
<artifactId>first-maven-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<execution>
<id>execution1</id>
<phase>initialize</phase>
<goals>
<goal>doit</goal>
</goals>
</execution>
</plugin>
<plugin>
<groupId>com.test.plugin2</groupId>
<artifactId>second-maven-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<execution>
<id>another</id>
<phase>package</phase>
<goals>
<goal>goforit</goal>
</goals>
</execution>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
最佳答案
您可以使用 <inherited>false</inherited>
在第一个插件配置中。所以它只会在父 pom 执行中运行。
<build>
<plugins>
<plugin>
<groupId>com.test.plugin</groupId>
<artifactId>first-maven-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<inherited>false</inherited>
<execution>
<id>execution1</id>
<phase>initialize</phase>
<goals>
<goal>doit</goal>
</goals>
</execution>
</plugin>
<plugin>
<groupId>com.test.plugin2</groupId>
<artifactId>second-maven-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<execution>
<id>another</id>
<phase>package</phase>
<goals>
<goal>goforit</goal>
</goals>
</execution>
</plugin>
</plugins>
</build>
见 https://stackoverflow.com/a/1671175
关于Maven 配置文件 - 如何为父级和模块运行一次插件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36216342/