Skip to content

Commit a233d8b

Browse files
authored
fix(android): contain use of JCenter to 0.64 and older (#658)
1 parent d884ce7 commit a233d8b

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

android/app/build.gradle

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ repositories {
2525
mavenCentral()
2626
google()
2727

28-
// TODO: Remove these when they've been published to Maven Central.
29-
// See https://github.com/microsoft/react-native-test-app/issues/305
30-
// noinspection JcenterRepositoryObsolete
31-
jcenter() {
32-
content {
33-
includeGroup("com.facebook.fbjni")
34-
includeGroup("com.facebook.flipper")
35-
includeGroup("com.facebook.fresco")
36-
includeGroup("com.facebook.yoga")
28+
// TODO: Remove this block when we drop support for 0.64.
29+
if (getReactNativeVersionNumber(rootDir) < 6500) {
30+
// Artifacts for 0.65+ are published to Maven Central. If we're on an
31+
// older version, we still need to use JCenter.
32+
// noinspection JcenterRepositoryObsolete
33+
jcenter() {
34+
content {
35+
includeGroup("com.facebook.fbjni")
36+
includeGroup("com.facebook.flipper")
37+
includeGroup("com.facebook.fresco")
38+
includeGroup("com.facebook.yoga")
39+
}
3740
}
3841
}
3942

android/test-app-util.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,11 @@ ext.getFlipperVersion = { baseDir ->
137137
// Use the recommended Flipper version
138138
return recommendedFlipperVersion
139139
}
140+
141+
ext.getReactNativeVersionNumber = { baseDir ->
142+
def reactNativePath = findNodeModulesPath(baseDir, "react-native")
143+
def packageJson = file("${reactNativePath}/package.json")
144+
def manifest = new JsonSlurper().parseText(packageJson.text)
145+
def (major, minor, patch) = manifest["version"].tokenize(".")
146+
return (major as int) * 10000 + (minor as int) * 100 + (patch as int)
147+
}

0 commit comments

Comments
 (0)