【发布时间】:2014-04-04 16:54:34
【问题描述】:
我有一个pom.xml,我在两个不同的profiles 中定义了相同的plugin(相同的groupId 和artifactId,不同的execution :-))。 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 会限制将插件合并为一个并执行多个操作?
【问题讨论】:
-
你真的需要这些资料吗?
-
是的,在我的项目中,我确实需要这些配置文件。该示例是我正在处理的项目的一个非常简化的投影。
-
您可以提交您的 pom 作为以下 MNG-2258 错误的示例。
标签: java maven maven-3 maven-plugin