开发者

How to deactivate maven profile in child module?

开发者 https://www.devze.com 2023-03-01 15:39 出处:网络
I have a profile defined in parent pom.xml and activated by property. In child module I need to de-activate it. How this can be done (it\'s Maven 3)?

I have a profile defined in parent pom.xml and activated by property. In child module I need to de-activate it. How this can be done (it's Maven 3)?

开发者_如何学JAVA

ps. As far as I know it can't be done legally (MNG-4565, MNG-5083), but what is a possible workaround?


It depends. Child poms should not deny parent pom behaviour (it's like LSP for build process). It may be a good idea to define profile in a parent pom, but activate it only in child poms where you really need it.

If you can't do it, you could activate profile in a parent pom by a property with exact value:

<profiles>
  <profile> 
    <activation>
      <property>
        <name>environment</name>
        <value>test</value>
      </property>
    </activation>
  </profile>
</profiles>

and then redefine property value in a child pom.

0

精彩评论

暂无评论...
验证码 换一张
取 消