mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 14:32:28 +03:00
build: improve gradle experience
This expands the gradle wrapper shell script used by the buildserver for usage outside the buildserver environment. It also allows downloading whitelisted versions of gradle if they are not yet deployed to the buildserver by simply upsating the copy of fdroidserver (in contrast to having to reprovision the whole buildserver). We first move the buildserver/gradle shell script to the repo root as gradlew-fdroid, as it's an fdroid specific gradle wrapper. We also now sync it inside the build VM before each build. We then add a list of whitelisted gradle distributions taken from the makebuildserver script. The script additionally now reads two env vars which tell it where to expect installed versions of gradle and where it might store downloaded gradle .zip files. Both of those are configurable from config.py. As the first should normally just be a subdir of the second it's not exposed in the example config.py but only used by the buildserver config.py. Default config now uses this internal gradle wrapper but a path to a custom wrapper or specific gradle distribution can still be set from config.py. Closes fdroid/fdroidserver#98 Ref: fdroid/fdroidserver#370
This commit is contained in:
parent
68cb81f38d
commit
9889a98dea
9 changed files with 217 additions and 109 deletions
2
buildserver/Vagrantfile
vendored
2
buildserver/Vagrantfile
vendored
|
@ -75,7 +75,5 @@ Vagrant.configure("2") do |config|
|
|||
config.vm.provision "shell", path: "provision-pip",
|
||||
args: ["compare-locales"]
|
||||
config.vm.provision "shell", path: "provision-gradle"
|
||||
config.vm.provision "file", source: "gradle",
|
||||
destination: "/opt/gradle/bin/gradle"
|
||||
|
||||
end
|
||||
|
|
|
@ -12,3 +12,4 @@ ndk_paths = {
|
|||
java_paths = {
|
||||
'8': "/usr/lib/jvm/java-8-openjdk-amd64",
|
||||
}
|
||||
gradle_version_dir = "/opt/gradle/versions"
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
bindir="$(dirname $0)"
|
||||
basedir="$(dirname $bindir)"
|
||||
verdir="${basedir}/versions"
|
||||
args=("$@")
|
||||
|
||||
run_gradle() {
|
||||
"${verdir}/${v_found}/bin/gradle" "${args[@]}"
|
||||
exit $?
|
||||
}
|
||||
|
||||
contains() {
|
||||
local e
|
||||
for e in $2; do
|
||||
[[ $e == $1 ]] && return 0;
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# 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=(4.8.1 4.8 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)
|
||||
|
||||
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; do
|
||||
[[ -f $f ]] || continue
|
||||
while read l; do
|
||||
if [[ -z "$plugin_pver" && $l == *'com.android.tools.build:gradle:'* ]]; then
|
||||
plugin_pver=$(echo -n "$l" | sed "s/.*com.android.tools.build:gradle:\\([0-9\\.\\+]\\+\\).*/\\1/")
|
||||
elif [[ -z "$wrapper_ver" && $l == *'gradleVersion = '* ]]; then
|
||||
wrapper_ver=$(echo -n "$l" | sed "s/.*gradleVersion *=* *[\"']\\([0-9\\.]\\+\\)[\"'].*/\\1/")
|
||||
fi
|
||||
done < $f
|
||||
done
|
||||
|
||||
if [[ -n $wrapper_ver ]]; then
|
||||
v_found=$wrapper_ver
|
||||
echo "Found $v_found via gradleVersion"
|
||||
run_gradle
|
||||
fi
|
||||
|
||||
if [[ -n $plugin_pver ]]; then
|
||||
i=0
|
||||
match=false
|
||||
for k in ${d_plugin_k[@]}; do
|
||||
if [[ $plugin_pver == ${k}* ]]; then
|
||||
plugin_ver=${d_plugin_v[$i]}
|
||||
match=true
|
||||
break
|
||||
fi
|
||||
let i++
|
||||
done
|
||||
if $match; then
|
||||
v_found=$plugin_ver
|
||||
echo "Found $v_found via gradle plugin version $k"
|
||||
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
|
||||
fi
|
||||
|
||||
run_gradle
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
test -e /opt/gradle/versions || mkdir -p /opt/gradle/versions
|
||||
cd /opt/gradle/versions
|
||||
|
@ -15,6 +15,7 @@ done
|
|||
chmod -R a+rX /opt/gradle
|
||||
|
||||
test -e /opt/gradle/bin || mkdir -p /opt/gradle/bin
|
||||
touch /opt/gradle/bin/gradle
|
||||
chown vagrant.vagrant /opt/gradle/bin/gradle
|
||||
chmod 0755 /opt/gradle/bin/gradle
|
||||
ln -fs /home/vagrant/fdroidserver/gradlew-fdroid /opt/gradle/bin/gradle
|
||||
chown -h vagrant.vagrant /opt/gradle/bin/gradle
|
||||
chown vagrant.vagrant /opt/gradle/versions
|
||||
chmod 0755 /opt/gradle/versions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue