Skip to content

Commit

Permalink
Merge pull request #2248 from trackq/fixme-react-native-version
Browse files Browse the repository at this point in the history
Retrieve react native version from package.json
  • Loading branch information
mchowning authored May 22, 2020
2 parents 51389eb + f48f1cf commit d95255a
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions react-native-aztec/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ buildscript {
jSoupVersion = '1.10.3'
wordpressUtilsVersion = '1.22'
espressoVersion = '3.0.1'

aztecVersion = 'v1.3.42'
}

Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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']
}

0 comments on commit d95255a

Please sign in to comment.