From 702f999b050d50286d7a222587772bf4d2f7c557 Mon Sep 17 00:00:00 2001 From: Martin Konicek Date: Tue, 9 Feb 2016 06:36:30 -0800 Subject: [PATCH] Consume Android artifacts from npm Summary: This lets us say goodbye to Maven Central. This will greatly simplify and speed up the release process as releasing Android artifacts to Maven Central adds a lot of [complexity](https://github.com/facebook/react-native/blob/master/Releases-publish.md) and delays the whole release by several hours when we have to wait for the artifacts to propagate. This diff assumes there's a local Maven repo at `node_modules/react-native/android`. The second part once this lands is to change our `release.sh` script to output the artifacts under `react-native/android` before publishing to npm. This adds 3.7MB to the size of `node_modules` of any app. However, we just download eagerly what we'd normally download later via Gradle. **Test plan** Released RN including a local Maven repo into Sinopia: $ cd react-native # Updated version in gradle.properties to 0.21.0 $ ./gradlew ReactAndroid:installArchives # Moved everything in .m2/repository/com/facebook/react to react-native/android $ ls react-native/android com/facebook/react/react-native/0.21.0/react-native-0.21.0.aar com/facebook/react/react-native/0.21.0/react-native-0.21.0.pom com/facebook/react/react-native/maven-metadata.xml ... # Set version in package.json to 0.21.0 $ npm set registry http://localhost:4873/ $ npm publish Created and ran an app: $ cd /tmp $ react-native init AndroidNpm $ cd AndroidNpm $ react-native run-android It worked. Checked that we're using the artifacts from node_modules/react-native/android: $ cd android $ ./gradlew app:dependencies compile - Classpath for compiling the main sources. +--- com.android.support:appcompat-v7:23.0.1 | \--- com.android.support:support-v4:23.0.1 | \--- com.android.support:support-annotations:23.0.1 \--- com.facebook.react:react-native:+ -> 0.21.0 +--- com.google.code.findbugs:jsr305:3.0.0 +--- com.facebook.stetho:stetho-okhttp:1.2.0 ... Checked that Android Studio can find the source jars (you can navigate to RN sources in Android Studio). Opened the new project as described in the [docs](https://facebook.github.io/react-native/docs/android-setup.html#editing-your-app-s-java-code-in-android-studio). public Reviewed By: bestander Differential Revision: D2912557 fb-gh-sync-id: 251c180518a3fb9bb8e80963b236e982d65533be shipit-source-id: 251c180518a3fb9bb8e80963b236e982d65533be --- .../generator-android/templates/src/app/build.gradle | 9 ++++----- local-cli/generator-android/templates/src/build.gradle | 4 ++++ package.json | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/local-cli/generator-android/templates/src/app/build.gradle b/local-cli/generator-android/templates/src/app/build.gradle index ee7028cf4..428bb043d 100644 --- a/local-cli/generator-android/templates/src/app/build.gradle +++ b/local-cli/generator-android/templates/src/app/build.gradle @@ -62,8 +62,7 @@ import com.android.build.OutputFile apply from: "react.gradle" /** - * Set this to true to create three separate APKs instead of one: - * - A universal APK that works on all devices + * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. @@ -93,9 +92,9 @@ android { } splits { abi { - enable enableSeparateBuildPerCPUArchitecture - universalApk false reset() + enable enableSeparateBuildPerCPUArchitecture + universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86" } } @@ -123,5 +122,5 @@ android { dependencies { compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" - compile "com.facebook.react:react-native:0.13.0" + compile "com.facebook.react:react-native:+" // From node_modules } diff --git a/local-cli/generator-android/templates/src/build.gradle b/local-cli/generator-android/templates/src/build.gradle index ccdfc4e3d..403a00756 100644 --- a/local-cli/generator-android/templates/src/build.gradle +++ b/local-cli/generator-android/templates/src/build.gradle @@ -16,5 +16,9 @@ allprojects { repositories { mavenLocal() jcenter() + maven { + // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm + url "$projectDir/../../node_modules/react-native/android" + } } } diff --git a/package.json b/package.json index e7040699e..c77553f37 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "files": [ "React", "React.podspec", - "ReactAndroid", + "android", "Libraries", "packager", "cli.js",