#!/bin/sh

export IFS=","
maven_files=api/ch.netzschmiede.flarmradar.api.core/pom.xml,\
api/pom.xml,\
assembly/pom.xml,\
lib/ch.netzschmiede.flarmradar.lib.log/pom.xml,\
lib/ch.netzschmiede.flarmradar.lib.remote/pom.xml,\
lib/ch.netzschmiede.flarmradar.lib.upgrade/pom.xml,\
lib/pom.xml,\
pom.xml,\
srv/ch.netzschmiede.flarmradar.srv.core/pom.xml,\
srv/pom.xml,\
web/ch.netzschmiede.flarmradar.web.radar/pom.xml,\
web/ch.netzschmiede.flarmradar.web.rest/pom.xml,\
web/ch.netzschmiede.flarmradar.web.zkee/pom.xml,\
web/pom.xml,\
client/pom.xml,\
client/pkg/deb/flarmclient,\
server/pkg/deb/flarmradar

function usage {
  cat <<EOF
  
Usage:  
	$0 <from_version> <to_version>
	
Synopsis:
  Do trivial search/replace on a number of files. The versions
  must be provided in Maven-style, like 1.0.0-SNAPSHOT
  
Examples:
  $0 1.0.0-SNAPSHOT 1.1.0
  
EOF
}

if ( [ -z "$1" ] || [ -z "$2" ] ) ; then
	usage && exit 1
fi

from_version=$1
to_version=$2

for file in $maven_files; do
  [ ! -f $file ] && continue
  echo "shift version in $file"
  temp=`mktemp -t x`
  sed "s/$from_version/$to_version/g" $file > $temp && mv $temp $file
done


