@@ -306,15 +306,21 @@ function parseOpts(options, resolvedTarget) {
306306 // Iterate through command line options
307307 for ( var i = 0 ; options && ( i < options . length ) ; ++ i ) {
308308 if ( / ^ - - / . exec ( options [ i ] ) ) {
309- var option = options [ i ] . substring ( 2 ) ;
310- switch ( option ) {
309+ var keyValue = options [ i ] . substring ( 2 ) . split ( '=' ) ;
310+ var flagName = keyValue [ 0 ] ;
311+ var flagValue = keyValue [ 1 ] ;
312+ if ( ( flagName == 'versionCode' || flagName == 'minSdkVersion' ) && ! flagValue ) {
313+ flagValue = options [ i + 1 ] ;
314+ ++ i ;
315+ }
316+ switch ( flagName ) {
311317 case 'debug' :
312318 case 'release' :
313- ret . buildType = option ;
319+ ret . buildType = flagName ;
314320 break ;
315321 case 'ant' :
316322 case 'gradle' :
317- ret . buildMethod = option ;
323+ ret . buildMethod = flagName ;
318324 break ;
319325 case 'device' :
320326 case 'emulator' :
@@ -324,8 +330,14 @@ function parseOpts(options, resolvedTarget) {
324330 case 'nobuild' :
325331 ret . buildMethod = 'none' ;
326332 break ;
333+ case 'versionCode' :
334+ process . env [ 'ANDROID_VERSION_CODE' ] = flagValue ;
335+ break ;
336+ case 'minSdkVersion' :
337+ process . env [ 'ANDROID_MIN_SDK_VERSION' ] = flagValue ;
338+ break ;
327339 default :
328- console . warn ( 'Build option \'' + options [ i ] + '\' not recognized (ignoring).' ) ;
340+ console . warn ( 'Build option -- \'' + flagName + '\' not recognized (ignoring).' ) ;
329341 }
330342 } else {
331343 console . warn ( 'Build option \'' + options [ i ] + '\' not recognized (ignoring).' ) ;
@@ -445,12 +457,14 @@ module.exports.findBestApkForArchitecture = function(buildResults, arch) {
445457} ;
446458
447459module . exports . help = function ( ) {
448- console . log ( 'Usage: ' + path . relative ( process . cwd ( ) , path . join ( ROOT , 'cordova' , 'build' ) ) + ' [build_type ]' ) ;
449- console . log ( 'Build Types : ' ) ;
450- console . log ( ' \'--debug\': Default build, will build project in debug mode' ) ;
460+ console . log ( 'Usage: ' + path . relative ( process . cwd ( ) , path . join ( ROOT , 'cordova' , 'build' ) ) + ' [flags ]' ) ;
461+ console . log ( 'Flags: ' ) ;
462+ console . log ( ' \'--debug\': will build project in debug mode (default) ' ) ;
451463 console . log ( ' \'--release\': will build project for release' ) ;
452- console . log ( ' \'--ant\': Default build, will build project with ant' ) ;
464+ console . log ( ' \'--ant\': will build project with ant (default) ' ) ;
453465 console . log ( ' \'--gradle\': will build project with gradle' ) ;
454- console . log ( ' \'--nobuild\': will skip build process (can be used with run command)' ) ;
466+ console . log ( ' \'--nobuild\': will skip build process (useful when using run command)' ) ;
467+ console . log ( ' \'--versionCode=#\': Override versionCode for this build. Useful for uploading multiple APKs. Requires --gradle.' ) ;
468+ console . log ( ' \'--minSdkVersion=#\': Override minSdkVersion for this build. Useful for uploading multiple APKs. Requires --gradle.' ) ;
455469 process . exit ( 0 ) ;
456470} ;
0 commit comments