Setting default values for custom Maven 2 properties

前端 未结 6 1813
误落风尘
误落风尘 2020-12-01 03:05

I have a Maven pom.xml with a plugin that I want to be able to control on the command line. Everything works otherwise fine, except even after searching the net a while I ca

6条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 04:06

    @akostadinov's solution works great for common usage... But if the desired property shall be used by reactor component during dependency resolution phase (very early in mvn pom hierarchy processing...) you should use profile "none activation" test mechanism to ensure the optional command line provided value is always prioritized regarding the value provided inside pom.xml. And this whatever deep is your pom hierarchy.

    To do so, add this kind of profile in your parent pom.xml :

     
        
          my.property
          
            
              !my.property
            
          
          
            ${an.other.property} or a_static_value
          
        
      
    

提交回复
热议问题