You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/12/24 19:44:52 UTC
[1/3] android commit: CB-7980: Add 9 to versionCode for minSdk 20+ if
not multiarch
Repository: cordova-android
Updated Branches:
refs/heads/4.0.x a696ff37f -> 4f3ae2317
CB-7980: Add 9 to versionCode for minSdk 20+ if not multiarch
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/9224ab15
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/9224ab15
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/9224ab15
Branch: refs/heads/4.0.x
Commit: 9224ab15929b80d1b149e9f9e4743de86a04d77b
Parents: 931a996
Author: Mark Koudritsky <ka...@gmail.com>
Authored: Thu Nov 6 15:38:48 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Dec 23 15:29:40 2014 -0500
----------------------------------------------------------------------
bin/templates/project/build.gradle | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/9224ab15/bin/templates/project/build.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle
index a5faf91..573b289 100644
--- a/bin/templates/project/build.gradle
+++ b/bin/templates/project/build.gradle
@@ -73,7 +73,7 @@ android {
}
defaultConfig {
- versionCode Integer.parseInt(System.env.ANDROID_VERSION_CODE ?: ("" + getVersionCodeFromManifest() + "0"))
+ versionCode Integer.parseInt(System.env.ANDROID_VERSION_CODE ?: ("" + getIntFromManifest("versionCode") + "0"))
}
compileSdkVersion cordova.cordovaSdkVersion
@@ -99,6 +99,8 @@ android {
}
}
}
+ } else if (getIntFromManifest("minSdkVersion") >= 20) {
+ defaultConfig.versionCode += 9
}
compileOptions {
@@ -179,9 +181,9 @@ gradle.taskGraph.whenReady { taskGraph ->
}
}
-def getVersionCodeFromManifest() {
+def getIntFromManifest(name) {
def manifestFile = file(android.sourceSets.main.manifest.srcFile)
- def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
+ def pattern = Pattern.compile(name + "=\"(\\d+)\"")
def matcher = pattern.matcher(manifestFile.getText())
matcher.find()
return Integer.parseInt(matcher.group(1))
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[3/3] android commit: Merge branch 'master' into 4.0.x
(--minSdkVersion and --versionCode)
Posted by ag...@apache.org.
Merge branch 'master' into 4.0.x (--minSdkVersion and --versionCode)
Conflicts:
bin/templates/project/build.gradle
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/4f3ae231
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/4f3ae231
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/4f3ae231
Branch: refs/heads/4.0.x
Commit: 4f3ae23170d6b661f10b3f8a426534f12c35827e
Parents: a696ff3 7cfb33d
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Dec 24 13:35:17 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Dec 24 13:35:39 2014 -0500
----------------------------------------------------------------------
bin/templates/cordova/lib/build.js | 36 +++++++++++++++++++++++----------
bin/templates/project/build.gradle | 17 +++++++++++++---
2 files changed, 39 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4f3ae231/bin/templates/cordova/lib/build.js
----------------------------------------------------------------------
diff --cc bin/templates/cordova/lib/build.js
index 005ba70,b507c5e..621d7d8
--- a/bin/templates/cordova/lib/build.js
+++ b/bin/templates/cordova/lib/build.js
@@@ -445,12 -457,14 +457,14 @@@ module.exports.findBestApkForArchitectu
};
module.exports.help = function() {
- console.log('Usage: ' + path.relative(process.cwd(), path.join(ROOT, 'cordova', 'build')) + ' [build_type]');
- console.log('Build Types : ');
- console.log(' \'--debug\': Default build, will build project in debug mode');
+ console.log('Usage: ' + path.relative(process.cwd(), path.join(ROOT, 'cordova', 'build')) + ' [flags]');
+ console.log('Flags:');
+ console.log(' \'--debug\': will build project in debug mode (default)');
console.log(' \'--release\': will build project for release');
- console.log(' \'--ant\': Default build, will build project with ant');
- console.log(' \'--gradle\': will build project with gradle');
- console.log(' \'--nobuild\': will skip build process (can be used with run command)');
- console.log(' \'--ant\': will build project with ant (default)');
- console.log(' \'--gradle\': will build project with gradle');
++ console.log(' \'--ant\': will build project with ant');
++ console.log(' \'--gradle\': will build project with gradle (default)');
+ console.log(' \'--nobuild\': will skip build process (useful when using run command)');
+ console.log(' \'--versionCode=#\': Override versionCode for this build. Useful for uploading multiple APKs. Requires --gradle.');
+ console.log(' \'--minSdkVersion=#\': Override minSdkVersion for this build. Useful for uploading multiple APKs. Requires --gradle.');
process.exit(0);
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[2/3] android commit: CB-7980 Add --minSdkVersion and --versionCode
flags to cordova/build command
Posted by ag...@apache.org.
CB-7980 Add --minSdkVersion and --versionCode flags to cordova/build command
These are also exposed via environment variables: ANDROID_VERSION_CODE, ANDROID_MIN_SDK_VERSION
This also fixes build.gradle modifying the value set by ANDROID_VERSION_CODE when multi-apk is enabled (override should never be modified)
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/7cfb33d0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/7cfb33d0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/7cfb33d0
Branch: refs/heads/4.0.x
Commit: 7cfb33d0ef057ec5cbe23c30b4ac0c8dd504933c
Parents: 9224ab1
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Dec 23 16:26:43 2014 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Dec 23 16:26:43 2014 -0500
----------------------------------------------------------------------
bin/templates/cordova/lib/build.js | 34 +++++++++++++++++++++++----------
bin/templates/project/build.gradle | 17 ++++++++++++++---
2 files changed, 38 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/7cfb33d0/bin/templates/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js
index 86b5e66..b507c5e 100644
--- a/bin/templates/cordova/lib/build.js
+++ b/bin/templates/cordova/lib/build.js
@@ -306,15 +306,21 @@ function parseOpts(options, resolvedTarget) {
// Iterate through command line options
for (var i=0; options && (i < options.length); ++i) {
if (/^--/.exec(options[i])) {
- var option = options[i].substring(2);
- switch(option) {
+ var keyValue = options[i].substring(2).split('=');
+ var flagName = keyValue[0];
+ var flagValue = keyValue[1];
+ if ((flagName == 'versionCode' || flagName == 'minSdkVersion') && !flagValue) {
+ flagValue = options[i + 1];
+ ++i;
+ }
+ switch(flagName) {
case 'debug':
case 'release':
- ret.buildType = option;
+ ret.buildType = flagName;
break;
case 'ant':
case 'gradle':
- ret.buildMethod = option;
+ ret.buildMethod = flagName;
break;
case 'device':
case 'emulator':
@@ -324,8 +330,14 @@ function parseOpts(options, resolvedTarget) {
case 'nobuild' :
ret.buildMethod = 'none';
break;
+ case 'versionCode':
+ process.env['ANDROID_VERSION_CODE'] = flagValue;
+ break;
+ case 'minSdkVersion':
+ process.env['ANDROID_MIN_SDK_VERSION'] = flagValue;
+ break;
default :
- console.warn('Build option \'' + options[i] + '\' not recognized (ignoring).');
+ console.warn('Build option --\'' + flagName + '\' not recognized (ignoring).');
}
} else {
console.warn('Build option \'' + options[i] + '\' not recognized (ignoring).');
@@ -445,12 +457,14 @@ module.exports.findBestApkForArchitecture = function(buildResults, arch) {
};
module.exports.help = function() {
- console.log('Usage: ' + path.relative(process.cwd(), path.join(ROOT, 'cordova', 'build')) + ' [build_type]');
- console.log('Build Types : ');
- console.log(' \'--debug\': Default build, will build project in debug mode');
+ console.log('Usage: ' + path.relative(process.cwd(), path.join(ROOT, 'cordova', 'build')) + ' [flags]');
+ console.log('Flags:');
+ console.log(' \'--debug\': will build project in debug mode (default)');
console.log(' \'--release\': will build project for release');
- console.log(' \'--ant\': Default build, will build project with ant');
+ console.log(' \'--ant\': will build project with ant (default)');
console.log(' \'--gradle\': will build project with gradle');
- console.log(' \'--nobuild\': will skip build process (can be used with run command)');
+ console.log(' \'--nobuild\': will skip build process (useful when using run command)');
+ console.log(' \'--versionCode=#\': Override versionCode for this build. Useful for uploading multiple APKs. Requires --gradle.');
+ console.log(' \'--minSdkVersion=#\': Override minSdkVersion for this build. Useful for uploading multiple APKs. Requires --gradle.');
process.exit(0);
};
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/7cfb33d0/bin/templates/project/build.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle
index 573b289..e147691 100644
--- a/bin/templates/project/build.gradle
+++ b/bin/templates/project/build.gradle
@@ -74,6 +74,9 @@ android {
defaultConfig {
versionCode Integer.parseInt(System.env.ANDROID_VERSION_CODE ?: ("" + getIntFromManifest("versionCode") + "0"))
+ if (System.env.ANDROID_MIN_SDK_VERSION) {
+ minSdkVersion Integer.parseInt(System.env.ANDROID_MIN_SDK_VERSION)
+ }
}
compileSdkVersion cordova.cordovaSdkVersion
@@ -82,13 +85,13 @@ android {
if (multiarch || System.env.BUILD_MULTIPLE_APKS) {
productFlavors {
armv7 {
- versionCode defaultConfig.versionCode + 2
+ versionCode System.env.ANDROID_VERSION_CODE ?: defaultConfig.versionCode + 2
ndk {
abiFilters "armeabi-v7a", ""
}
}
x86 {
- versionCode defaultConfig.versionCode + 4
+ versionCode System.env.ANDROID_VERSION_CODE ?: defaultConfig.versionCode + 4
ndk {
abiFilters "x86", ""
}
@@ -99,8 +102,16 @@ android {
}
}
}
- } else if (getIntFromManifest("minSdkVersion") >= 20) {
+ } else if (!System.env.ANDROID_VERSION_CODE) {
+ def minSdkVersion = Integer.parseInt(System.env.ANDROID_MIN_SDK_VERSION ?: "" + getIntFromManifest("minSdkVersion"))
+ // Vary versionCode by the two most common API levels:
+ // 14 is ICS, which is the lowest API level for many apps.
+ // 20 is Lollipop, which is the lowest API level for the updatable system webview.
+ if (minSdkVersion >= 20) {
defaultConfig.versionCode += 9
+ } else if (minSdkVersion >= 14) {
+ defaultConfig.versionCode += 8
+ }
}
compileOptions {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org