diff --git a/react-native-aztec/android/build.gradle b/react-native-aztec/android/build.gradle index f1f2eb3766..2aad9ee5cc 100644 --- a/react-native-aztec/android/build.gradle +++ b/react-native-aztec/android/build.gradle @@ -11,7 +11,6 @@ buildscript { jSoupVersion = '1.10.3' wordpressUtilsVersion = '1.22' espressoVersion = '3.0.1' - aztecVersion = 'v1.3.42' } @@ -31,10 +30,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'com.github.dcendents.android-maven' -// import the `readReactNativeVersion()` function -apply from: 'https://gist.githubusercontent.com/hypest/742448b9588b3a0aa580a5e80ae95bdf/raw/8eb62d40ee7a5104d2fcaeff21ce6f29bd93b054/readReactNativeVersion.gradle' - -group='com.github.wordpress-mobile.gutenberg-mobile' +group = 'com.github.wordpress-mobile.gutenberg-mobile' // fallback flag value for when lib is compiled individually (e.g. via jitpack) project.ext.buildGutenbergFromSource = false @@ -86,18 +82,18 @@ repositories { maven { url "https://jitpack.io" } if (!rootProject.ext.buildGutenbergFromSource) { - // if not building from source (where the node_modules dir is used), use a remote RN maven repo - def reactNativeRepo = 'https://dl.bintray.com/wordpress-mobile/react-native-mirror/' - println "Will use the RN maven repo at ${reactNativeRepo}" - maven { url reactNativeRepo } - } + // if not building from source (where the node_modules dir is used), use a remote RN maven repo + def reactNativeRepo = 'https://dl.bintray.com/wordpress-mobile/react-native-mirror/' + println "Will use the RN maven repo at ${reactNativeRepo}" + maven { url reactNativeRepo } + } } dependencies { - api ("com.github.wordpress-mobile.WordPress-Aztec-Android:aztec:$aztecVersion") - api ("com.github.wordpress-mobile.WordPress-Aztec-Android:wordpress-shortcodes:$aztecVersion") - api ("com.github.wordpress-mobile.WordPress-Aztec-Android:wordpress-comments:$aztecVersion") - api ("com.github.wordpress-mobile.WordPress-Aztec-Android:glide-loader:$aztecVersion") + api "com.github.wordpress-mobile.WordPress-Aztec-Android:aztec:$aztecVersion" + api "com.github.wordpress-mobile.WordPress-Aztec-Android:wordpress-shortcodes:$aztecVersion" + api "com.github.wordpress-mobile.WordPress-Aztec-Android:wordpress-comments:$aztecVersion" + api "com.github.wordpress-mobile.WordPress-Aztec-Android:glide-loader:$aztecVersion" api "org.wordpress:utils:$wordpressUtilsVersion" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" @@ -110,13 +106,18 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.0.0' - if (rootProject.ext.buildGutenbergFromSource) { - implementation "com.facebook.react:react-native:+" // From node_modules. - } else { + def reactNativeVersion = reactNativeVersion() + logger.quiet("Using react-native version: $reactNativeVersion") + implementation "com.facebook.react:react-native:$reactNativeVersion" +} - // FIXME Temporary fix to get Jitpack builds to green while I work on a solution without hardcoded values. - //def rnVersion = readReactNativeVersion('../package.json', 'peerDependencies') - def rnVersion = '0.61.5' - implementation "com.facebook.react:react-native:${rnVersion}" // From Maven repo +// Returns react-native version based on environment +def reactNativeVersion() { + if (rootProject.ext.buildGutenbergFromSource) { + return '+' } + + def packageFile = new File("$projectDir/../../package.json") + def packageContent = new groovy.json.JsonSlurper().parseText(packageFile.text) + return packageContent['dependencies']['react-native'] }