我正在研究多模块项目。我想在构建其中一个模块后运行我的插件。这个 mojo 应该只能直接从 CLI 运行,不能附加到阶段,因为在某些环境中我们不想运行这个目标。
配置我的插件的最佳方法是什么?它应该在父级中配置还是应该在模块中配置?
如果我在父级和模块中都配置它,模块配置会覆盖父级配置吗?
如果我仅在父级中配置它,我是否能够从模块文件夹中运行它?
目前,我仅在 my-module 中配置了它,并且从父文件夹
mvn -pl my-module groupId:artifactId:myGoal
中运行它,看起来我必须使用完全限定名称。我想这是因为家长对这个插件一无所知。
I'm working on the multi module project. I want to run my plugin after build for one of the modules. This mojo should be only run directly from CLI and can not be attached to the phase as on some environments we dont want to run this goal.
What is the best aproach to configure my plugin? Should it be configured within parent or should i configure it within module?
If I configure it within both parent and module will module configuration overwrite parent configuration?
If I configure it only within parent will I be able to run it from within module folder?
At the moment I have it configured only in my-module and i run it like this from parent folder
mvn -pl my-module groupId:artifactId:myGoal
It looks like i have to use fully qualified name. I guess this is because parent doesnt know anything about this plugin.
发布评论
评论(1)
如果您希望插件在每次构建时执行一次,请在 Mojo 上使用
@aggregator
注释。这向 Maven 发出信号,使其在 Maven 构建中仅执行一次 mojo,除非它显式绑定到生命周期阶段。 您可以在 Mojo API 规范页面了解更多信息。如果您愿意, 为了避免必须声明 mojo 的完全限定名称,您可以在 settings.xml。您还可以在 pom.xml 的
pluginManagement
部分中指定它。 xml,尽管我不确定这是否适合您的用例。If you want the plugin to be executed once per build, then use the
@aggregator
annotation on your Mojo. This signals to Maven to only execute the mojo once in the Maven build, unless it is explicitly bound to a lifecycle phase. You can find out more at the Mojo API Specification page.If you want to avoid having to declare the fully-qualified name of the mojo, you can configure the groupId in the
pluginGroups
section of the settings.xml. You may also be able to specify it in thepluginManagement
section of the pom.xml, though I'm not certain that this works for your use case.