diff --git a/templates/android.js b/templates/android.js index 551d967d..2d64d08c 100644 --- a/templates/android.js +++ b/templates/android.js @@ -2,19 +2,22 @@ module.exports = platform => [{ name: () => `${platform}/build.gradle`, content: ({ packageIdentifier }) => `// ${platform}/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath("com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}") +buildscript { + // 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:3.4.1' + } } } @@ -44,14 +47,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url "$projectDir/../node_modules/react-native/android" + url "$rootDir/../node_modules/react-native/android" + } + maven { + // Android JSC is installed from npm + url "$rootDir/../node_modules/jsc-android/dist" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/integration/cli/create/view/__snapshots__/cli-create-with-view.test.js.snap b/tests/integration/cli/create/view/__snapshots__/cli-create-with-view.test.js.snap index 98f266c8..1a9bfaf5 100644 --- a/tests/integration/cli/create/view/__snapshots__/cli-create-with-view.test.js.snap +++ b/tests/integration/cli/create/view/__snapshots__/cli-create-with-view.test.js.snap @@ -126,19 +126,22 @@ sdk.dir=/Users/{username}/Library/Android/sdk "name": "react-native-integration-view-test-package/android/build.gradle", "theContent": "// android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -168,14 +171,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/integration/cli/create/with-defaults/__snapshots__/cli-create-with-defaults.test.js.snap b/tests/integration/cli/create/with-defaults/__snapshots__/cli-create-with-defaults.test.js.snap index d29b076a..1d98e5ab 100644 --- a/tests/integration/cli/create/with-defaults/__snapshots__/cli-create-with-defaults.test.js.snap +++ b/tests/integration/cli/create/with-defaults/__snapshots__/cli-create-with-defaults.test.js.snap @@ -126,19 +126,22 @@ sdk.dir=/Users/{username}/Library/Android/sdk "name": "react-native-integration-test-package/android/build.gradle", "theContent": "// android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -168,14 +171,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/view/with-defaults/__snapshots__/create-view-with-defaults.test.js.snap b/tests/with-injection/create/view/with-defaults/__snapshots__/create-view-with-defaults.test.js.snap index a518a1ae..d839fdee 100644 --- a/tests/with-injection/create/view/with-defaults/__snapshots__/create-view-with-defaults.test.js.snap +++ b/tests/with-injection/create/view/with-defaults/__snapshots__/create-view-with-defaults.test.js.snap @@ -201,19 +201,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -243,14 +246,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/view/with-example/with-defaults/__snapshots__/create-view-with-example-with-defaults.test.js.snap b/tests/with-injection/create/view/with-example/with-defaults/__snapshots__/create-view-with-example-with-defaults.test.js.snap index f890c40d..f5cdacf4 100644 --- a/tests/with-injection/create/view/with-example/with-defaults/__snapshots__/create-view-with-example-with-defaults.test.js.snap +++ b/tests/with-injection/create/view/with-example/with-defaults/__snapshots__/create-view-with-example-with-defaults.test.js.snap @@ -206,19 +206,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -248,14 +251,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/view/with-example/with-options/__snapshots__/create-view-with-example-with-options.test.js.snap b/tests/with-injection/create/view/with-example/with-options/__snapshots__/create-view-with-example-with-options.test.js.snap index 14f17c01..1b03ffda 100644 --- a/tests/with-injection/create/view/with-example/with-options/__snapshots__/create-view-with-example-with-options.test.js.snap +++ b/tests/with-injection/create/view/with-example/with-options/__snapshots__/create-view-with-example-with-options.test.js.snap @@ -206,19 +206,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -248,14 +251,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/view/with-options/for-android/__snapshots__/lib-view-android-config-options.test.js.snap b/tests/with-injection/create/view/with-options/for-android/__snapshots__/lib-view-android-config-options.test.js.snap index 22c71440..5fef4267 100644 --- a/tests/with-injection/create/view/with-options/for-android/__snapshots__/lib-view-android-config-options.test.js.snap +++ b/tests/with-injection/create/view/with-options/for-android/__snapshots__/lib-view-android-config-options.test.js.snap @@ -163,19 +163,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -205,14 +208,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/with-defaults/__snapshots__/create-with-defaults.test.js.snap b/tests/with-injection/create/with-defaults/__snapshots__/create-with-defaults.test.js.snap index aa05215b..4035e86e 100644 --- a/tests/with-injection/create/with-defaults/__snapshots__/create-with-defaults.test.js.snap +++ b/tests/with-injection/create/with-defaults/__snapshots__/create-with-defaults.test.js.snap @@ -201,19 +201,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -243,14 +246,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/with-example/with-defaults/__snapshots__/create-with-example-with-defaults.test.js.snap b/tests/with-injection/create/with-example/with-defaults/__snapshots__/create-with-example-with-defaults.test.js.snap index a2fb70fc..8e5d726e 100644 --- a/tests/with-injection/create/with-example/with-defaults/__snapshots__/create-with-example-with-defaults.test.js.snap +++ b/tests/with-injection/create/with-example/with-defaults/__snapshots__/create-with-example-with-defaults.test.js.snap @@ -206,19 +206,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -248,14 +251,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/with-example/with-missing-package-scripts/__snapshots__/recover-from-missing-package-scripts.test.js.snap b/tests/with-injection/create/with-example/with-missing-package-scripts/__snapshots__/recover-from-missing-package-scripts.test.js.snap index a34b7764..dcd6d2a1 100644 --- a/tests/with-injection/create/with-example/with-missing-package-scripts/__snapshots__/recover-from-missing-package-scripts.test.js.snap +++ b/tests/with-injection/create/with-example/with-missing-package-scripts/__snapshots__/recover-from-missing-package-scripts.test.js.snap @@ -206,19 +206,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -248,14 +251,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/with-example/with-null-options/with-null-prefix/__snapshots__/create-with-example-with-null-prefix.test.js.snap b/tests/with-injection/create/with-example/with-null-options/with-null-prefix/__snapshots__/create-with-example-with-null-prefix.test.js.snap index e2f4662a..e40d473e 100644 --- a/tests/with-injection/create/with-example/with-null-options/with-null-prefix/__snapshots__/create-with-example-with-null-prefix.test.js.snap +++ b/tests/with-injection/create/with-example/with-null-options/with-null-prefix/__snapshots__/create-with-example-with-null-prefix.test.js.snap @@ -206,19 +206,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -248,14 +251,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/with-example/with-options/__snapshots__/create-with-example-with-options.test.js.snap b/tests/with-injection/create/with-example/with-options/__snapshots__/create-with-example-with-options.test.js.snap index 51903c9f..0909fdd5 100644 --- a/tests/with-injection/create/with-example/with-options/__snapshots__/create-with-example-with-options.test.js.snap +++ b/tests/with-injection/create/with-example/with-options/__snapshots__/create-with-example-with-options.test.js.snap @@ -206,19 +206,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -248,14 +251,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/with-name-in-camel-case/__snapshots__/create-with-name-in-camel-case.test.js.snap b/tests/with-injection/create/with-name-in-camel-case/__snapshots__/create-with-name-in-camel-case.test.js.snap index 5f28437e..88b01ac9 100644 --- a/tests/with-injection/create/with-name-in-camel-case/__snapshots__/create-with-name-in-camel-case.test.js.snap +++ b/tests/with-injection/create/with-name-in-camel-case/__snapshots__/create-with-name-in-camel-case.test.js.snap @@ -201,19 +201,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -243,14 +246,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/with-options/for-android/__snapshots__/create-with-options-for-android.test.js.snap b/tests/with-injection/create/with-options/for-android/__snapshots__/create-with-options-for-android.test.js.snap index 0e1ddb7c..62cf4466 100644 --- a/tests/with-injection/create/with-options/for-android/__snapshots__/create-with-options-for-android.test.js.snap +++ b/tests/with-injection/create/with-options/for-android/__snapshots__/create-with-options-for-android.test.js.snap @@ -163,19 +163,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -205,14 +208,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/with-options/platforms-array/__snapshots__/platforms-array.test.js.snap b/tests/with-injection/create/with-options/platforms-array/__snapshots__/platforms-array.test.js.snap index 40125fed..cbef564a 100644 --- a/tests/with-injection/create/with-options/platforms-array/__snapshots__/platforms-array.test.js.snap +++ b/tests/with-injection/create/with-options/platforms-array/__snapshots__/platforms-array.test.js.snap @@ -201,19 +201,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -243,14 +246,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/with-options/platforms-comma-separated/__snapshots__/platforms-comma-separated.test.js.snap b/tests/with-injection/create/with-options/platforms-comma-separated/__snapshots__/platforms-comma-separated.test.js.snap index 0225d697..d07f71a8 100644 --- a/tests/with-injection/create/with-options/platforms-comma-separated/__snapshots__/platforms-comma-separated.test.js.snap +++ b/tests/with-injection/create/with-options/platforms-comma-separated/__snapshots__/platforms-comma-separated.test.js.snap @@ -201,19 +201,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -243,14 +246,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/with-options/with-custom-module-prefix/__snapshots__/create-with-custom-module-prefix.test.js.snap b/tests/with-injection/create/with-options/with-custom-module-prefix/__snapshots__/create-with-custom-module-prefix.test.js.snap index adf459b9..870faa8f 100644 --- a/tests/with-injection/create/with-options/with-custom-module-prefix/__snapshots__/create-with-custom-module-prefix.test.js.snap +++ b/tests/with-injection/create/with-options/with-custom-module-prefix/__snapshots__/create-with-custom-module-prefix.test.js.snap @@ -201,19 +201,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -243,14 +246,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-injection/create/with-options/with-module-name/__snapshots__/create-with-module-name.test.js.snap b/tests/with-injection/create/with-options/with-module-name/__snapshots__/create-with-module-name.test.js.snap index 9b128417..8a2d6a81 100644 --- a/tests/with-injection/create/with-options/with-module-name/__snapshots__/create-with-module-name.test.js.snap +++ b/tests/with-injection/create/with-options/with-module-name/__snapshots__/create-with-module-name.test.js.snap @@ -201,19 +201,22 @@ content: -------- // android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -243,14 +246,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-mocks/cli/command/func/with-options/__snapshots__/cli-command-func-with-options.test.js.snap b/tests/with-mocks/cli/command/func/with-options/__snapshots__/cli-command-func-with-options.test.js.snap index a77ace0a..ee32456b 100644 --- a/tests/with-mocks/cli/command/func/with-options/__snapshots__/cli-command-func-with-options.test.js.snap +++ b/tests/with-mocks/cli/command/func/with-options/__snapshots__/cli-command-func-with-options.test.js.snap @@ -205,19 +205,22 @@ buck-out/ "outputFileName": "react-native-alice-bobbi/android/build.gradle", "theContent": "// android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -247,14 +250,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-mocks/cli/program/with-defaults/for-android/__snapshots__/cli-program-with-defaults-for-android.test.js.snap b/tests/with-mocks/cli/program/with-defaults/for-android/__snapshots__/cli-program-with-defaults-for-android.test.js.snap index e1dc5eb8..7db15fae 100644 --- a/tests/with-mocks/cli/program/with-defaults/for-android/__snapshots__/cli-program-with-defaults-for-android.test.js.snap +++ b/tests/with-mocks/cli/program/with-defaults/for-android/__snapshots__/cli-program-with-defaults-for-android.test.js.snap @@ -328,19 +328,22 @@ buck-out/ "outputFileName": "react-native-test-package/android/build.gradle", "theContent": "// android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -370,14 +373,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-mocks/lib/create/with-example/with-logging/with-defaults/__snapshots__/create-with-example-with-defaults.test.js.snap b/tests/with-mocks/lib/create/with-example/with-logging/with-defaults/__snapshots__/create-with-example-with-defaults.test.js.snap index 15520160..c97010ee 100644 --- a/tests/with-mocks/lib/create/with-example/with-logging/with-defaults/__snapshots__/create-with-example-with-defaults.test.js.snap +++ b/tests/with-mocks/lib/create/with-example/with-logging/with-defaults/__snapshots__/create-with-example-with-defaults.test.js.snap @@ -270,19 +270,22 @@ buck-out/ "outputFileName": "react-native-alice-bobbi/android/build.gradle", "theContent": "// android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -312,14 +315,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-mocks/lib/create/with-example/with-logging/with-error/__snapshots__/with-yarn-error-logging.test.js.snap b/tests/with-mocks/lib/create/with-example/with-logging/with-error/__snapshots__/with-yarn-error-logging.test.js.snap index 4cc3e6e3..c888a1ff 100644 --- a/tests/with-mocks/lib/create/with-example/with-logging/with-error/__snapshots__/with-yarn-error-logging.test.js.snap +++ b/tests/with-mocks/lib/create/with-example/with-logging/with-error/__snapshots__/with-yarn-error-logging.test.js.snap @@ -270,19 +270,22 @@ buck-out/ "outputFileName": "react-native-alice-bobbi/android/build.gradle", "theContent": "// android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -312,14 +315,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-mocks/lib/create/with-example/with-logging/with-null-options/with-null-prefix/__snapshots__/create-with-example-with-options.test.js.snap b/tests/with-mocks/lib/create/with-example/with-logging/with-null-options/with-null-prefix/__snapshots__/create-with-example-with-options.test.js.snap index 937fe0e9..4ed308df 100644 --- a/tests/with-mocks/lib/create/with-example/with-logging/with-null-options/with-null-prefix/__snapshots__/create-with-example-with-options.test.js.snap +++ b/tests/with-mocks/lib/create/with-example/with-logging/with-null-options/with-null-prefix/__snapshots__/create-with-example-with-options.test.js.snap @@ -270,19 +270,22 @@ buck-out/ "outputFileName": "react-native-alice-bobbi/android/build.gradle", "theContent": "// android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -312,14 +315,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies { diff --git a/tests/with-mocks/lib/create/with-example/with-logging/with-options/__snapshots__/create-with-example-with-options.test.js.snap b/tests/with-mocks/lib/create/with-example/with-logging/with-options/__snapshots__/create-with-example-with-options.test.js.snap index b9381619..536ceb83 100644 --- a/tests/with-mocks/lib/create/with-example/with-logging/with-options/__snapshots__/create-with-example-with-options.test.js.snap +++ b/tests/with-mocks/lib/create/with-example/with-logging/with-options/__snapshots__/create-with-example-with-options.test.js.snap @@ -264,19 +264,22 @@ buck-out/ "outputFileName": "react-native-alice-bobbi/android/build.gradle", "theContent": "// android/build.gradle -buildscript { - ext.safeExtGet = {prop, fallback -> - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback - } - repositories { - google() - jcenter() - } +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} - dependencies { - // Matches recent template from React Native (0.60) - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16 - classpath(\\"com.android.tools.build:gradle:\${safeExtGet('gradlePluginVersion', '3.4.1')}\\") +buildscript { + // 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:3.4.1' + } } } @@ -306,14 +309,17 @@ android { } repositories { + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches recent template from React Native 0.59 / 0.60 - // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30 - // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L28 - url \\"$projectDir/../node_modules/react-native/android\\" + url \\"$rootDir/../node_modules/react-native/android\\" + } + maven { + // Android JSC is installed from npm + url \\"$rootDir/../node_modules/jsc-android/dist\\" } - mavenCentral() + google() + jcenter() } dependencies {