From d9900a725d84c5629cdb0f783b7ef99ac9d8bb72 Mon Sep 17 00:00:00 2001 From: mbillau Date: Tue, 9 Sep 2014 09:38:15 -0400 Subject: [PATCH 1/4] Second part of CB-7499, support RTL text direction --- bin/templates/project/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/templates/project/AndroidManifest.xml b/bin/templates/project/AndroidManifest.xml index cea9dc31..603f4a75 100644 --- a/bin/templates/project/AndroidManifest.xml +++ b/bin/templates/project/AndroidManifest.xml @@ -31,7 +31,7 @@ + android:hardwareAccelerated="true" android:supportsRtl="true"> Date: Tue, 16 Sep 2014 10:28:34 -0400 Subject: [PATCH 2/4] CB-7536 check_reqs: windows tweaks + sdk manager error message 1. Don't escape \s since those are used by windows for directory seperators 2. Don't warn about missing directories on windows when we're just testing for their existence 3. Don't give command to install sdk from command-line, since they also require Build-tools and Platform-tools (which are not installed by default with IDE-less SDK installer). --- bin/lib/check_reqs.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js index 358c73f4..a7410e99 100644 --- a/bin/lib/check_reqs.js +++ b/bin/lib/check_reqs.js @@ -110,10 +110,13 @@ module.exports.check_java = function() { } } else if (isWindows) { // Try to auto-detect java in the default install paths. + var oldSilent = shelljs.config.silent; + shelljs.config.silent = true; var firstJdkDir = shelljs.ls(process.env['ProgramFiles'] + '\\java\\jdk*')[0] || shelljs.ls('C:\\Program Files\\java\\jdk*')[0] || shelljs.ls('C:\\Program Files (x86)\\java\\jdk*')[0]; + shelljs.config.silent = oldSilent; if (firstJdkDir) { // shelljs always uses / in paths. firstJdkDir = firstJdkDir.replace(/\//g, path.sep); @@ -195,7 +198,7 @@ module.exports.check_android = function() { }; module.exports.getAbsoluteAndroidCmd = function() { - return forgivingWhichSync('android').replace(/([ \\])/g, '\\$1'); + return forgivingWhichSync('android').replace(/(\s)/g, '\\$1'); }; module.exports.check_android_target = function(valid_target) { @@ -209,9 +212,12 @@ module.exports.check_android_target = function(valid_target) { .then(function(output) { if (output.split('\n').indexOf(valid_target) == -1) { var androidCmd = module.exports.getAbsoluteAndroidCmd(); - throw new Error('Please install Android target: "' + valid_target + '".\n' + + throw new Error('Please install Android target: "' + valid_target + '".\n\n' + 'Hint: Open the SDK manager by running: ' + androidCmd + '\n' + - 'Or install directly via: ' + androidCmd + ' update sdk --no-ui --all --filter "' + valid_target + '"'); + 'You will require:\n' + + '1. "SDK Platform" for ' + valid_target + '\n' + + '2. "Android SDK Platform-tools (latest)\n' + + '3. "Android SDK Build-tools" (latest)'); } }); }; From 00f6d30e081c6a81ad0fb2aeb437f3840a73f39c Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Tue, 16 Sep 2014 13:00:27 -0400 Subject: [PATCH 3/4] CB-7512 Change gradle android plugins from 0.10 -> 0.12 --- bin/templates/cordova/lib/build.js | 2 +- bin/templates/project/build.gradle | 4 ++-- bin/templates/project/cordova.gradle | 2 +- framework/build.gradle | 7 ++++++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js index df2448c0..585b7af6 100644 --- a/bin/templates/cordova/lib/build.js +++ b/bin/templates/cordova/lib/build.js @@ -236,7 +236,7 @@ var builders = { // Find the recently-generated output APK files // Gradle can generate multiple output files; return all of them. getOutputFiles: function(build_type) { - var binDir = path.join(ROOT, 'build', 'apk'); + var binDir = path.join(ROOT, 'build', 'outputs', 'apk'); var candidates = find_files(binDir, function(candidate) { // Need to choose between release and debug .apk. if (build_type === 'debug') { diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle index e3468d85..e76634f6 100644 --- a/bin/templates/project/build.gradle +++ b/bin/templates/project/build.gradle @@ -29,7 +29,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:0.10.+' + classpath 'com.android.tools.build:gradle:0.12.0+' } } @@ -109,7 +109,7 @@ def getProjectList() { def matcher = pattern.matcher(manifestFile.getText()) def projects = [] while (matcher.find()) { - projects.add(":" + matcher.group(2).replace("/",":")) + projects.add(":" + matcher.group(2).replace("/",":")) } return projects } diff --git a/bin/templates/project/cordova.gradle b/bin/templates/project/cordova.gradle index 6c7d0ab3..ba73c93e 100644 --- a/bin/templates/project/cordova.gradle +++ b/bin/templates/project/cordova.gradle @@ -116,5 +116,5 @@ String getAndroidSdkDir() { } cordovaSdkVersion = getProjectTarget("android-19") -cordovaBuildToolsVersion = latestBuildToolsAvailable("19.0.0") +cordovaBuildToolsVersion = latestBuildToolsAvailable("19.1.0") diff --git a/framework/build.gradle b/framework/build.gradle index 59e1ae75..6ca284d3 100644 --- a/framework/build.gradle +++ b/framework/build.gradle @@ -25,7 +25,12 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:0.10.+' + // This should be updated with each cordova-android release. + // It can affect things like where the .apk is generated. + // It also dictates what the minimum android build-tools version + // that you need (Set in bin/templates/project/cordova.gradle). + // Be sure to also update the value in bin/templates/project. + classpath 'com.android.tools.build:gradle:0.12.+' } } From 25be42d3857c0d841db899ce226836f466b71dcb Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Tue, 16 Sep 2014 13:01:25 -0400 Subject: [PATCH 4/4] CB-7512 Add gradle environment vars for signing apks --- bin/templates/project/build.gradle | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle index e76634f6..a1f74b9b 100644 --- a/bin/templates/project/build.gradle +++ b/bin/templates/project/build.gradle @@ -89,6 +89,26 @@ android { targetCompatibility JavaVersion.VERSION_1_7 } + if (System.env.RELEASE_SIGNING_PROPERTIES_FILE) { + signingConfigs { + release { + // These must be set or Gradle will complain (even if they are overridden). + keyAlias = "" + keyPassword = "" + storeFile = null + storePassword = "" + } + } + buildTypes { + release { + signingConfig signingConfigs.release + } + } + addSigningProps(System.env.RELEASE_SIGNING_PROPERTIES_FILE, signingConfigs.release) + } + if (System.env.DEBUG_SIGNING_PROPERTIES_FILE) { + addSigningProps(System.env.DEBUG_SIGNING_PROPERTIES_FILE, signingConfigs.debug) + } } task wrapper(type: Wrapper) { @@ -113,3 +133,24 @@ def getProjectList() { } return projects } + +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) + propsFile.withReader { reader -> + def props = new Properties() + props.load(reader) + signingConfig.keyAlias = ensureValueExists(propsFilePath, props, 'keyAlias') + signingConfig.keyPassword = ensureValueExists(propsFilePath, props, 'keyPassword') + signingConfig.storeFile = RelativePath.parse(true, ensureValueExists(propsFilePath, props, 'storeFile')).getFile(propsFile.getParentFile()) + signingConfig.storePassword = ensureValueExists(propsFilePath, props, 'storePassword') + } +} + +