chiark / gitweb /
makebuildserver: add gradle 4.7
[fdroidserver.git] / buildserver / gradle
index 4dc977d52a416d30705aa1ac356b3bab95e07a41..b1bf9be6219c8ad3162fe2a4ded3d8dda470a8fd 100755 (executable)
@@ -5,9 +5,6 @@ basedir="$(dirname $bindir)"
 verdir="${basedir}/versions"
 args=("$@")
 
-v_all=($(cd "${verdir}" && ls | sort -rV))
-echo "Available gradle versions: ${v_all[@]}"
-
 run_gradle() {
        "${verdir}/${v_found}/bin/gradle" "${args[@]}"
        exit $?
@@ -21,24 +18,37 @@ contains() {
        return 1
 }
 
-# key-value pairs of what gradle version each gradle plugin version
-# should accept
-d_plugin_k=( 2.1  2.0 1.5 1.3 1.2   1.1   1.0 0.14 0.13 0.12 0.11 0.10  0.9  0.8 0.7 0.6 0.5 0.4 0.3 0.2)
-d_plugin_v=(2.12 2.12 2.4 2.4 2.3 2.2.1 2.2.1  2.1  2.1 1.12 1.12 1.12 1.11 1.10 1.9 1.8 1.6 1.6 1.4 1.4)
+# key-value pairs of what gradle version (value) each gradle plugin version
+# (key) should accept. plugin versions are actually prefixes and catch sub-
+# versions as well. Pairs are taken from:
+# https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle
+d_plugin_k=(3.1 3.0 2.3    2.2  2.1.3  2.1  2.0 1.5 1.3 1.2   1.1   1.0 0.14 0.13 0.12 0.11 0.10  0.9  0.8 0.7 0.6 0.5 0.4 0.3 0.2)
+d_plugin_v=(4.4 4.1 3.3 2.14.1 2.14.1 2.12 2.12 2.4 2.4 2.3 2.2.1 2.2.1  2.1  2.1 1.12 1.12 1.12 1.11 1.10 1.9 1.8 1.6 1.6 1.4 1.4)
 
 # All gradle versions we know about
-plugin_v=(2.13 2.12 2.11 2.10 2.9 2.8 2.7 2.6 2.5 2.4 2.3 2.2.1 2.1 1.12 1.11 1.10 1.9 1.8 1.7 1.6 1.4)
+plugin_v=(4.7 4.6 4.5.1 4.5 4.4.1 4.4 4.3.1 4.3 4.2.1 4.2 4.1 4.0.2 4.0.1 4.0 3.5.1 3.5 3.4.1 3.4 3.3 3.2.1 3.2 3.1 3.0 2.14.1 2.14 2.13 2.12 2.11 2.10 2.9 2.8 2.7 2.6 2.5 2.4 2.3 2.2.1 2.2 2.1 1.12 1.11 1.10 1.9 1.8 1.7 1.6 1.4)
 
-# Find the highest version available
-for v in ${plugin_v[*]}; do
-       if contains $v "${v_all[*]}"; then
-               v_def=$v
-               break
-       fi
+v_all=${plugin_v[@]}
+echo "Available gradle versions: ${v_all[@]}"
+
+# Earliest takes priority
+for f in {.,..}/gradle/wrapper/gradle-wrapper.properties; do
+       [[ -f $f ]] || continue
+       while read l; do
+               if [[ $l == 'distributionUrl='* ]]; then
+                       wrapper_ver=$(echo -n "$l" | sed "s/.*gradle-\\([0-9\\.\\+]\\+\\).*/\\1/")
+               fi
+       done < $f
 done
 
+if [[ -n $wrapper_ver ]]; then
+       v_found=$wrapper_ver
+       echo "Found $v_found via distributionUrl"
+       run_gradle
+fi
+
 # Earliest takes priority
-for f in build.gradle ../build.gradle; do
+for f in {.,..}/build.gradle; do
        [[ -f $f ]] || continue
        while read l; do
                if [[ -z "$plugin_pver" && $l == *'com.android.tools.build:gradle:'* ]]; then
@@ -72,6 +82,14 @@ if [[ -n $plugin_pver ]]; then
        fi
 fi
 
+# Find the highest version available
+for v in ${plugin_v[*]}; do
+       if contains $v "${v_all[*]}"; then
+               v_def=$v
+               break
+       fi
+done
+
 if [[ -z $v_found ]]; then
        echo "No suitable gradle version found - defaulting to $v_def"
        v_found=$v_def