如何设置maven插件在同一阶段和不同插件的执行顺序



我想在运行maven插件之前和之后打印消息。

我试着这样做:

<plugins>
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>echo-maven-plugin</artifactId>
<version>0.5.0</version>
<executions>
<execution>
<id>echo-before-call-plugin</id>
<phase>compile</phase>
<goals>
<goal>echo</goal>
</goals>
<configuration>
<echos>
<echo>Before run plugin antrun.</echo>
</echos>
</configuration>
</execution>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<tasks>
.....
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>echo-maven-plugin</artifactId>
<version>0.5.0</version>
<executions>
<execution>
<id>echo-before-call-plugin</id>
<phase>compile</phase>
<goals>
<goal>echo</goal>
</goals>
<configuration>
<echos>
<echo>After run plugin antrun.</echo>
</echos>
</configuration>
</execution>
</plugin>
</plugins>

但是它得到一个错误-在*。

接下来我试着这样做:

<plugins>
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>echo-maven-plugin</artifactId>
<version>0.5.0</version>
<executions>
<execution>
<id>echo-before-call-plugin</id>
<phase>compile</phase>
<goals>
<goal>echo</goal>
</goals>
<configuration>
<echos>
<echo>Before run plugin antrun.</echo>
</echos>
</configuration>
</execution>

<execution>
<id>echo-after-call-plugin</id>
<phase>compile</phase>
<goals>
<goal>echo</goal>
</goals>
<configuration>
<echos>
<echo>After run plugin antrun.</echo>
</echos>
</configuration>
</execution>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<tasks>
.....
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

没有错误,但是在运行anrun插件之前打印这两个消息。如何在运行插件之前强制打印第一个消息,在它之后强制打印第二个消息。

将插件置于不同的生命周期阶段。其他的都很脆弱。

相关内容

  • 没有找到相关文章

最新更新