Skip to content

Commit 5064b8f

Browse files
committed
Download gradle-wrapper.jar directly from Gradle's GitHub repository, rather than extracting it from a Gradle release
1 parent 4b2b9d7 commit 5064b8f

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

Android/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ The `android.py` script also requires the following commands to be on the `PATH`
3030
* `curl`
3131
* `java` (or set the `JAVA_HOME` environment variable)
3232
* `tar`
33-
* `unzip`
3433

3534

3635
## Building

Android/android.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -241,31 +241,27 @@ def setup_sdk():
241241

242242
# To avoid distributing compiled artifacts without corresponding source code,
243243
# the Gradle wrapper is not included in the CPython repository. Instead, we
244-
# extract it from the Gradle release.
244+
# extract it from the Gradle GitHub repository.
245245
def setup_testbed():
246-
if all((TESTBED_DIR / path).exists() for path in [
247-
"gradlew", "gradlew.bat", "gradle/wrapper/gradle-wrapper.jar",
248-
]):
246+
# The Gradle version used for the build is specified in
247+
# testbed/gradle/wrapper/gradle-wrapper.properties. This wrapper version
248+
# doesn't need to match, as any version of the wrapper can download any
249+
# version of Gradle.
250+
version = "8.9.0"
251+
paths = ["gradlew", "gradlew.bat", "gradle/wrapper/gradle-wrapper.jar"]
252+
253+
if all((TESTBED_DIR / path).exists() for path in paths):
249254
return
250255

251-
ver_long = "8.7.0"
252-
ver_short = ver_long.removesuffix(".0")
253-
254-
for filename in ["gradlew", "gradlew.bat"]:
255-
out_path = download(
256-
f"https://raw.githubusercontent.com/gradle/gradle/v{ver_long}/{filename}",
257-
TESTBED_DIR)
256+
for path in paths:
257+
out_path = TESTBED_DIR / path
258+
out_path.parent.mkdir(exist_ok=True)
259+
download(
260+
f"https://raw.githubusercontent.com/gradle/gradle/v{version}/{path}",
261+
out_path.parent,
262+
)
258263
os.chmod(out_path, 0o755)
259264

260-
with TemporaryDirectory(prefix=SCRIPT_NAME) as temp_dir:
261-
bin_zip = download(
262-
f"https://services.gradle.org/distributions/gradle-{ver_short}-bin.zip",
263-
temp_dir)
264-
outer_jar = f"gradle-{ver_short}/lib/plugins/gradle-wrapper-{ver_short}.jar"
265-
run(["unzip", "-d", temp_dir, bin_zip, outer_jar])
266-
run(["unzip", "-o", "-d", f"{TESTBED_DIR}/gradle/wrapper",
267-
f"{temp_dir}/{outer_jar}", "gradle-wrapper.jar"])
268-
269265

270266
# run_testbed will build the app automatically, but it's useful to have this as
271267
# a separate command to allow running the app outside of this script.

0 commit comments

Comments
 (0)