首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >exec-maven-plugin无法在编译阶段之前启动

exec-maven-plugin无法在编译阶段之前启动
EN

Stack Overflow用户
提问于 2012-11-28 19:42:07
回答 2查看 3.5K关注 0票数 1

我想向Java资源文件中写入额外的文本(将两个.java文件合并为一个)。为此,我编写了一个python脚本。

我还想使用Maven自动执行这些步骤(组合文件、编译、打包)。我是Maven的新手,我发现exec-maven-plugin可以运行python脚本。

我尝试将<phase>process-resources</phase>设置为在编译前启动,但Eclipse抱怨Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (execution: default, phase: process-resources)

下面是我的exec-maven-plugin的pom:

代码语言:javascript
复制
  <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
            <execution>
                <phase>process-resources</phase> <!-- Eclipse complains an error here -->
                <goals>
                    <goal>exec</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <executable>python</executable>
            <workingDirectory>src/main/python</workingDirectory>
            <arguments>
                <argument>combine.py</argument>
            </arguments> 
        </configuration>
    </plugin>

有人知道我该如何实现这个目的吗?非常感谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-11-29 15:30:15

这是Eclipse M2e插件的诀窍。Sachin Shekhar R是对的,但对于像我这样的新手来说,答案还不够清楚。这是我的理解:

参见http://wiki.eclipse.org/M2E_plugin_execution_not_covered

在Eclipse M2e中有两种方法可以做到这一点。

  1. 使用Sachin Shekhar R答案中列出的代码。请注意,这段代码必须在<pluginManagement><plugins>下,<pluginManagement>必须在<plugins>内。示例代码:

插件生命周期-映射1.0.0 org.codehaus.mojo exec-maven- org.eclipse.m2e[1.2.1,) exec

这只在项目中有效,

  • 使用M2e插件的“快速修复”功能。它存在于1.0版之后。在Problems选项卡中查找错误。右击它,选择“快速修复”。将会弹出一个快速修复窗口,选择第二个选项Mark goal exec as ignored in Eclipse build in Eclipse references (experimental)

该方法将上述<lifecycleMappingMetadata>之间的代码写入生命周期映射到workspace/.metadata/.plugins/org.eclipse.m2e.core/lifecycle-mapping-metadata.xml的工作空间配置文件中

这适用于整个工作区

票数 3
EN

Stack Overflow用户

发布于 2012-11-28 19:50:09

我们在下面有类似的代码生成

代码语言:javascript
复制
<execution>
    <phase>generate-sources</phase>
    <goals>
        <goal>java</goal>
    </goals>
</execution>

在插件下面,我们还添加了避免eclipse抱怨的条目。

代码语言:javascript
复制
        <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.codehaus.mojo
                                    </groupId>
                                    <artifactId>
                                        exec-maven-plugin
                                    </artifactId>
                                    <versionRange>
                                        [1.2.1,)
                                    </versionRange>
                                    <goals>
                                        <goal>java</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution></pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>

来自生命周期映射的GWT源代码的实时示例- http://code.google.com/searchframe#T04cSGC7sWI/trunk/samples/expenses/pom.xml

参考说明- stackoverflow.com/questions/6352208/how-to-solve-plugin-execution-not-covered-by-lifecycle-configuration-for-sprin

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13604255

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档