我想向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:
<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>有人知道我该如何实现这个目的吗?非常感谢。
发布于 2012-11-29 15:30:15
这是Eclipse M2e插件的诀窍。Sachin Shekhar R是对的,但对于像我这样的新手来说,答案还不够清楚。这是我的理解:
参见http://wiki.eclipse.org/M2E_plugin_execution_not_covered。
在Eclipse M2e中有两种方法可以做到这一点。
Sachin Shekhar R答案中列出的代码。请注意,这段代码必须在<pluginManagement><plugins>下,<pluginManagement>必须在<plugins>内。示例代码:插件生命周期-映射1.0.0 org.codehaus.mojo exec-maven- org.eclipse.m2e[1.2.1,) exec
这只在项目中有效,
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的工作空间配置文件中
这适用于整个工作区
发布于 2012-11-28 19:50:09
我们在下面有类似的代码生成
<execution>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>在插件下面,我们还添加了避免eclipse抱怨的条目。
<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
https://stackoverflow.com/questions/13604255
复制相似问题