Maven(m2e)不执行ant任务 [英] Maven (m2e) is not executing ant task
问题描述
我有一个POM文件(由Eclipse执行),我想在 generate-sources
阶段执行一个ANT任务。根据 m2e文档,在如何解决不被生命周期配置覆盖的插件执行 ;对于Spring Data Maven构建, Maven:在包和应该放在哪里maven-编译器插件声明:在< plugins>或者& pluginManagement> ;? ,我以这种方式写了我的POM文件:
<?xml version = 1.0encoding =UTF-8?>
< project>
...
< build>
< pluginManagement>
< plugins>
...
< plugin>
< groupId> org.eclipse.m2e< / groupId>
< artifactId>生命周期映射< / artifactId>
< version> 1.0.0< / version>
< configuration>
< lifecycleMappingMetadata>
< pluginExecutions>
< pluginExecution>
< pluginExecutionFilter>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-antrun-plugin< / artifactId>
< versionRange> [1.8,)< / versionRange>
< goals>
< goal> generate-sources< / goal>
< / goals>
< / pluginExecutionFilter>
< action>
< execute />
< / action>
< / pluginExecution>
< / pluginExecutions>
< / lifecycleMappingMetadata>
< / configuration>
< / plugin>
< / plugins>
< / pluginManagement>
< plugins>
< plugin>
<! - 插件1 - >
< / plugin>
< plugin>
<! - 要在生成源阶段执行的插件。 - >
< / plugin>
< plugin>
<! - 应该在上面的插件之后的生成源阶段。 - >
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-antrun-plugin< / artifactId>
< version> 1.8< / version>
<执行>
< execution>
< id> ant-test< / id>
< configuration>
< task>
< echo message =ANT TEST/>
< / task>
< / configuration>
< goals>
< goal>运行< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< / plugins>
< / build>
...
< / project>
从我的阅读中我了解的是,我要求告诉Maven以下内容:首先询问Maven(m2e)的Eclipse插件,以便在 generate-sources
中执行maven-antrun-plugin(1.8或更高版本)。接下来,在 generate-sources
阶段中,在第一个插件执行之后,调用ant插件来运行回显我的消息的任务。 >
但是,messagem没有显示。当我执行 generate-sources
目标时也不执行安装
目标。
如果按照这个使用权限,然后添加< phase>
元素< execution>
,如下所示:
<执行>
< execution>
< id> ant-test< / id>
*< phase> generate-sources< / phase> *
< configuration>
< task>
< echo message =ANT TEST/>
< / task>
< / configuration>
< goals>
< goal>运行< / goal>
< / goals>
< / execution>
< / executions>
我有一个Eclipse错误消息:生命周期配置未涵盖的插件执行:org.apache .maven.plugins:maven-antrun-plugin:1.8:run(execution:ant-test,phase:generate-sources)。 这里显示了没有特定的< pluginManagement>
为ant插件。但是我也没有成功。
那么这里是什么?
谢谢,
Rafael Afonso
实际上,我发现错误消息插件执行没有被生命周期配置覆盖:org.apache.maven.plugins:maven-antrun-plugin:1.8:run(execution:ant-test,phase:generate-sources)在Maven执行中没有任何影响。该消息显示没有问题。说实话,我不得不将任务
更改为 target
,但是该消息仍然显示。可能这只是一种m2e的bug,唯一的效果是让我们感到恼怒。
I have a POM file (to be executed by Eclipse) where I want to execute a ANT task during the generate-sources
phase. Based on m2e documentation, in How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds, Maven: execute antrun task during package and Where should be placed maven-compiler-plugin declaration: in <plugins> or <pluginManagement>?, I wrote my POM file in this way:
<?xml version="1.0" encoding="UTF-8"?>
<project>
...
<build>
<pluginManagement>
<plugins>
...
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>[1.8,)</versionRange>
<goals>
<goal>generate-sources</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<!-- Plugin 1 -->
</plugin>
<plugin>
<!-- Plugin to be executed during generate-sources phase. -->
</plugin>
<plugin>
<!-- Should be in the generate-sources phase after the plugin above. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>ant-test</id>
<configuration>
<task>
<echo message="ANT TEST" />
</task>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
What I understood from my reading, is that I am asking telling to Maven the following: First ask to Eclipse plugin for Maven (m2e) to allow the maven-antrun-plugin (version 1.8 or above) to be executed during generate-sources
. Next, in the generate-sources
phase and after the execution of the first plugin, call the ant plugin to run the task which echo my message.
However, the messagem is not being showed. Neither when I execute just the generate-sources
goal nor when I execute the install
goal.
I if follow this sugestion here, and add the <phase>
element inside <execution>
, like here:
<executions>
<execution>
<id>ant-test</id>
*<phase>generate-sources</phase>*
<configuration>
<task>
<echo message="ANT TEST" />
</task>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
I have a Eclipse error message: Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-antrun-plugin:1.8:run (execution: ant-test, phase: generate-sources). Here shows a example where there is no a specific <pluginManagement>
for ant plugin. But also I had no success.
So What is missing here?
Thanks,
Rafael Afonso
Actually, I discovered that the error message Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-antrun-plugin:1.8:run (execution: ant-test, phase: generate-sources) has no effect in the Maven execution. The message is shown with no problems. To speak the truth, I had to change the task
to target
, but the message continues to be displayed. May be it is just a kind m2e's bug which the only effect is annoys us.
这篇关于Maven(m2e)不执行ant任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!