Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cedricwalter/git-branch-renamer-maven-plugin
When working with many feature/release/bugix/hotfix branches, it is a bad idea to start changing the pom version as this will create merge conflicts using pull request. this plugin allow you to keep in ALL branches the same pom version for all your projects, for example MASTER-SNAPSHOT the version will be derived from branch name automatically when running in your continuous integration server.
https://github.com/cedricwalter/git-branch-renamer-maven-plugin
agile apache apache-maven bamboo conflicts continuous-delivery continuous-deployment continuous-integration java jenkins maven pull-requests teamcity
Last synced: about 1 month ago
JSON representation
When working with many feature/release/bugix/hotfix branches, it is a bad idea to start changing the pom version as this will create merge conflicts using pull request. this plugin allow you to keep in ALL branches the same pom version for all your projects, for example MASTER-SNAPSHOT the version will be derived from branch name automatically when running in your continuous integration server.
- Host: GitHub
- URL: https://github.com/cedricwalter/git-branch-renamer-maven-plugin
- Owner: cedricwalter
- License: gpl-3.0
- Created: 2017-05-18T11:20:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-01T21:07:50.000Z (over 7 years ago)
- Last Synced: 2024-09-29T16:40:09.221Z (about 2 months ago)
- Topics: agile, apache, apache-maven, bamboo, conflicts, continuous-delivery, continuous-deployment, continuous-integration, java, jenkins, maven, pull-requests, teamcity
- Language: Java
- Size: 34.2 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/cedricwalter/git-branch-renamer-maven-plugin.svg?branch=master)](https://travis-ci.org/cedricwalter/git-branch-renamer-maven-plugin)
# Introduction
When working with many feature/release/bugfix/hotfix branches, it is a bad idea to start changing the pom version as this
will create merge conflicts when using pull requestRead more here
* [Update Maven pom version on GIT checkout in TeamCity](https://www.waltercedric.com/index.php?option=com_content&view=article&id=2206:update-maven-pom-version-on-git-checkout-in-teamcity&catid=129&Itemid=332)
* [maven-release-plugin with GIT](https://waltercedric.com/index.php?option=com_content&view=article&id=2212:maven-release-plugin-with-git&catid=356&Itemid=333)This plugin allow you to keep in ALL branches the same pom version for all your projects:
for example ```MASTER-SNAPSHOT``` and never change it again.the project version will be derived from branch name automagically when running in your continuous integration server.
Example if your branch name is named ```feature/xxxx```
* ```xxxx-SNAPSHOT``` (default)
* ```xxxx``` (release = true)
* ```0-xxxx-SNAPSHOT``` (forceNumericalVersion = true) useful for Apache Felix bundles
* ```feature-xxxx-SNAPSHOT``` (filterOutBranchQualifier = false)# Bonus
* Add the ability to use Pull request with any branching workflow model
* Remove all non portable build step (bash/shell) in jenkins/teamcity/bamboo/...
* Centralized code in project object model (pom)# Resume
* This plugin derive Maven artifact version from GIT branch name,
* Update pom version automatically,
* Can set up a Systen variable
* Can write a file containing calculated version
* Support travis# Caveat
Maven 2.0, 2.1, 2.2 and 3.0 do not currently support re-reading modifications of the pom.xml within one
invocation of Maven.You need to run this code in an own maven step like ```mvn clean```, then your build in ```mvn deploy```.
This is because Maven has read and cache the reactor content with the old version name,
the plugin properly change version on disk but there is no easy way to reload all projects in code.
(Pull request welcomed if you find how)# Travis
Travis do not checkout the whole git, but only the branch. This plugin can detect Travis environment
and use the value provided from environment ${TRAVIS_BRANCH}# Quick Usage
Add to the root pom
```
com.cedricwalter
git-branch-renamer-maven-plugin
1.5.0
false
pom
pre-clean
false
true
false
false
false
false
versionFromGitBranch
true
version.txt
```
# Notes
* You may not want to run this plugin locally, ideally run it only in your CI server using a profile, running it locally will change pom version
```
rename-pom-version-like-branch
unix
com.cedricwalter
git-branch-renamer-maven-plugin
1.5.0
false
pom
post-clean
false
false
false
false
true
```* this plugin as default rename version to snapshot, you may want to create another CI build for versioning your project,
use a -DreleaseNow=true like in ${releaseNow}
```
rename-pom-version-like-branch
unix
false
com.cedricwalter
git-branch-renamer-maven-plugin
1.5.0
false
pom
post-clean
${releaseNow}
false
false
false
true
```
# A bit of history
In the last 5 years I was doing the same in a build step (shell script) in Jetbrain Teamcity (https://www.jetbrains.com/teamcity/)
or Atlassian Bamboo (https://www.atlassian.com/software/bamboo). This plugin is portable, stay in pom.The method below is still valid!
```echo 'Change the version in pom.xml files...'
branch=$(git rev-parse --abbrev-ref HEAD)echo "osgi bundle do not accept non numerical version number, so use numerical OSGI qualifier for branch uniqueness"
version="0-$branch-SNAPSHOT"echo "version is ${version}"
echo "filter out any eventual Branch prefixes"
# e.g. /bugfix /feature /release
version="$(echo $version | sed 's/bugfix\///g')"
version="$(echo $version | sed 's/feature\///g')"
version="$(echo $version | sed 's/hotfix\///g')"
version="$(echo $version | sed 's/0-release\///g')"/opt/maven/apache-maven-3.3.9/bin/mvn versions:set -DgenerateBackupPoms=false -DnewVersion="$version"
echo 'Changed version in pom.xml files to ${version}'
exit 0 ```