Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Load Android Gradle Plugin conditionally #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

buildscript {
ext.safeExtGet = {prop, fallback ->
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
repositories {
jcenter()
google()
}
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
if (project == rootProject) {
repositories {
google()
jcenter()
}

dependencies {
classpath("com.android.tools.build:gradle:${safeExtGet('gradlePluginVersion', '3.4.1')}")
dependencies {
//noinspection GradleDependency
classpath("com.android.tools.build:gradle:3.5.3")
}
}
}

Expand All @@ -33,6 +40,6 @@ android {
}

dependencies {
implementation "com.facebook.react:react-native:${safeExtGet("reactNative", "+")}"
implementation "com.facebook.react:react-native:+"
}