|
| 1 | +#!/bin/sh |
| 2 | +# Copyright (C) 2009, Google Inc. |
| 3 | +# |
| 4 | +# All rights reserved. This program and the accompanying materials |
| 5 | +# are made available under the terms of the Eclipse Public License v1.0 |
| 6 | +# which accompanies this distribution, and is available at |
| 7 | +# http://www.eclipse.org/legal/epl-v10.html |
| 8 | + |
| 9 | +# Update all pom.xml with new build number |
| 10 | +# |
| 11 | +# TODO(spearce) This should be converted to some sort of |
| 12 | +# Java based Maven plugin so its fully portable. |
| 13 | +# |
| 14 | + |
| 15 | +V= |
| 16 | +J= |
| 17 | + |
| 18 | +while [ $# -gt 0 ] |
| 19 | +do |
| 20 | +case "$1" in |
| 21 | +--snapshot=*) |
| 22 | + V=$(echo "$1" | perl -pe 's/^--snapshot=//') |
| 23 | + if [ -z "$V" ] |
| 24 | + then |
| 25 | + echo >&2 "usage: $0 --snapshot=0.n.0" |
| 26 | + exit 1 |
| 27 | + fi |
| 28 | + case "$V" in |
| 29 | + *-SNAPSHOT) : ;; |
| 30 | + *) V=$V-SNAPSHOT ;; |
| 31 | + esac |
| 32 | + shift |
| 33 | + ;; |
| 34 | + |
| 35 | +--release) |
| 36 | + V=$(git describe HEAD) || exit |
| 37 | + shift |
| 38 | + ;; |
| 39 | + |
| 40 | +--jgit=*) |
| 41 | + J=${1##--jgit=} |
| 42 | + shift |
| 43 | + ;; |
| 44 | + |
| 45 | +*) |
| 46 | + echo >&2 "usage: $0 {--snapshot=0.n.0 | --release} [--jgit=0.n.0]" |
| 47 | + exit 1 |
| 48 | +esac |
| 49 | +done |
| 50 | + |
| 51 | +case "$V" in |
| 52 | +v*) V=$(echo "$V" | perl -pe s/^v//) ;; |
| 53 | +'') |
| 54 | + echo >&2 "usage: $0 {--snapshot=0.n.0 | --release}" |
| 55 | + exit 1 |
| 56 | +esac |
| 57 | + |
| 58 | +case "$V" in |
| 59 | +*-SNAPSHOT) |
| 60 | + POM_V=$V |
| 61 | + OSGI_V="${V%%-SNAPSHOT}.qualifier" |
| 62 | + ;; |
| 63 | +*-[1-9]*-g[0-9a-f]*) |
| 64 | + POM_V=$(echo "$V" | perl -pe 's/-(\d+-g.*)$/.$1/') |
| 65 | + OSGI_V=$(perl -e ' |
| 66 | + $ARGV[0] =~ /^(\d+)(?:\.(\d+)(?:\.(\d+))?)?-(\d+)-g(.*)$/; |
| 67 | + my ($a, $b, $c, $p, $r) = ($1, $2, $3, $4, $5); |
| 68 | + $b = '0' unless defined $b; |
| 69 | + $c = '0' unless defined $c; |
| 70 | +
|
| 71 | + printf "%s.%s.%s.%6.6i_g%s\n", $a, $b, $c, $p, $r; |
| 72 | + ' "$V") |
| 73 | + ;; |
| 74 | +*) |
| 75 | + POM_V=$V |
| 76 | + OSGI_V=$V |
| 77 | + ;; |
| 78 | +esac |
| 79 | + |
| 80 | +to_version() { |
| 81 | + perl -e ' |
| 82 | + $ARGV[0] =~ /^(\d+(?:\.\d+(?:\.\d+)?)?)/; |
| 83 | + print $1 |
| 84 | + ' "$1" |
| 85 | +} |
| 86 | + |
| 87 | +next_version() { |
| 88 | + perl -e ' |
| 89 | + $ARGV[0] =~ /^(\d+)(?:\.(\d+)(?:\.(\d+))?)?/; |
| 90 | + my ($a, $b) = ($1, $2); |
| 91 | + $b = 0 unless defined $b; |
| 92 | + $b++; |
| 93 | + print "$a.$b.0"; |
| 94 | + ' "$1" |
| 95 | +} |
| 96 | + |
| 97 | +EGIT_V=$(to_version "$V") |
| 98 | +EGIT_N=$(next_version "$EGIT_V") |
| 99 | + |
| 100 | +[ -z "$J" ] && J=$V |
| 101 | +JGIT_V=$(to_version "$J") |
| 102 | +JGIT_N=$(next_version "$JGIT_V") |
| 103 | + |
| 104 | +perl -pi -e ' |
| 105 | + s/^(Bundle-Version:\s*).*$/${1}'"$OSGI_V"'/; |
| 106 | + s/(org.eclipse.egit.*;version=")[^"[(]*(")/${1}'"$EGIT_V"'${2}/; |
| 107 | + s/(org.eclipse.egit.*;version="\[)[^"]*(\)")/${1}'"$EGIT_V,$EGIT_N"'${2}/; |
| 108 | + s/(org.eclipse.jgit.*;version="\[)[^"]*(\)")/${1}'"$JGIT_V,$JGIT_N"'${2}/; |
| 109 | + ' $(git ls-files | grep META-INF/MANIFEST.MF) |
| 110 | + |
| 111 | +perl -pi -e ' |
| 112 | + if ($ARGV ne $old_argv) { |
| 113 | + $seen_version = 0; |
| 114 | + $old_argv = $ARGV; |
| 115 | + } |
| 116 | + if (!$seen_version) { |
| 117 | + $seen_version = 1 if (!/<\?xml/ && |
| 118 | + s/(version=")[^"]*(")/${1}'"$OSGI_V"'${2}/); |
| 119 | + } |
| 120 | + s/(feature="org.eclipse.jgit" version=")[^"]*(")/${1}'"$JGIT_V"'${2}/; |
| 121 | + ' org.eclipse.egit-feature/feature.xml |
| 122 | + |
| 123 | +perl -pi -e ' |
| 124 | + s{<(version)>[^<\$]*</\1>}{<${1}>'"$POM_V"'</${1}>}; |
| 125 | + ' org.eclipse.egit-feature/pom.xml |
| 126 | + |
| 127 | +perl -pi -e ' |
| 128 | + if ($ARGV ne $old_argv) { |
| 129 | + $seen_version = 0; |
| 130 | + $old_argv = $ARGV; |
| 131 | + } |
| 132 | + if ($seen_version < 2) { |
| 133 | + $seen_version++ if |
| 134 | + s{<(version)>[^<\$]*</\1>}{<${1}>'"$POM_V"'</${1}>}; |
| 135 | + } |
| 136 | + ' org.eclipse.egit-updatesite/pom.xml |
| 137 | + |
| 138 | +perl -pi -e ' |
| 139 | + if ($ARGV ne $old_argv) { |
| 140 | + $seen_version = 0; |
| 141 | + $old_argv = $ARGV; |
| 142 | + } |
| 143 | + if (!$seen_version) { |
| 144 | + $seen_version = 1 if |
| 145 | + s{<(version)>[^<\$]*</\1>}{<${1}>'"$POM_V"'</${1}>}; |
| 146 | + } |
| 147 | + s{<(jgit-version)>[^<]*</\1>}{<${1}>'"$J"'</${1}>}; |
| 148 | + ' $(git ls-files | grep pom.xml) |
| 149 | + |
| 150 | +git diff |
0 commit comments