Skip to content

Commit e5cc42e

Browse files
authored
fix(android): bump Gradle wrapper version for 0.76 (#2216)
1 parent 2a3154c commit e5cc42e

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

android/gradle-wrapper.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,26 @@ const {
1515
v,
1616
} = require("../scripts/helpers");
1717

18+
// Maximum value of a 32-bit integer (to ensure compatibility across language
19+
// boundaries)
20+
const INT_MAX = 2 ** 31 - 1;
21+
1822
/**
19-
* Keep this in sync with the Groovy version in `android/test-app-util.gradle`!
23+
* This table is also used by `android/test-app-util.gradle`!
2024
*
2125
* We have two implementations because there are currently two ways to build the
2226
* Android app. If built via `@react-native-community/cli`, this script will be
2327
* run and we can change Gradle version before it is executed. If it's built
2428
* with Gradle directly, it's already too late and the best we can do is to warn
2529
* the user.
2630
*
31+
* Gradle version can be found in the template:
32+
* https://github.com/react-native-community/template/blob/main/template/android/gradle/wrapper/gradle-wrapper.properties
33+
*
2734
* @type {[number, [number, string], [number, string]][]}
2835
*/
2936
const GRADLE_VERSIONS = [
30-
[v(0, 76, 0), [v(8, 9, 0), "8.9"], [Number.MAX_SAFE_INTEGER, ""]], // 0.76: [8.9, *)
37+
[v(0, 76, 0), [v(8, 10, 1), "8.10.1"], [INT_MAX, ""]], // 0.76: [8.10.1, *)
3138
[v(0, 75, 0), [v(8, 8, 0), "8.8"], [v(8, 9, 0), "8.8"]], // 0.75: [8.8, 8.9)
3239
[v(0, 74, 0), [v(8, 6, 0), "8.6"], [v(8, 9, 0), "8.8"]], // 0.74: [8.6, 8.9)
3340
[v(0, 73, 0), [v(8, 3, 0), "8.3"], [v(8, 9, 0), "8.8"]], // 0.73: [8.3, 8.9)
@@ -99,4 +106,5 @@ function configureGradleWrapper(sourceDir, fs = nodefs) {
99106
}
100107
}
101108

109+
exports.GRADLE_VERSIONS = GRADLE_VERSIONS;
102110
exports.configureGradleWrapper = configureGradleWrapper;

android/test-app-util.gradle

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ ext.autolinkingInfo = { buildDir ->
99
return new JsonSlurper().parseText(autolinking.text)
1010
}
1111

12-
ext.checkEnvironment = { rootDir ->
13-
// Keep this in sync with the JS version in `android/gradle-wrapper.js`
14-
//
12+
ext.checkEnvironment = { rootDir, testAppDir ->
13+
String[] args = ["node", "-p", "JSON.stringify(require('./android/gradle-wrapper.js').GRADLE_VERSIONS)"]
14+
def stdout = new StringBuffer()
15+
def stderr = new StringBuffer()
16+
def node = Runtime.runtime.exec(args, null, file(testAppDir))
17+
node.waitForProcessOutput(stdout, stderr)
18+
if (node.exitValue() != 0) {
19+
throw new RuntimeException("Failed to load 'android/gradle-wrapper.js':\n${stderr}")
20+
}
21+
1522
// We have two implementations because there are currently two ways to build
1623
// the Android app. If built via `@react-native-community/cli`, the JS
1724
// script will be run and we can change Gradle version before it is
1825
// executed. If it's built with Gradle directly, it's already too late and
1926
// the best we can do is to warn the user.
20-
def gradleVersions = [
21-
[v(0, 76, 0), [v(8, 9, 0), "8.9"], [Integer.MAX_VALUE, ""]], // 0.76: [8.9, *)
22-
[v(0, 75, 0), [v(8, 8, 0), "8.8"], [v(8, 9, 0), "8.8"]], // 0.75: [8.8, 8.9)
23-
[v(0, 74, 0), [v(8, 6, 0), "8.6"], [v(8, 9, 0), "8.8"]], // 0.74: [8.6, 8.9)
24-
[v(0, 73, 0), [v(8, 3, 0), "8.3"], [v(8, 9, 0), "8.8"]], // 0.73: [8.3, 8.9)
25-
[v(0, 72, 0), [v(8, 1, 1), "8.1.1"], [v(8, 3, 0), "8.2.1"]], // 0.72: [8.1.1, 8.3)
26-
[0, [v(7, 5, 1), "7.6.4"], [v(8, 0, 0), "7.6.4"]], // <0.72: [7.5.1, 8.0.0)
27-
]
27+
def gradleVersions = new JsonSlurper().parseText(stdout.toString())
2828

2929
def warnGradle = { gradleVersion, reactNativeVersion ->
3030
def message = [
@@ -37,8 +37,6 @@ ext.checkEnvironment = { rootDir ->
3737
logger.error(message, gradleVersion, reactNativeVersion, gradleVersion)
3838
}
3939

40-
// Gradle version can be found in the template:
41-
// https://github.com/facebook/react-native/blob/main/packages/react-native/template/android/gradle/wrapper/gradle-wrapper.properties
4240
def gradleVersion = toVersionNumber(gradle.gradleVersion)
4341

4442
def reactNativeVersionString = getPackageVersion("react-native", rootDir)

test-app.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ private static void applyConfigPlugins(String testAppDir, File rootDir) {
1515

1616
private static Object autolinkModules(File projectRoot, File output, String testAppDir) {
1717
String[] autolink = ["node", "${testAppDir}/android/autolink.mjs", projectRoot.toString(), output.toString()]
18-
def stdout = new StringBuffer()
18+
def stderr = new StringBuffer()
1919
def proc = Runtime.runtime.exec(autolink, null, projectRoot)
20-
proc.waitForProcessOutput(null, stdout)
20+
proc.waitForProcessOutput(null, stderr)
2121
if (proc.exitValue() != 0) {
22-
throw new RuntimeException("Failed to autolink:\n${stdout}")
22+
throw new RuntimeException("Failed to autolink:\n${stderr}")
2323
}
2424

2525
return new JsonSlurper().parseText(output.text)
@@ -58,7 +58,7 @@ private static boolean isMediaFile(File file) {
5858
def testAppDir = buildscript.sourceFile.getParent()
5959
apply(from: "${testAppDir}/android/test-app-util.gradle")
6060

61-
checkEnvironment(rootDir)
61+
checkEnvironment(rootDir, testAppDir)
6262

6363
def reactNativeDir = file(findNodeModulesPath("react-native", rootDir))
6464
def cliAndroidDir = findNodeModulesPath("@react-native-community/cli-platform-android", reactNativeDir)

test/android/gradle-wrapper.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe("configureGradleWrapper()", () => {
135135
process.argv.push("run-android");
136136

137137
const cases = [
138-
["8.8", "0.76.0", "gradle-8.9-bin.zip"],
138+
["8.9", "0.76.0", "gradle-8.10.1-bin.zip"],
139139
["8.9", "0.75.0", "gradle-8.8-bin.zip"],
140140
["8.7", "0.75.0", "gradle-8.8-bin.zip"],
141141
["8.9", "0.74.0", "gradle-8.8-bin.zip"],
@@ -190,7 +190,7 @@ describe("configureGradleWrapper()", () => {
190190
process.argv.push("run-android");
191191

192192
const cases = [
193-
["8.9", "0.76.0"],
193+
["8.10.1", "0.76.0"],
194194
["8.8", "0.75.0"],
195195
["8.8", "0.74.0"],
196196
["8.8", "0.73.0"],

0 commit comments

Comments
 (0)