-
Notifications
You must be signed in to change notification settings - Fork 39
/
updateSdkVersions.sh
executable file
·62 lines (56 loc) · 1.83 KB
/
updateSdkVersions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
# this script is meant to be used after a new SDK version is out
# to facilitate the update of all the places where we usually depend on the latest version
# provide the new sdk version you want the project to be updated to
if [[ -z "$SDK_VERSION" ]]; then
echo "Must provide SDK_VERSION in environment" 1>&2
exit 1
fi
updateJavaSamples() {
echo ">>> Updating pom versions to $SDK_VERSION"
PROJS=$(find $1 -type f -name "pom.xml")
for i in ${PROJS[@]}
do
echo "Updating pom for: $i"
# we only want to update the first occurrence of <version>, the one belonging the parent-pom
awk '/<version>[^<]*<\/version>/ && !subyet {sub("<version>[^<]*<\/version>", "<version>"ENVIRON["SDK_VERSION"]"</version>"); subyet=1} 1' $i > temp && mv temp $i
done
}
updateScalaSamples() {
echo ">>> Updating sbt plugins to $SDK_VERSION"
PROJS=$(find $1 -type f -name "*plugins.sbt")
for i in ${PROJS[@]}
do
echo "Updating plugins sbt for: $i"
sed -i.bak "s/System.getProperty(\"kalix-sdk.version\", \".*\"))/System.getProperty(\"kalix-sdk.version\", \"$SDK_VERSION\"))/" $i
rm $i.bak
done
}
updateMavenPlugin() {
echo ">>> Updating maven plugin to $SDK_VERSION"
(
cd maven-java &&
../.github/patch-maven-versions.sh
)
}
DEFAULT_SAMPLES="./samples"
option="${1}"
sample="${2:-$DEFAULT_SAMPLES}"
case ${option} in
java) updateJavaSamples $sample
;;
scala) updateScalaSamples $sample
;;
plugin) updateMavenPlugin
;;
all)
updateJavaSamples $sample
updateScalaSamples $sample
updateMavenPlugin
;;
*)
echo "`basename ${0}`:usage: java|scala|plugin|all [project-folder]"
echo "e.g.: `basename ${0}` java ./samples/java-protobuf-customer-registry-kafka-quickstart/"
exit 1 # Command to come out of the program with status 1
;;
esac