Maven - can't activate profiles in multi-module project

前端 未结 2 620
遇见更好的自我
遇见更好的自我 2020-12-30 12:59

I\'m experiencing some difficulties configuring our project with Maven and need some help :)

Say, I have a multi-module project, with modules A and B (there are ~20

相关标签:
2条回答
  • 2020-12-30 13:50

    One of the ways to handle this requirement is to define your plugins within <pluginManagement> section of your multi-module parent pom. In each of the project where you need to use this plugin, you declare it.

    This way, you get to define all the plugin details and configuration in a central place as well as have the flexibility to use it only for relevant modules. More details here.

    0 讨论(0)
  • 2020-12-30 14:05

    Defining a profile in a parent and then activating it from a child or from another profile is not supported by either Maven 2 or 3, currently. There are a couple of stackoverflow questions and answers [1] covering the details. There are related feature requests in Maven's issue tracker:

    • https://issues.apache.org/jira/browse/MNG-3309
    • https://issues.apache.org/jira/browse/MNG-4565
    • https://issues.apache.org/jira/browse/MNG-5127

    @Raghuram's suggestion to use <pluginManagement> is one way you can make this work without duplicating configuration. The other is to explicitly duplicate the config in each child module requiring it.

    [1]: Activate different Maven profiles depending on current module? ; Why can't I activate a Maven2 profile from another profile?

    0 讨论(0)
提交回复
热议问题