Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve react native version from package.json #2248

Merged
merged 7 commits into from
May 22, 2020
Merged
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
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']
}