我有一个pom.xml
其中I定义相同的plugin
(相同的groupId
和artifactId
不同的execution
在两个不同的:-)) profiles
。的executions
定义是在相同的phase
,因此订单是根据xml中的订单计算的:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>echo</groupId>
<artifactId>test</artifactId>
<name>echo-test</name>
<version>1.0.0</version>
<packaging>pom</packaging>
<profiles>
<profile>
<id>1st-profile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>1st-antrun-echo</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>1st antrun plugin</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>2nd-profile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>maven-echo-plugin</artifactId>
<version>0.1</version>
<executions>
<execution>
<id>1st-soebes-echo</id>
<phase>test</phase>
<goals>
<goal>echo</goal>
</goals>
<configuration>
<echos>
<echo>1st echo-plugin</echo>
</echos>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>2nd-antrun-echo</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>2nd antrun plugin</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
所有插件的执行都在该test
阶段中定义,因此我希望遵循以下顺序:
1st antrun plugin
1st echo-plugin
2nd antrun plugin
但是,由于antrun-plugins
已合并,因此得到以下输出:
1st echo-plugin
1st antrun plugin
2nd antrun plugin
此命令说明了为什么会这样: mvn help:effective-pom
除了引入新阶段以外,还有其他解决方案可以保留订单吗?我们的项目确实很大,这是一个非常简化的示例。
为什么将Maven限制为将插件合并为多个执行?
以我的经验,这是Maven中最大的错误之一。如果您在不同配置文件中为同一插件配置了多个配置,则顺序将无法预测。我什至观察到,在给定的阶段中,我在项目B中有一些插件顺序,并且一旦某些相同的插件在父项目中得到了配置(甚至不在同一阶段),该顺序就被破坏了。
在https://issues.apache.org/jira/browse/MNG-2258上有一个与此相关的明显错误关闭的错误。
我认为您现在无法做更多的事情。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句