1

I have a multi-project maven project. One child only has a specific plugin and I want it to be optional (so not bound to a specific phase). How can I run a full clean install on the entire project and additionally run a project's specific plugin?

I've encountered this post but it looks like an overkill, and it is not so easy in my specific case.

balsick
  • 1,099
  • 1
  • 10
  • 23
  • Can you explain what kind of specific plugin is needed in a child only? – khmarbaise Mar 04 '19 at 08:50
  • proguard-maven-plugin. I'm not interested in running it on any of the non-final projects nor in the root. – balsick Mar 04 '19 at 08:55
  • Than simply define the life cycle binding in that particular child...the version can be defined in parent via pluginManagement...? – khmarbaise Mar 04 '19 at 09:22
  • @khmarbaise sorry, I forgot to mention that I do not want the plugin to be bound to a specific phase. I want the hiding to be an optional task – balsick Mar 04 '19 at 09:51
  • 1
    Sounds like you just need to put plugin invocation into [profile](https://maven.apache.org/guides/introduction/introduction-to-profiles.html) – rkosegi Mar 04 '19 at 09:59
  • @rkosegi it sure is the best solution so far. If you want to post an answer, I'll accept it – balsick Mar 04 '19 at 10:39
  • 1
    @balsick added answer – rkosegi Mar 04 '19 at 12:19

1 Answers1

1

Your best option is to use maven build profiles.

In example, use this snippet in child module:

<profiles>
    <profile>
        <id>only-in-child-module</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <build>
            <plugins>
                ....
            </plugins>
        </build>
    </profile>
</profiles>

This build profile will not be active unless you explicitly ask maven for it like:

mvn clean install -Ponly-in-child-module

rkosegi
  • 14,165
  • 5
  • 50
  • 83