Question

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.

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top