我想在运行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>
但是它得到一个错误-在 *.pom文件中我们只能使用一次插件。
接下来我试着这样做:
<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>
有没有错误,但这两个消息都是在运行前打印的antrun插件.如何强制打印第一个mesege前runig插件,和第二个后.
1条答案
按热度按时间k97glaaz1#
把插件放到不同的生命周期阶段,其他的都很脆弱。