cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [02/11] android commit: CB-8026 Remove default target value from gradle file
Date Tue, 20 Jan 2015 19:54:36 GMT
CB-8026 Remove default target value from gradle file

Wasn't being used anyways, and it still referenced android-19
This also switches to using a Properties object rather than a RegEx
for parsing project.properties


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/a3457d94
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/a3457d94
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/a3457d94

Branch: refs/heads/master
Commit: a3457d940851cfdee019fd2a159877076b1be7d0
Parents: b69fed1
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Tue Jan 20 11:33:55 2015 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Jan 20 11:33:55 2015 -0500

----------------------------------------------------------------------
 bin/templates/project/build.gradle | 15 ++++-----------
 framework/cordova.gradle           | 34 ++++++++++++++++++---------------
 2 files changed, 23 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a3457d94/bin/templates/project/build.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle
index 911ffb6..ed4fd12 100644
--- a/bin/templates/project/build.gradle
+++ b/bin/templates/project/build.gradle
@@ -60,11 +60,11 @@ ext {
     apply from: 'CordovaLib/cordova.gradle'
     // The value for android.compileSdkVersion.
     if (!project.hasProperty('cdvCompileSdkVersion')) {
-        cdvCompileSdkVersion = privateHelpers.getProjectTarget('android-19')
+        cdvCompileSdkVersion = privateHelpers.getProjectTarget()
     }
     // The value for android.buildToolsVersion.
     if (!project.hasProperty('cdvBuildToolsVersion')) {
-        cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools('19.1.0')
+        cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
     }
     // Sets the versionCode to the given value.
     if (!project.hasProperty('cdvVersionCode')) {
@@ -249,27 +249,20 @@ gradle.taskGraph.whenReady { taskGraph ->
     }
 }
 
-def ensureValueExists(filePath, props, key) {
-    if (props.get(key) == null) {
-        throw new GradleException(filePath + ': Missing key required "' + key + '"')
-    }
-    return props.get(key)
-}
-
 def addSigningProps(propsFilePath, signingConfig) {
     def propsFile = file(propsFilePath)
     def props = new Properties()
     propsFile.withReader { reader ->
         props.load(reader)
     }
-    def storeFile = new File(ensureValueExists(propsFilePath, props, 'storeFile'))
+    def storeFile = new File(privateHelpers.ensureValueExists(propsFilePath, props, 'storeFile'))
     if (!storeFile.isAbsolute()) {
         storeFile = RelativePath.parse(true, storeFile.toString()).getFile(propsFile.getParentFile())
     }
     if (!storeFile.exists()) {
         throw new FileNotFoundException('Keystore file does not exist: ' + storeFile.getAbsolutePath())
     }
-    signingConfig.keyAlias = ensureValueExists(propsFilePath, props, 'keyAlias')
+    signingConfig.keyAlias = privateHelpers.ensureValueExists(propsFilePath, props, 'keyAlias')
     signingConfig.keyPassword = props.get('keyPassword', signingConfig.keyPassword)
     signingConfig.storeFile = storeFile
     signingConfig.storePassword = props.get('storePassword', signingConfig.storePassword)

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a3457d94/framework/cordova.gradle
----------------------------------------------------------------------
diff --git a/framework/cordova.gradle b/framework/cordova.gradle
index 8b371bf..5ce93f8 100644
--- a/framework/cordova.gradle
+++ b/framework/cordova.gradle
@@ -20,16 +20,19 @@
 import java.util.regex.Pattern
 import groovy.swing.SwingBuilder
 
+String doEnsureValueExists(filePath, props, key) {
+    if (props.get(key) == null) {
+        throw new GradleException(filePath + ': Missing key required "' + key + '"')
+    }
+    return props.get(key)
+}
 
-String getProjectTarget(String defaultTarget) {
-    def manifestFile = file("project.properties")
-    def pattern = Pattern.compile("target\\s*=\\s*(.*)")
-    def matcher = pattern.matcher(manifestFile.getText())
-    if (matcher.find()) {
-        matcher.group(1)
-    } else {
-        defaultTarget
+String doGetProjectTarget() {
+    def props = new Properties()
+    file('project.properties').withReader { reader ->
+        props.load(reader)
     }
+    return doEnsureValueExists('project.properties', props, 'target')
 }
 
 String[] getAvailableBuildTools() {
@@ -39,7 +42,7 @@ String[] getAvailableBuildTools() {
         .sort { a, b -> compareVersions(b, a) }
 }
 
-String findLatestInstalledBuildTools(String minBuildToolsVersion) {
+String doFindLatestInstalledBuildTools(String minBuildToolsVersion) {
     def availableBuildToolsVersions
     try {
         availableBuildToolsVersions = getAvailableBuildTools()
@@ -117,7 +120,7 @@ String getAndroidSdkDir() {
     androidSdkDir
 }
 
-def extractIntFromManifest(name) {
+def doExtractIntFromManifest(name) {
     def manifestFile = file(android.sourceSets.main.manifest.srcFile)
     def pattern = Pattern.compile(name + "=\"(\\d+)\"")
     def matcher = pattern.matcher(manifestFile.getText())
@@ -125,7 +128,7 @@ def extractIntFromManifest(name) {
     return Integer.parseInt(matcher.group(1))
 }
 
-def promptForPassword(msg) {
+def doPromptForPassword(msg) {
     if (System.console() == null) {
         def ret = null
         new SwingBuilder().edt {
@@ -153,9 +156,10 @@ def promptForPassword(msg) {
 ext {
     // These helpers are shared, but are not guaranteed to be stable / unchanged.
     privateHelpers = {}
-    privateHelpers.getProjectTarget = { defaultValue -> getProjectTarget(defaultValue)
}
-    privateHelpers.findLatestInstalledBuildTools = { defaultValue -> findLatestInstalledBuildTools(defaultValue)
}
-    privateHelpers.extractIntFromManifest = { name -> extractIntFromManifest(name) }
-    privateHelpers.promptForPassword = { msg -> promptForPassword(msg) }
+    privateHelpers.getProjectTarget = { doGetProjectTarget() }
+    privateHelpers.findLatestInstalledBuildTools = { doFindLatestInstalledBuildTools('19.1.0')
}
+    privateHelpers.extractIntFromManifest = { name -> doExtractIntFromManifest(name) }
+    privateHelpers.promptForPassword = { msg -> doPromptForPassword(msg) }
+    privateHelpers.ensureValueExists = { filePath, props, key -> doEnsureValueExists(filePath,
props, key) }
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message