16f06be9bSShawn O. Pearce#!/bin/sh 26f06be9bSShawn O. Pearce# Copyright (C) 2009, Google Inc. 36f06be9bSShawn O. Pearce# and other copyright owners as documented in the project's IP log. 46f06be9bSShawn O. Pearce# 56f06be9bSShawn O. Pearce# This program and the accompanying materials are made available 66f06be9bSShawn O. Pearce# under the terms of the Eclipse Distribution License v1.0 which 76f06be9bSShawn O. Pearce# accompanies this distribution, is reproduced below, and is 86f06be9bSShawn O. Pearce# available at http://www.eclipse.org/org/documents/edl-v10.php 96f06be9bSShawn O. Pearce# 106f06be9bSShawn O. Pearce# All rights reserved. 116f06be9bSShawn O. Pearce# 126f06be9bSShawn O. Pearce# Redistribution and use in source and binary forms, with or 136f06be9bSShawn O. Pearce# without modification, are permitted provided that the following 146f06be9bSShawn O. Pearce# conditions are met: 156f06be9bSShawn O. Pearce# 166f06be9bSShawn O. Pearce# - Redistributions of source code must retain the above copyright 176f06be9bSShawn O. Pearce# notice, this list of conditions and the following disclaimer. 186f06be9bSShawn O. Pearce# 196f06be9bSShawn O. Pearce# - Redistributions in binary form must reproduce the above 206f06be9bSShawn O. Pearce# copyright notice, this list of conditions and the following 216f06be9bSShawn O. Pearce# disclaimer in the documentation and/or other materials provided 226f06be9bSShawn O. Pearce# with the distribution. 236f06be9bSShawn O. Pearce# 246f06be9bSShawn O. Pearce# - Neither the name of the Eclipse Foundation, Inc. nor the 256f06be9bSShawn O. Pearce# names of its contributors may be used to endorse or promote 266f06be9bSShawn O. Pearce# products derived from this software without specific prior 276f06be9bSShawn O. Pearce# written permission. 286f06be9bSShawn O. Pearce# 296f06be9bSShawn O. Pearce# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 306f06be9bSShawn O. Pearce# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 316f06be9bSShawn O. Pearce# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 326f06be9bSShawn O. Pearce# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 336f06be9bSShawn O. Pearce# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 346f06be9bSShawn O. Pearce# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 356f06be9bSShawn O. Pearce# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 366f06be9bSShawn O. Pearce# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 376f06be9bSShawn O. Pearce# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 386f06be9bSShawn O. Pearce# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 396f06be9bSShawn O. Pearce# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 406f06be9bSShawn O. Pearce# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 416f06be9bSShawn O. Pearce# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 426f06be9bSShawn O. Pearce 436f06be9bSShawn O. Pearce 44fc5fc70eSShawn O. Pearce# Update all pom.xml with new build number 456f06be9bSShawn O. Pearce# 466f06be9bSShawn O. Pearce# TODO(spearce) This should be converted to some sort of 476f06be9bSShawn O. Pearce# Java based Maven plugin so its fully portable. 486f06be9bSShawn O. Pearce# 496f06be9bSShawn O. Pearce 506f06be9bSShawn O. Pearcecase "$1" in 516f06be9bSShawn O. Pearce--snapshot=*) 526f06be9bSShawn O. Pearce V=$(echo "$1" | perl -pe 's/^--snapshot=//') 536f06be9bSShawn O. Pearce if [ -z "$V" ] 546f06be9bSShawn O. Pearce then 556f06be9bSShawn O. Pearce echo >&2 "usage: $0 --snapshot=0.n.0" 566f06be9bSShawn O. Pearce exit 1 576f06be9bSShawn O. Pearce fi 586f06be9bSShawn O. Pearce case "$V" in 596f06be9bSShawn O. Pearce *-SNAPSHOT) : ;; 606f06be9bSShawn O. Pearce *) V=$V-SNAPSHOT ;; 616f06be9bSShawn O. Pearce esac 626f06be9bSShawn O. Pearce ;; 636f06be9bSShawn O. Pearce 646f06be9bSShawn O. Pearce--release) 656f06be9bSShawn O. Pearce V=$(git describe HEAD) || exit 666f06be9bSShawn O. Pearce ;; 676f06be9bSShawn O. Pearce 686f06be9bSShawn O. Pearce*) 696f06be9bSShawn O. Pearce echo >&2 "usage: $0 {--snapshot=0.n.0 | --release}" 706f06be9bSShawn O. Pearce exit 1 716f06be9bSShawn O. Pearceesac 726f06be9bSShawn O. Pearce 736f06be9bSShawn O. Pearcecase "$V" in 746f06be9bSShawn O. Pearcev*) V=$(echo "$V" | perl -pe s/^v//) ;; 756f06be9bSShawn O. Pearceesac 766f06be9bSShawn O. Pearce 776f06be9bSShawn O. Pearcecase "$V" in 786f06be9bSShawn O. Pearce*-SNAPSHOT) 796f06be9bSShawn O. Pearce POM_V=$V 80764f1635SShawn O. Pearce OSGI_V="${V%%-SNAPSHOT}.qualifier" 816f06be9bSShawn O. Pearce ;; 826f06be9bSShawn O. Pearce*-[1-9]*-g[0-9a-f]*) 836f06be9bSShawn O. Pearce POM_V=$(echo "$V" | perl -pe 's/-(\d+-g.*)$/.$1/') 84764f1635SShawn O. Pearce OSGI_V=$(perl -e ' 858d88a842SShawn O. Pearce die unless $ARGV[0] =~ /^(\d+)(?:\.(\d+)(?:\.(\d+))?(?:\.\d{12}-r)?)?-(\d+)-g(.*)$/; 86764f1635SShawn O. Pearce my ($a, $b, $c, $p, $r) = ($1, $2, $3, $4, $5); 87764f1635SShawn O. Pearce $b = '0' unless defined $b; 88764f1635SShawn O. Pearce $c = '0' unless defined $c; 89764f1635SShawn O. Pearce 90764f1635SShawn O. Pearce printf "%s.%s.%s.%6.6i_g%s\n", $a, $b, $c, $p, $r; 91764f1635SShawn O. Pearce ' "$V") 926f06be9bSShawn O. Pearce ;; 936f06be9bSShawn O. Pearce*) 946f06be9bSShawn O. Pearce POM_V=$V 95764f1635SShawn O. Pearce OSGI_V=$V 966f06be9bSShawn O. Pearce ;; 976f06be9bSShawn O. Pearceesac 986f06be9bSShawn O. Pearce 99764f1635SShawn O. PearceAPI_V=$(perl -e ' 100764f1635SShawn O. Pearce $ARGV[0] =~ /^(\d+(?:\.\d+(?:\.\d+)?)?)/; 101764f1635SShawn O. Pearce print $1 102764f1635SShawn O. Pearce ' "$V") 103764f1635SShawn O. Pearce 104764f1635SShawn O. PearceAPI_N=$(perl -e ' 105764f1635SShawn O. Pearce $ARGV[0] =~ /^(\d+)(?:\.(\d+)(?:\.(\d+))?)?/; 106764f1635SShawn O. Pearce my ($a, $b) = ($1, $2); 107764f1635SShawn O. Pearce $b = 0 unless defined $b; 108764f1635SShawn O. Pearce $b++; 109764f1635SShawn O. Pearce print "$a.$b.0"; 110764f1635SShawn O. Pearce ' "$API_V") 111764f1635SShawn O. Pearce 112200f3caeSShawn O. Pearceperl -pi~ -e ' 113764f1635SShawn O. Pearce s/^(Bundle-Version:\s*).*$/${1}'"$OSGI_V"'/; 114764f1635SShawn O. Pearce s/(org.eclipse.jgit.*;version=")[^"[(]*(")/${1}'"$API_V"'${2}/; 115764f1635SShawn O. Pearce s/(org.eclipse.jgit.*;version="\[)[^"]*(\)")/${1}'"$API_V,$API_N"'${2}/; 116*a51b4408SMatthias Sohn s/(Fragment-Host: org.eclipse.jgit.*;bundle-version="\[)[^"]*(\)")/${1}'"$API_V,$API_N"'${2}/; 117764f1635SShawn O. Pearce ' $(git ls-files | grep META-INF/MANIFEST.MF) 118764f1635SShawn O. Pearce 119200f3caeSShawn O. Pearceperl -pi~ -e ' 120e2a35242SMatthias Sohn s/^(Bundle-Version:\s*).*$/${1}'"$OSGI_V"'/; 121e2a35242SMatthias Sohn s/(org.eclipse.jgit.*;version=")[^"[(]*(")/${1}'"$API_V"'${2}/; 122e2a35242SMatthias Sohn s/(org.eclipse.jgit.*;version="\[)[^"]*(\)")/${1}'"$API_V,$API_N"'${2}/; 123792d27ecSMatthias Sohn s/^(Eclipse-SourceBundle:\s*org.eclipse.jgit.*;version=\").*(\";roots=\"\.\")$/${1}'"$OSGI_V"'${2}/; 124e2a35242SMatthias Sohn ' $(git ls-files | grep META-INF/SOURCE-MANIFEST.MF) 125e2a35242SMatthias Sohn 126e2a35242SMatthias Sohnperl -pi~ -e ' 127764f1635SShawn O. Pearce if ($ARGV ne $old_argv) { 128764f1635SShawn O. Pearce $seen_version = 0; 129764f1635SShawn O. Pearce $old_argv = $ARGV; 130764f1635SShawn O. Pearce } 131764f1635SShawn O. Pearce if (!$seen_version) { 132764f1635SShawn O. Pearce $seen_version = 1 if (!/<\?xml/ && 133764f1635SShawn O. Pearce s/(version=")[^"]*(")/${1}'"$OSGI_V"'${2}/); 134764f1635SShawn O. Pearce } 135eeab3757SThomas Wolf s/(import feature="org\.eclipse\.jgit[^"]*" version=")[^"]*(")/${1}'"$API_V"'${2}/; 136eeab3757SThomas Wolf s/(import plugin="org\.eclipse\.jgit[^"]*" version=")[^"]*(")/${1}'"$API_V"'${2}/; 1377804045cSShawn O. Pearce ' org.eclipse.jgit.packaging/org.*.feature/feature.xml 138764f1635SShawn O. Pearce 139200f3caeSShawn O. Pearceperl -pi~ -e ' 14079a2e28aSMatthias Sohn if ($ARGV ne $old_argv) { 14179a2e28aSMatthias Sohn $seen_version = 0; 14279a2e28aSMatthias Sohn $old_argv = $ARGV; 14379a2e28aSMatthias Sohn } 144eeab3757SThomas Wolf if ($seen_version < 2) { 145eeab3757SThomas Wolf $seen_version++ if 146764f1635SShawn O. Pearce s{<(version)>.*</\1>}{<${1}>'"$POM_V"'</${1}>}; 14779a2e28aSMatthias Sohn } 148eeab3757SThomas Wolf ' org.eclipse.jgit.packaging/org.*.source.feature/pom.xml 149e2a35242SMatthias Sohn 150e2a35242SMatthias Sohnperl -pi~ -e ' 151e2a35242SMatthias Sohn if ($ARGV ne $old_argv) { 152e2a35242SMatthias Sohn $seen_version = 0; 153e2a35242SMatthias Sohn $old_argv = $ARGV; 154e2a35242SMatthias Sohn } 15513f9aae4SMatthias Sohn if ($seen_version < 18) { 15613f9aae4SMatthias Sohn $seen_version++ if 15713f9aae4SMatthias Sohn s{<(version)>.*</\1>}{<${1}>'"$POM_V"'</${1}>}; 15813f9aae4SMatthias Sohn } 15913f9aae4SMatthias Sohn ' org.eclipse.jgit.coverage/pom.xml 16013f9aae4SMatthias Sohn 16113f9aae4SMatthias Sohnperl -pi~ -e ' 16213f9aae4SMatthias Sohn if ($ARGV ne $old_argv) { 16313f9aae4SMatthias Sohn $seen_version = 0; 16413f9aae4SMatthias Sohn $old_argv = $ARGV; 16513f9aae4SMatthias Sohn } 1666f06be9bSShawn O. Pearce if (!$seen_version) { 1676f06be9bSShawn O. Pearce $seen_version = 1 if 168fc5fc70eSShawn O. Pearce s{<(version)>.*</\1>}{<${1}>'"$POM_V"'</${1}>}; 1696f06be9bSShawn O. Pearce } 1706f06be9bSShawn O. Pearce ' $(git ls-files | grep pom.xml) 1716f06be9bSShawn O. Pearce 172200f3caeSShawn O. Pearcefind . -name '*~' | xargs rm -f 1736f06be9bSShawn O. Pearcegit diff 174