Maven (m2e) 没有执行蚂蚁任务 [英] Maven (m2e) is not executing ant task

查看:38
本文介绍了Maven (m2e) 没有执行蚂蚁任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 POM 文件(由 Eclipse 执行),我想在 generate-sources 阶段在其中执行 ANT 任务.基于 m2e 文档,在 如何解决生命周期配置未涵盖的插件执行";对于 Spring Data Maven 构建Maven:在打包期间执行 antrun 任务应该放在哪里 maven-编译器插件声明:在 <plugins> 中还是<pluginManagement>?,我的POM文件是这样写的:

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>

我从阅读中了解到,我要求告诉 Maven 以下内容:首先询问 Maven (m2e) 的 Eclipse 插件以允许 maven-antrun-plugin(1.8 版或更高版本)在 generate-sources 期间执行.接下来,在generate-sources阶段,在第一个插件执行后,调用ant插件运行回显我的消息的任务.

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.

但是,没有显示消息.当我只执行 generate-sources 目标或执行 install 目标时.

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>

我有一条 Eclipse 错误消息:生命周期配置未涵盖插件执行:org.apache.maven.plugins:maven-antrun-plugin:1.8:run (execution: ant-test, phase: generate-sources).此处显示了一个示例,其中没有针对 ant 插件的特定 .但我也没有成功.

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.

那么这里缺少什么?

谢谢,

拉斐尔·阿方索

推荐答案

实际上,我做了下面的结构,并且奏效了:

Actually, I did the structure below, and it worked:

<build>
        <plugins>
            <plugin>
                ....
            </plugin>
            <plugin>
                ...
            </plugin>
        </plugins>
        <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>run</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
</build>

这篇关于Maven (m2e) 没有执行蚂蚁任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆