在 Maven 生命周期映射中为现有插件提供配置
我想提供一个带有自定义
的 Maven 插件,它提供了复杂的生命周期。作为此生命周期的一部分,我需要在不同阶段使用不同配置运行 maven-compiler-plugin 2 次。我想让这个包装尽可能简单易用。目标是该插件的使用者所要做的就是选择新的打包,而不必进行任何插件执行配置:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>some.other.group</groupId>
<artifactId>something-useful</artifactId>
<version>1.0.0</version>
<packaging>my-maven-plugin-jar</packaging>
...
<build>
<plugins>
<plugin>
<groupId>my.group.id</groupId>
<artifactId>my-maven-plugin</artifactId>
<version>0.0.1</version>
<extensions>true</extensions
</plugin>
</plugin>
</build>
</project>
然后我的自定义生命周期将绑定我需要的所有目标,包括两次编译器。问题是,每个编译器传递都将不同的源代码(使用
编译到不同的目标(使用 outputDirectory),并且我无法找到任何方法来配置它们,而不在使用我的插件的 pom 的
子元素我可以使用原型来完成此操作,但在我看来,使用自定义包装来完成此操作会更优雅。有什么建议吗?
I would like to provide a maven plugin with a custom <packaging>
that provides a complex lifecycle. As part of this lifecycle, I need to run the maven-compiler-plugin 2 times in different phases with different configurations. I would like to make this packaging as simple as possible to use. The goal would be that all a consumer of this plugin would have to do is select the new packaging and not have to do any plugin execution configuration:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>some.other.group</groupId>
<artifactId>something-useful</artifactId>
<version>1.0.0</version>
<packaging>my-maven-plugin-jar</packaging>
...
<build>
<plugins>
<plugin>
<groupId>my.group.id</groupId>
<artifactId>my-maven-plugin</artifactId>
<version>0.0.1</version>
<extensions>true</extensions
</plugin>
</plugin>
</build>
</project>
Then my custom lifecycle would bind the all the goals I needed including the compiler both times. The problem is, each compiler pass is compiling different source (using <includes> and <excludes>
into different destinations (using outputDirectory) and I cant find any way to configure them without doing so in the <executions>
sub-element of pom using my plugin. I could do this with an archetype, but it seems to me to be a little more elegant to do this with a custom packaging. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论