How to keep Maven profiles which are activeByDefault active even if another profile gets activated?

前端 未结 6 1864
悲哀的现实
悲哀的现实 2020-11-30 21:15

I have a profile in my pom.xml which should be always active unless it is explicitely deactivated (-P !firstProfile). I solved this by using the activeByDefault flag:

<
6条回答
  •  时光说笑
    2020-11-30 21:35

    I wish there was such a possibility, I have often missed it. The only relevant JIRA issue I could find is this one:

    MNG-4917: Profile not active even though it has activeByDefault set to true

    And it's been resolved as Not A Problem.

    I've stopped using activeByDefault, because this "all or nothing" approach made it worthless for me.


    The only way to change this behavior is to write your own replacement for DefaultProfileSelector, register it as a plexus component with @Component( role = ProfileSelector.class ) and put it in ${MAVEN_HOME}/lib/ext (that way it will be picked as default profile selector). (If you are using Maven 3.0.2 or older you will also have to edit ${MAVEN_HOME}/bin/m2.conf to load lib/ext before it loads lib)

提交回复
热议问题