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

前端 未结 6 1804
悲哀的现实
悲哀的现实 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:40

    One trick is to avoid activeByDefault, and instead activate the profile by the absence of a property, eg:

    
      
        firstProfile
        
          
            !skipFirstProfile
          
        
        ...
      
    
    

    You should then be able to deactivate the profile with -DskipFirstProfile or with -P !firstProfile, but otherwise the profile will be active.

    See: Maven: The Complete Reference, Profile Activation - Activation by the Absence of a Property

提交回复
热议问题