How to activate profile by means of maven property?

前端 未结 7 1322
Happy的楠姐
Happy的楠姐 2020-12-05 10:25

I\'m trying to activate a maven profile using a property defined inside pom.xml:


  [...]
  
             


        
7条回答
  •  半阙折子戏
    2020-12-05 10:58

    As mentioned in previous answers, profile activation only works with system properties.

    But, with a little creativity you can achieve a similar result (conditional plugin execution) using pom properties. To achieve that, use the phase tag of the plugin you want to conditionally execute:

    
    
        ...
    
        
            none
            
            
        
    
        ...
    
        
    
            ...
    
            
                
                your-plugin
                
                    
                        ${run.it}
                    
                
    
                
            
    
            ...
    
        
    
    
    

    The only difference is that you have to use a phase name instead of true/false. But you can change the property or override it freely as a property.

提交回复
热议问题