From be06e7d5299e9cdab53ecb7fc81588ab5c1a8f6e Mon Sep 17 00:00:00 2001 From: David Howell Date: Wed, 19 Apr 2017 13:58:42 +0930 Subject: [PATCH 1/2] Avoid the use of npm, instead read versions from dependencies.list --- react-native/android/build.gradle | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/react-native/android/build.gradle b/react-native/android/build.gradle index 597e7158..458015c9 100644 --- a/react-native/android/build.gradle +++ b/react-native/android/build.gradle @@ -32,9 +32,24 @@ import org.apache.tools.ant.filters.ReplaceTokens // We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk. // After that we build native code from src/main/jni with module path pointing at third-party-ndk. -ext.coreVersion = "npm --silent run get-core-version".execute().text.trim() -ext.syncVersion = "npm --silent run get-sync-version".execute().text.trim() -def currentVersion = "npm --silent run get-version".execute().text.trim() +def getDependenciesVersion(keyName) { + def inputFile = new File(buildscript.sourceFile.getParent() + "/../../dependencies.list") + def line + inputFile.withReader { reader -> + while ((line = reader.readLine())!=null) { + def (key, value) = line.tokenize('=') + if (keyName == key) { + return value + } + } + + throw new GradleException("${keyName} not found in dependencies.list.") + } +} + +ext.coreVersion = getDependenciesVersion("REALM_CORE_VERSION").trim() +ext.syncVersion = getDependenciesVersion("REALM_SYNC_VERSION").trim() +def currentVersion = getDependenciesVersion("VERSION").trim() def downloadsDir = new File("$projectDir/downloads") def jscDownloadDir = new File("$projectDir/src/main/jni/jsc") def coreDownloadDir = new File("$projectDir/src/main/jni") From 7702c3ec676bc0afc3c243b141f8905144560a44 Mon Sep 17 00:00:00 2001 From: David Howell Date: Wed, 19 Apr 2017 14:01:22 +0930 Subject: [PATCH 2/2] Move helper function out of the way --- react-native/android/build.gradle | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/react-native/android/build.gradle b/react-native/android/build.gradle index 458015c9..020d8241 100644 --- a/react-native/android/build.gradle +++ b/react-native/android/build.gradle @@ -32,21 +32,6 @@ import org.apache.tools.ant.filters.ReplaceTokens // We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk. // After that we build native code from src/main/jni with module path pointing at third-party-ndk. -def getDependenciesVersion(keyName) { - def inputFile = new File(buildscript.sourceFile.getParent() + "/../../dependencies.list") - def line - inputFile.withReader { reader -> - while ((line = reader.readLine())!=null) { - def (key, value) = line.tokenize('=') - if (keyName == key) { - return value - } - } - - throw new GradleException("${keyName} not found in dependencies.list.") - } -} - ext.coreVersion = getDependenciesVersion("REALM_CORE_VERSION").trim() ext.syncVersion = getDependenciesVersion("REALM_SYNC_VERSION").trim() def currentVersion = getDependenciesVersion("VERSION").trim() @@ -103,6 +88,21 @@ task prepareRealmCore(dependsOn: downloadRealmCore, type:Copy) { } } +def getDependenciesVersion(keyName) { + def inputFile = new File(buildscript.sourceFile.getParent() + "/../../dependencies.list") + def line + inputFile.withReader { reader -> + while ((line = reader.readLine())!=null) { + def (key, value) = line.tokenize('=') + if (keyName == key) { + return value + } + } + + throw new GradleException("${keyName} not found in dependencies.list.") + } +} + def getNdkBuildName() { if (Os.isFamily(Os.FAMILY_WINDOWS)) { return "ndk-build.cmd"