Maven release: next development version in batch mode

后端 未结 7 2405
一生所求
一生所求 2021-02-19 23:13

I have configured a Jenkins job to release my maven project automatically. This is done by using the following: mvn --batch-mode clean release:prepare release:perform

7条回答
  •  北恋
    北恋 (楼主)
    2021-02-19 23:43

    I know this is a kinda old post but I didn't find an answer I really liked anywhere online and I was able to come up with something that might work well for others...

    I wanted to increment the minorVersion as the OP states, and I was able to do so by using a combination of the build helper plugin (to parse the version) and the release plugin, in my project POM. Note the "initialize" phase referenced in the POM and the maven run property...

    Here's the excerpt from the POM, we use the build helper plugin to parse the version which we can reference in the release plugin...

    
                    org.codehaus.mojo
                    build-helper-maven-plugin
                    ${maven.build.helper.plugin.version}
                    
                        
                            parse-versions-for-release
                            initialize
                            
                                parse-version
                            
                            
                                parsedVersion
                            
                        
                    
                
                
                    org.apache.maven.plugins
                    maven-release-plugin
                    ${maven.release.plugin.version}
                    
                        true
                        @{project.artifactId}-@{project.version}
                        false
                        ${parsedVersion.majorVersion}.${parsedVersion.nextMinorVersion}.0-SNAPSHOT
                    
                
    

    Now we can just run a pretty normal release, but adding in the "initialize" phase to trigger the version parsing (and ensure it occurs prior to looking for the parsed versions)...

    mvn initialize release:clean release:prepare release:perform
    

提交回复
热议问题