-
Notifications
You must be signed in to change notification settings - Fork 12
/
set-version.sh
executable file
·52 lines (42 loc) · 1.76 KB
/
set-version.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
#!/bin/bash
if [ $# -eq 1 ]
then
IFS=-
read version flavour <<< "$1"
echo "setting version=$version${flavour:+ with }$flavour"
sed -i -E \
-e "s%^( <version>)[^-]+-([^-]+).*(</version>)$%\1$version-\2${flavour:+-}$flavour\3%" \
pom.xml examples/scala/pom.xml
version=$(grep -m 1 version pom.xml | sed "s/\s*<[^>]*>\s*//g")
elif [ $# -eq 2 ]
then
spark=$1
scala=$2
if [[ "$spark" == "3.5."* ]] || [[ "$spark" > "3.5." ]]
then
graphframes="0.8.3-spark3.5"
elif [[ "$spark" == "3.4."* ]] || [[ "$scala" > "2.13." ]]
then
graphframes="0.8.3-spark3.4"
else
graphframes="0.8.1-spark3.0"
fi
spark_compat=${spark%.*}
scala_compat=${scala%.*}
scala_patch=${scala/*./}
spark_patch=${spark/*./}
echo "setting spark=$spark and scala=$scala and graphframes=$graphframes"
sed -i -E \
-e "s%^( <artifactId>)([^_]+)[_0-9.]+(</artifactId>)$%\1\2_${scala_compat}\3%" \
-e "s%^( <version>)([^-]+)-[^-]+(.*</version>)$%\1\2-$spark_compat\3%" \
-e "s%^( <scala.compat.version>).+(</scala.compat.version>)$%\1${scala_compat}\2%" \
-e "s%^( <scala.version>\\\$\{scala.compat.version\}.).+(</scala.version>)$%\1$scala_patch\2%" \
-e "s%^( <spark.compat.version>).+(</spark.compat.version>)$%\1${spark_compat}\2%" \
-e "s%^( <spark.version>\\\$\{spark.compat.version\}.).+(</spark.version>)$%\1$spark_patch\2%" \
-e "s%^( <graphframes.version>).+(</graphframes.version>)$%\1$graphframes\2%" \
pom.xml examples/scala/pom.xml
version=$(grep -m 1 version pom.xml | sed "s/\s*<[^>]*>\s*//g")
else
echo "Provide the Spark-Dgraph-Connector version (e.g. 2.5.0 or 2.5.0-SNAPSHOT), or the Spark and Scala version"
exit 1
fi