I have a project for which I have to create a new release from time to time. At the moment we have no facilities in place to increase the version numbers automatically (e.g. maven-release-plugin). Therefore I have to increase the version numbers manually (e.g. from 1.0.6 to 1.0.7).
- The project consists of many sub-projects and I don’t always have all the sub-projects opened in the IDE.
- I can use the GNU command line tools on all OS platforms. When you are a developer and you are using Windows I heavily suggest that you install Cygwin. Cygwin enables you to use all sorts of GNU command line tools under Windows.
- Sometimes I have projects where I don’t use an IDE at all.
At first I search for all occurences of the current version number to see where I will have to increase it:
$ egrep -Hir '1\.0\.6' | less
Then I run the following command to do the actual replacement:
$ find . -not \( -path ./.git -prune \) -type f \ -iregex ".*\.\(MF\|xml\|e4xmi\|java\|product\)" \ -print0 | xargs -0 sed -i 's/1\.0\.6/1.0.7/g'
- We don’t want
sed(the GNU Stream Editor which does the actual replacement) to mess around with the
.gitfolder under any cirumstances. Therefore we exclude it from the search results (
-not \( -path ./.git -prune \)). To read more about the different ways of how to exclude certain directories from a
findsearch see here. The method above should work under any circumstances.
- We don’t want
sedto search for version number strings in e.g. binary files (
egrepomits binary files by default). Therefore we only include files with certain file extensions in the search results (
To review the changes made by
sed I use the following command (see
here for an exaplanation and
$ git diff --color-words=.
This way you can easily spot the changed characters: