Sea*_*oyd 20 java eclipse m2eclipse maven m2e
我已经使用m2eclipse 2年左右,现在已经切换到m2e.
不幸的是,这已经破坏了我的一些功能.
在许多项目中,我生成了Java代码,通常是通过库项目中的主类生成的.这是一个典型的设置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>generateDTOs</id>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<mainClass>com.somecompany.SomeCodeGenerator</mainClass>
<arguments>
<argument>${project.build.directory}/generated-sources/foo</argument>
<argument>${project.basedir}/path/to/a/config/file</argument>
<argument>more arguments</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>addDtoSourceFolder</id>
<goals>
<goal>add-source</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/foo</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
以前,我只需要使用eclipse作为maven项目导入该项目,代码将自动执行并将源文件夹添加到eclipse项目中.
现在,m2e已经为buildhelper插件安装了一个"连接器",因此创建了源文件夹,但我必须通过执行手动触发代码生成Run As > Maven > generate-sources.这真的很烦人,我想maven构建响应pom.xml更改Project > Clean ...,SVN更新,Eclipse启动等,就像以前一样.
我能做些什么让m2e像m2eclipse一样工作?
Jon*_*rth 21
你必须告诉M2E,可以将代码生成器作为Eclipse构建的一部分运行:
<project>
<build>
[...]
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence
on the Maven build itself. -->
<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>[,)</versionRange>
<goals>
<goal>java</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
笔记:
| 归档时间: |
|
| 查看次数: |
10707 次 |
| 最近记录: |