In Maven, how can I dynamically build a property value at runtime?

前端 未结 3 1040
盖世英雄少女心
盖世英雄少女心 2020-12-03 10:50

In maven it is very easy to set properties in a pom with the following syntax:

...

  4.06.17.6
          


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-03 11:19

    You can use maven build-helper plugin, in particular its regex-property mojo. Take a look at usage examples (scroll to Set a property by applying a regex replacement to a value section).

    Basically you want something like that in your pom to get myVersionTag property inferred from myValue:

    
      ...
      
        
          
            org.codehaus.mojo
            build-helper-maven-plugin
            1.7
            
              
                regex-property
                
                  regex-property
                
                
                  myVersionTag
                  $\{myValue}
                  (\d+)\.(\d+)\.(\d+)\.(\d+)
                  V_$1_$2_$3_P$4
                
              
            
          
        
      
      ...
    
    

提交回复
热议问题