Maven (m2e) is not executing ant task

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.

链接地址: http://www.djcxy.com/p/44326.html

上一篇: 终止一个Python脚本

下一篇: Maven(m2e)不执行ant任务