Update org.apache.commons:commons-compress to 1.25.0
[egit/eclipse.git] / tools / version.sh
blob6c38c9646c3413bbff2ddecd4f976f80abd9321b
1 #!/bin/sh
2 # Copyright (C) 2009, Google Inc.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Eclipse Public License 2.0
6 # which accompanies this distribution, and is available at
7 # https://www.eclipse.org/legal/epl-2.0/
9 # SPDX-License-Identifier: EPL-2.0
11 # Update all pom.xml with new build number
13 # TODO(spearce) This should be converted to some sort of
14 # Java based Maven plugin so its fully portable.
20 while [ $# -gt 0 ]
22 case "$1" in
23 --snapshot=*)
24 V=$(echo "$1" | perl -pe 's/^--snapshot=//')
25 if [ -z "$V" ]
26 then
27 echo >&2 "usage: $0 --snapshot=0.n.0"
28 exit 1
30 case "$V" in
31 *-SNAPSHOT) : ;;
32 *) V=$V-SNAPSHOT ;;
33 esac
34 shift
37 --release)
38 V=$(git describe HEAD) || exit
39 shift
42 --jgit=*)
43 J=${1##--jgit=}
44 shift
48 echo >&2 "usage: $0 {--snapshot=0.n.0 | --release} [--jgit=0.n.0]"
49 exit 1
50 esac
51 done
53 case "$V" in
54 v*) V=$(echo "$V" | perl -pe s/^v//) ;;
55 '')
56 echo >&2 "usage: $0 {--snapshot=0.n.0 | --release}"
57 exit 1
58 esac
60 case "$V" in
61 *-SNAPSHOT)
62 POM_V=$V
63 OSGI_V="${V%%-SNAPSHOT}.qualifier"
65 *-[1-9]*-g[0-9a-f]*)
66 POM_V=$(echo "$V" | perl -pe 's/-(\d+-g.*)$/.$1/')
67 OSGI_V=$(perl -e '
68 $ARGV[0] =~ /^(\d+)(?:\.(\d+)(?:\.(\d+))?)?-(\d+)-g(.*)$/;
69 my ($a, $b, $c, $p, $r) = ($1, $2, $3, $4, $5);
70 $b = '0' unless defined $b;
71 $c = '0' unless defined $c;
73 printf "%s.%s.%s.%6.6i_g%s\n", $a, $b, $c, $p, $r;
74 ' "$V")
77 POM_V=$V
78 OSGI_V=$V
80 esac
82 to_version() {
83 perl -e '
84 $ARGV[0] =~ /^(\d+(?:\.\d+(?:\.\d+)?)?)/;
85 print $1
86 ' "$1"
89 next_version() {
90 perl -e '
91 $ARGV[0] =~ /^(\d+)(?:\.(\d+)(?:\.(\d+))?)?/;
92 my ($a, $b) = ($1, $2);
93 $b = 0 unless defined $b;
94 $b++;
95 print "$a.$b.0";
96 ' "$1"
99 EGIT_V=$(to_version "$V")
100 EGIT_N=$(next_version "$EGIT_V")
102 [ -z "$J" ] && J=$V
103 JGIT_V=$(to_version "$J")
104 JGIT_N=$(next_version "$JGIT_V")
106 perl -pi~ -e '
107 s/^(Bundle-Version:\s*).*$/${1}'"$OSGI_V"'/;
108 s/(org.eclipse.egit.*;version=")[^"[(]*(")/${1}'"$EGIT_V"'${2}/;
109 s/(org.eclipse.egit.*;version="\[)[^"]*(\)")/${1}'"$EGIT_V,$EGIT_N"'${2}/;
110 s/(org.eclipse.egit.*;bundle-version="\[)[^"]*(\)")/${1}'"$EGIT_V,$EGIT_N"'${2}/;
111 s/(org.eclipse.jgit.*;version="\[)[^"]*(\)")/${1}'"$JGIT_V,$JGIT_N"'${2}/;
112 s/(org.eclipse.jgit;bundle-version="\[)[^"]*(\)")/${1}'"$JGIT_V,$JGIT_N"'${2}/;
113 ' $(git ls-files | grep META-INF/MANIFEST.MF)
115 # Replace version numbers in feature.xml files. The first version is replaced by the full OSGi version.
116 # Versions in dependencies in the <requires> section for EGit/JGit features or plugins are set to the
117 # simple version numbers.
119 perl -pi~ -e '
120 if ($ARGV ne $old_argv) {
121 $seen_version = 0;
122 $old_argv = $ARGV;
124 if (!$seen_version) {
125 $seen_version = 1 if (!/<\?xml/ &&
126 s/(version=")[^"]*(")/${1}'"$OSGI_V"'${2}/);
128 s/(feature="org.eclipse.jgit[^"]*" version=")[^"]*(")/${1}'"$JGIT_V"'${2}/;
129 s/(plugin="org.eclipse.jgit[^"]*" version=")[^"]*(")/${1}'"$JGIT_V"'${2}/;
130 s/(feature="org.eclipse.egit[^"]*" version=")[^"]*(")/${1}'"$EGIT_V"'${2}/;
131 s/(plugin="org.eclipse.egit[^"]*" version=")[^"]*(")/${1}'"$EGIT_V"'${2}/;
132 ' $(git ls-files | grep feature.xml)
134 perl -pi~ -e '
135 s{<(version)>[^<\$]*</\1>}{<${1}>'"$POM_V"'</${1}>};
136 ' org.eclipse.egit-feature/pom.xml
138 perl -pi~ -e '
139 if ($ARGV ne $old_argv) {
140 $seen_version = 0;
141 $old_argv = $ARGV;
143 if (!$seen_version) {
144 $seen_version = 1 if
145 s{<(version)>[^<\$]*</\1>}{<${1}>'"$POM_V"'</${1}>};
147 s{<(egit-version)>[^<\$]*</\1>}{<${1}>'"$POM_V"'</${1}>};
148 ' pom.xml
150 perl -pi~ -e '
151 if ($ARGV ne $old_argv) {
152 $seen_version = 0;
153 $old_argv = $ARGV;
155 if ($seen_version < 2) {
156 $seen_version++ if
157 s{<(version)>[^<\$]*</\1>}{<${1}>'"$POM_V"'</${1}>};
159 ' org.eclipse.egit.repository/pom.xml
161 perl -pi~ -e '
162 if ($ARGV ne $old_argv) {
163 $seen_version = 0;
164 $seen_version2 = 0;
165 $old_argv = $ARGV;
167 if (!$seen_version) {
168 $seen_version = 1 if
169 s{<(version)>[^<\$]*</\1>}{<${1}>'"$POM_V"'</${1}>};
171 if ($seen_version2 < 2) {
172 $seen_version2++ if
173 s|(<version\>)([\.\d]*)(\</version\>)|${1}'$EGIT_V'${3}|;
175 ' org.eclipse.egit.ui.test/pom.xml
177 perl -pi~ -e '
178 if ($ARGV ne $old_argv) {
179 $seen_version = 0;
180 $old_argv = $ARGV;
182 if (!$seen_version) {
183 $seen_version = 1 if
184 s{<(version)>[^<\$]*</\1>}{<${1}>'"$POM_V"'</${1}>};
186 s{<(jgit-version)>[^<]*</\1>}{<${1}>'"$J"'</${1}>};
187 ' $(git ls-files | grep pom.xml)
189 find . -name '*~' | xargs rm -f
190 git diff