Remove -SNAPSHOT from project version in pom

后端 未结 4 1526
梦如初夏
梦如初夏 2020-12-29 04:08

I have a pom with the following GAV

com.company.services
test-branch-2
1.0         


        
4条回答
  •  温柔的废话
    2020-12-29 05:04

    Add the following to your POM:

    
        
            
                org.codehaus.mojo
                build-helper-maven-plugin
                1.11
                
                    newVersion
                    ${project.version}
                    -SNAPSHOT
                    false
                
            
            
                org.codehaus.mojo
                versions-maven-plugin
                2.2
            
        
    
    

    You can now remove the -SNAPSHOT part of your project's version with:

    mvn build-helper:regex-property versions:set -N
    

    The -N tells Maven to only proces the root project in case you have modules defined in your POM. This is not strictly necessary but prevents the build-helper plugin from running unnecessarily against the submodules. The versions plugin runs only on the root project in any case, and traverses all modules automatically. Consider using the reactorModuleConvergence rule of the maven-enforcer plugin to make sure multi-module projects are handled correctly.

    You can run mvn versions:commit to remove the backup POM(s) generated by versions:set. Alternatively you can add false to the configuration of the versions plugin.

提交回复
热议问题