maven生成eclipse项目进行自定义打包
对于我正在开发的一个项目,我定义了一个自定义 Maven 打包以及关联的生命周期(通过定义 components.xml
和定义 LifecycleMapping
)。
显然,这个打包对应于一个特定的开发,已在 Eclipse 中为其创建了一个插件。我想做的是根据我的 pom.xml 内容配置 Eclipse。
我显然已经看过 可定制构建生命周期,但我对提供的信息感到非常困惑。
据我了解,我必须在我的目标项目中定义一个构建插件,我将在其中添加特定于我的项目的配置元素。举个例子,如果有一个名为 mycompany.mydev.MyEclipseConfigurator
的配置器,我必须写
<build> <plugins> <plugin> <groupId>org.maven.ide.eclipse</groupId> <artifactId>lifecycle-mapping</artifactId> <version>0.9.9-SNAPSHOT</version> <configuration> <mappingId>customizable</mappingId> <configurators> <configurator id='mycompany.mydev.MyEclipseConfigurator'/> </configurators> </configuration> </plugin> </plugins> </build>
Am I right ?
for a project I'm working on, I've defined a custom maven packaging, and the associated lifecycle (through the definition of a components.xml
and the definition of a LifecycleMapping
).
Obviously, this packaging corresponds to a specific development, for which a plugin has been created in Eclipse. What I would like to do is configure Eclipse according to my pom.xml content.
I've obviously looked at Customizable build lifecycle, but I'm more than confused by provided information.
From what I understand, I must define in my target project a build plugin, in which i'll add configuration elements specific to my project. As an example, having a configurator called mycompany.mydev.MyEclipseConfigurator
, I'll have to write
<build> <plugins> <plugin> <groupId>org.maven.ide.eclipse</groupId> <artifactId>lifecycle-mapping</artifactId> <version>0.9.9-SNAPSHOT</version> <configuration> <mappingId>customizable</mappingId> <configurators> <configurator id='mycompany.mydev.MyEclipseConfigurator'/> </configurators> </configuration> </plugin> </plugins> </build>
Am I right ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上,前面提到的文档是指已弃用的 Maven Eclipse 插件版本。
最新的 -最新版本清楚地说明了如何通过指定项目的性质和构建器从 maven pom.xml 中配置 eclipse 项目。
In fact, previously mentionned documentation refers to deprecated version of maven eclipse plugin.
The most up-to-date version clearly states how to configure eclipse project from within maven pom.xml by specifying project's nature and builders.
我的自定义打包遇到的问题是 Maven 无法识别该项目是基于 Java 的,因此 Maven Eclipse 插件没有在
.project
文件中生成正确的条目,并且没有生成.classpath
。第一件事可以通过在 POM 中添加正确的构建命令和性质来纠正,但这仍然不会为您提供
.classpath
。解决方案是将以下片段添加到您的
components.xml
中:添加此内容后,MEP 会将您的项目视为普通的 JAR 或 WAR 项目,并为其生成预期的 Eclipse 配置。
The problem I had with our custom packaging, is that Maven did not recognize the project as being Java-based, hence the Maven Eclipse Plugin did not generate the right entries in the
.project
file, and did not generate a.classpath
.The first thing can be corrected by adding the right build commands and natures in the POM, but that still does not give you a
.classpath
.The solution is to add the following fragment to your
components.xml
:With this addition, the MEP will treat your project as a normal JAR or WAR project and generate the expected Eclipse configuration for it.