Skip to content

Commit d884ce7

Browse files
authored
fix(android): stop using workaround for trove4j (#657)
`org.jetbrains.trove4j:trove4j` has been uploaded to Maven Central: https://search.maven.org/artifact/org.jetbrains.trove4j/trove4j/20160824/jar `force-resolve-trove4j.gradle` is now deprecated and will be removed in the next major release.
1 parent 592a229 commit d884ce7

File tree

9 files changed

+70
-85
lines changed

9 files changed

+70
-85
lines changed

android/app/build.gradle

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1+
buildscript {
2+
def androidDir = "${buildscript.sourceFile.getParent()}/../"
3+
apply(from: "$androidDir/test-app-util.gradle")
4+
apply(from: "$androidDir/dependencies.gradle")
5+
}
6+
7+
plugins {
8+
id("com.android.application")
9+
id("kotlin-android")
10+
id("kotlin-kapt")
11+
}
12+
113
// `react-native run-android` is hard-coded to look for the output APK at a very
214
// specific location. See
315
// https://github.com/react-native-community/cli/blob/6cf12b00c02aca6d4bc843446394331d71a9749e/packages/platform-android/src/commands/runAndroid/index.ts#L180
416
buildDir = "$rootDir/$name/build"
517

618
def reactNativeDir = findNodeModulesPath(rootDir, "react-native")
719

8-
buildscript {
9-
def androidDir = "${buildscript.sourceFile.getParent()}/../"
10-
apply from: "$androidDir/test-app-util.gradle"
11-
apply from: "$androidDir/dependencies.gradle"
12-
13-
repositories {
14-
google()
15-
mavenCentral()
16-
}
17-
}
18-
1920
repositories {
2021
maven {
21-
url("${reactNativeDir}/android")
22+
url = uri("${reactNativeDir}/android")
2223
}
2324

24-
google()
2525
mavenCentral()
26+
google()
2627

2728
// TODO: Remove these when they've been published to Maven Central.
2829
// See https://github.com/microsoft/react-native-test-app/issues/305
@@ -38,19 +39,11 @@ repositories {
3839

3940
// https://github.com/AzureAD/microsoft-authentication-library-for-android#step-1-declare-dependency-on-msal
4041
maven {
41-
url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1'
42+
url = uri("https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1")
4243
}
4344
}
4445

45-
apply from: "$projectDir/../force-resolve-trove4j.gradle"
46-
47-
apply plugin: "com.android.application"
48-
apply plugin: "kotlin-android"
49-
apply plugin: "kotlin-kapt"
50-
51-
def testAppDir = file("$projectDir/../../")
52-
53-
apply from: file("${testAppDir}/test-app.gradle")
46+
apply(from: "$projectDir/../../test-app.gradle")
5447
applyTestAppModule(project)
5548

5649
project.ext.react = [
@@ -91,7 +84,7 @@ android {
9184
def recommendedFlipperVersion = getFlipperRecommendedVersion(rootDir)
9285
buildConfigField "String",
9386
"ReactTestApp_recommendedFlipperVersion",
94-
recommendedFlipperVersion ? "\"${recommendedFlipperVersion}\"" : '"0"'
87+
recommendedFlipperVersion ? "\"${recommendedFlipperVersion}\"" : "\"0\""
9588

9689
resValue "string", "app_name", project.ext.react.appName
9790

@@ -107,7 +100,7 @@ android {
107100

108101
sourceSets {
109102
if (project.ext.react.enableFlipper) {
110-
debug.java.srcDirs += 'src/flipper/java'
103+
debug.java.srcDirs += "src/flipper/java"
111104
}
112105
}
113106
}
@@ -129,14 +122,15 @@ dependencies {
129122
}
130123

131124
if (buildReactNativeFromSource(rootDir)) {
132-
implementation project(':ReactAndroid')
125+
implementation project(":ReactAndroid")
133126
} else {
134127
implementation "com.facebook.react:react-native:+"
135128
}
136129

137130
implementation libraries.kotlinStdlibJdk7
138131
implementation libraries.kotlinStdlibJdk8
139132
implementation libraries.kotlinReflect
133+
140134
implementation libraries.androidAppCompat
141135
implementation libraries.androidCoreKotlinExtensions
142136
implementation libraries.androidRecyclerView
@@ -155,13 +149,13 @@ dependencies {
155149
if (project.ext.react.enableFlipper) {
156150
def flipperVersion = project.ext.react.enableFlipper
157151
debugImplementation("com.facebook.flipper:flipper:${flipperVersion}") {
158-
exclude group: 'com.facebook.fbjni'
152+
exclude(group: "com.facebook.fbjni")
159153
}
160154
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${flipperVersion}") {
161-
exclude group: 'com.facebook.flipper'
155+
exclude(group: "com.facebook.flipper")
162156
}
163157
debugImplementation("com.facebook.flipper:flipper-network-plugin:${flipperVersion}") {
164-
exclude group: 'com.facebook.flipper'
158+
exclude(group: "com.facebook.flipper")
165159
}
166160
}
167161
}

android/build.gradle

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
buildscript { scriptHandler ->
2-
def buildscriptDir = buildscript.sourceFile.getParent()
3-
apply from: "$buildscriptDir/dependencies.gradle"
4-
apply from: "$buildscriptDir/force-resolve-trove4j.gradle", to: scriptHandler
1+
plugins {
2+
apply(from: "${buildscript.sourceFile.getParent()}/dependencies.gradle")
53

6-
repositories {
7-
google()
8-
mavenCentral()
9-
}
10-
11-
dependencies {
12-
classpath "com.android.tools.build:gradle:$androidPluginVersion"
13-
}
4+
id("com.android.application") version "${androidPluginVersion}" apply false
5+
id("com.android.library") version "${androidPluginVersion}" apply false
6+
id("kotlin-android") version "${kotlinVersion}" apply false
7+
id("kotlin-kapt") version "${kotlinVersion}" apply false
148
}

android/settings.gradle

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
rootProject.name='react-test-app'
2-
include ':app', ':support'
1+
pluginManagement {
2+
repositories {
3+
gradlePluginPortal()
4+
mavenCentral()
5+
google()
6+
}
7+
}
8+
9+
rootProject.name = "react-test-app"
10+
include ":app", ":support"

android/support/build.gradle

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
buildscript {
2-
def androidDir = "${buildscript.sourceFile.getParent()}/../"
3-
apply from: "$androidDir/dependencies.gradle"
1+
plugins {
2+
id("com.android.library")
43
}
54

65
repositories {
7-
google()
86
mavenCentral()
7+
google()
98
}
109

11-
def androidDir = "${buildscript.sourceFile.getParent()}/../"
12-
apply from: "$androidDir/force-resolve-trove4j.gradle"
13-
14-
apply plugin: "com.android.library"
15-
1610
android {
11+
def androidDir = "${buildscript.sourceFile.getParent()}/../"
12+
apply(from: "$androidDir/dependencies.gradle")
13+
1714
compileSdkVersion project.ext.compileSdkVersion
1815
buildToolsVersion project.ext.buildToolsVersion
1916

example/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
buildscript { scriptHandler ->
1+
buildscript {
22
def androidTestAppDir = "../node_modules/react-native-test-app/android"
3-
apply from: "$androidTestAppDir/dependencies.gradle"
3+
apply(from: "${androidTestAppDir}/dependencies.gradle")
44

55
repositories {
6-
google()
76
mavenCentral()
7+
google()
88
}
99

1010
dependencies {

example/android/settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pluginManagement {
66
}
77
}
88

9-
rootProject.name='example'
9+
rootProject.name = "example"
1010

11-
apply from: file("../node_modules/react-native-test-app/test-app.gradle")
11+
apply(from: "../node_modules/react-native-test-app/test-app.gradle")
1212
applyTestAppSettings(settings)

scripts/configure.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,13 @@ const getConfig = (() => {
408408
android: {
409409
files: {
410410
"build.gradle": join(
411-
"buildscript { scriptHandler ->",
411+
"buildscript {",
412412
` def androidTestAppDir = "${testAppRelPath}/android"`,
413-
' apply from: "$androidTestAppDir/dependencies.gradle"',
414-
' apply from: "$androidTestAppDir/force-resolve-trove4j.gradle", to: scriptHandler',
413+
' apply(from: "${androidTestAppDir}/dependencies.gradle")',
415414
"",
416415
" repositories {",
417-
" google()",
418416
" mavenCentral()",
417+
" google()",
419418
" }",
420419
"",
421420
" dependencies {",
@@ -473,9 +472,9 @@ const getConfig = (() => {
473472
" }",
474473
"}",
475474
"",
476-
`rootProject.name='${name}'`,
475+
`rootProject.name = "${name}"`,
477476
"",
478-
`apply from: file("${testAppRelPath}/test-app.gradle")`,
477+
`apply(from: "${testAppRelPath}/test-app.gradle")`,
479478
"applyTestAppSettings(settings)",
480479
""
481480
),

test-app.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ def cliAndroidDir = findNodeModulesPath(rootDir, "@react-native-community/cli-pl
3838
apply from: "$cliAndroidDir/native_modules.gradle"
3939

4040
ext.applyTestAppSettings = { DefaultSettings defaultSettings ->
41-
buildscript { scriptHandler ->
42-
apply from: "$scriptDir/android/force-resolve-trove4j.gradle", to: scriptHandler
43-
}
44-
4541
applySettings(defaultSettings)
4642
applyNativeModulesSettingsGradle(defaultSettings)
4743
}

test/configure/__snapshots__/gatherConfig.test.js.snap

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,13 @@ Object {
6565
".watchmanconfig": Object {
6666
"source": "node_modules/react-native/template/_watchmanconfig",
6767
},
68-
"android/build.gradle": "buildscript { scriptHandler ->
68+
"android/build.gradle": "buildscript {
6969
def androidTestAppDir = \\"../../android\\"
70-
apply from: \\"$androidTestAppDir/dependencies.gradle\\"
71-
apply from: \\"$androidTestAppDir/force-resolve-trove4j.gradle\\", to: scriptHandler
70+
apply(from: \\"\${androidTestAppDir}/dependencies.gradle\\")
7271
7372
repositories {
74-
google()
7573
mavenCentral()
74+
google()
7675
}
7776
7877
dependencies {
@@ -104,9 +103,9 @@ Object {
104103
}
105104
}
106105
107-
rootProject.name='Test'
106+
rootProject.name = \\"Test\\"
108107
109-
apply from: file(\\"../../test-app.gradle\\")
108+
apply(from: \\"../../test-app.gradle\\")
110109
applyTestAppSettings(settings)
111110
",
112111
"babel.config.js": Object {
@@ -476,14 +475,13 @@ Object {
476475
".watchmanconfig": Object {
477476
"source": "node_modules/react-native/template/_watchmanconfig",
478477
},
479-
"android/build.gradle": "buildscript { scriptHandler ->
478+
"android/build.gradle": "buildscript {
480479
def androidTestAppDir = \\"../../android\\"
481-
apply from: \\"$androidTestAppDir/dependencies.gradle\\"
482-
apply from: \\"$androidTestAppDir/force-resolve-trove4j.gradle\\", to: scriptHandler
480+
apply(from: \\"\${androidTestAppDir}/dependencies.gradle\\")
483481
484482
repositories {
485-
google()
486483
mavenCentral()
484+
google()
487485
}
488486
489487
dependencies {
@@ -515,9 +513,9 @@ Object {
515513
}
516514
}
517515
518-
rootProject.name='Test'
516+
rootProject.name = \\"Test\\"
519517
520-
apply from: file(\\"../../test-app.gradle\\")
518+
apply(from: \\"../../test-app.gradle\\")
521519
applyTestAppSettings(settings)
522520
",
523521
"babel.config.js": Object {
@@ -643,14 +641,13 @@ Object {
643641
".watchmanconfig": Object {
644642
"source": "node_modules/react-native/template/_watchmanconfig",
645643
},
646-
"android/build.gradle": "buildscript { scriptHandler ->
644+
"android/build.gradle": "buildscript {
647645
def androidTestAppDir = \\"../../android\\"
648-
apply from: \\"$androidTestAppDir/dependencies.gradle\\"
649-
apply from: \\"$androidTestAppDir/force-resolve-trove4j.gradle\\", to: scriptHandler
646+
apply(from: \\"\${androidTestAppDir}/dependencies.gradle\\")
650647
651648
repositories {
652-
google()
653649
mavenCentral()
650+
google()
654651
}
655652
656653
dependencies {
@@ -682,9 +679,9 @@ Object {
682679
}
683680
}
684681
685-
rootProject.name='Test'
682+
rootProject.name = \\"Test\\"
686683
687-
apply from: file(\\"../../test-app.gradle\\")
684+
apply(from: \\"../../test-app.gradle\\")
688685
applyTestAppSettings(settings)
689686
",
690687
"babel.config.js": Object {

0 commit comments

Comments
 (0)