Enable maven3 extension only on specified profile(s)

こ雲淡風輕ζ 提交于 2019-12-10 15:26:05

问题


I have an extension I use in my Maven 3 build that outputs build information for me. It's a bit verbose so I would like to run it only in some build profiles. But <extensions> are only allowed in the main <build> and not in the profiles.

So my question is two fold. First, is there already a way to limit the extension to run only in specific profile(s) with something I can do in the pom.xml? Second, if not, then how should I implement this?

My initial thought was to call mavenSession.getCurrentProject().getActiveProfiles() and compare that to the list of profiles I want to run the extension on. But then I need to somehow pass the profile information there.. I'd like to do that in the pom.xml rather than from the command line but I'm not sure where should this info be stored.


回答1:


One thing that should work is to use a property containing a comma-separated profile name list, ideally named in a way to make the connection obvious (i.e. «extension-artifactId».run-for-profiles). Then pass that either via -D, or put it in the <properties> section to define a project default.



来源:https://stackoverflow.com/questions/9081764/enable-maven3-extension-only-on-specified-profiles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!