gradlew-fdroid handles duplicate keys in gradle-wrapper.properties different from java
Java uses the last key in the file:
import java.util.Properties
def properties = new Properties()
properties.load(new FileInputStream(new File("gradle-wrapper.properties")))
println properties.getProperty("distributionUrl")
$ cat gradle-wrapper.properties
distributionUrl=1
distributionUrl=2
distributionUrl=3
$ groovy test.groovy
3
So we should probably change
# Earliest takes priority
for f in {.,..}/gradle/wrapper/gradle-wrapper.properties; do
[[ -f $f ]] || continue
while IFS='' read -r line || [ -n "$line" ]; do
line=$(printf "$line" | tr -d '\r') # strip Windows linefeeds
if [[ $line == 'distributionUrl='* ]]; then
wrapper_ver=${line#*/gradle-}
wrapper_ver=${wrapper_ver%-*.zip}
break 2
fi
done < $f
done
to something like
# Last key (same as java.util.Properties) takes priority
for f in {.,..}/gradle/wrapper/gradle-wrapper.properties; do
[[ -f $f ]] || continue
while IFS='' read -r line || [ -n "$line" ]; do
line=$(printf "$line" | tr -d '\r') # strip Windows linefeeds
if [[ $line == 'distributionUrl='* ]]; then
wrapper_ver=${line#*/gradle-}
wrapper_ver=${wrapper_ver%-*.zip}
fi
done < $f
[[ -n $wrapper_ver ]] && break
done
NB: untested (I did test the snippet in isolation, seems to work).
Edited by FC (Fay) Stegerman