blob: 7252db6bf68d508d8f10af62e86dfbb5450ed959 [file] [log] [blame]
#!/bin/sh -e
# replace in all files the OLD_VERSION by the NEW_VERSION
# run and tested on linux.
# no need for windows support here although any community
# is always welcome to contibute such thing
#Make sure the current dir is the one of the script.
thisdir=`dirname $0`;
cd $thisdir
thisdir=`pwd`
if [ -z "$NEW_VERSION" ]; then
#use the first argument as the new version
if [ -n "$1" ]; then
NEW_VERSION=$1
else
echo "No NEW_VERSION defined."
exit 2
fi
fi
if [ -z "$OLD_VERSION" ]; then
#read it in the pom.xml
line=`sed '/<version>.*-SNAPSHOT<\/version>/!d' pom.xml | head -1`
OLD_VERSION=`echo $line | sed 's/ /\//g' | sed 's/^<version>//g' | sed 's/-SNAPSHOT<\/version>//g'`
fi
# reconstruct the version and buildNumber aka qualifier.
# make the assumption that the completeVersion matches a 4 seg numbers.
#if it does not then make the assumption that this buildNumber is just the forced context qualifier and use
#the pom.xml's version for the rest of the version.
var=$(echo $NEW_VERSION | awk -F"." '{print $1,$2,$3}')
set -- $var
if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
NEW_VERSION=$1.$2.$3
completeVersion="$NEW_VERSION.qualifier"
else
echo "Expecting a valid OSGi version: major.minor.update.qualifier; $NEW_VERSION is incorrect"
exit 2
fi
echo "$completeVersion"
if [ "$2" != "quiet" ]; then
echo "Change the version from $OLD_VERSION to $NEW_VERSION and set the forceContextQualifier to $buildNumber ? (default yes)"
read quiet
[ -n "$quiet" ] && exit 0
echo "Executing..."
else
echo "Changing the version from $OLD_VERSION to $NEW_VERSION and set the forceContextQualifier to $buildNumber."
fi
#update the numbers for the release
#sed -i "s/<forceContextQualifier>.*<\/forceContextQualifier>/<forceContextQualifier>$buildNumber<\/forceContextQualifier>/" pom.xml
#update the jetty-version too
#sed -i "s/<jetty-version>.*<\/jetty-version>/<jetty-version>$completeVersion<\/jetty-version>/" pom.xml
#replace in the pom.xml
find . -name pom.xml -type f -exec sed -i 's/'$OLD_VERSION'/'$NEW_VERSION'/g' {} \;
#replace in the other eclipse files where they end with a .qualifier
OLD_VERSION_QUALIFIER="$OLD_VERSION.qualifier"
NEW_VERSION_QUALIFIER="$NEW_VERSION.qualifier"
echo "$OLD_VERSION_QUALIFIER -> $NEW_VERSION_QUALIFIER"
find . -type f -name feature.xml -exec sed -i "s/$OLD_VERSION_QUALIFIER/$NEW_VERSION_QUALIFIER/g" {} \;
find . -type f -name categories.xml -exec sed -i "s/$OLD_VERSION_QUALIFIER/$NEW_VERSION_QUALIFIER/g" {} \;
find . -type f -name category.xml -exec sed -i "s/$OLD_VERSION_QUALIFIER/$NEW_VERSION_QUALIFIER/g" {} \;
find . -type f -name site.xml -exec sed -i "s/$OLD_VERSION_QUALIFIER/$NEW_VERSION_QUALIFIER/g" {} \;
find . -type f -name MANIFEST.MF -exec sed -i "s/$OLD_VERSION_QUALIFIER/$NEW_VERSION_QUALIFIER/g" {} \;
find . -type f -name *.product -exec sed -i "s/$OLD_VERSION_QUALIFIER/$NEW_VERSION_QUALIFIER/g" {} \;