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

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

    Profiles are a good way to bring some order into POM. Especially if you use multiple executions of the same plugin for different purposes.

    Using files:

    
        alwaysActive
        
             .
        
        ...
    
    

    This will always be true (unless someone deletes the directory during Maven boot :). Tested with Maven 3.6.0.

    It might also be a good way to differentiate between types of projects. For instance, my project has always module.json present.

    Using a profile activating extension

    There are a few Maven extensions for profile activation. One of them in a fork here:
    https://github.com/OndraZizka/el-profile-activator-extension

提交回复
热议问题