Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 74D7310AD7 for ; Mon, 3 Feb 2014 20:26:49 +0000 (UTC) Received: (qmail 78714 invoked by uid 500); 3 Feb 2014 20:26:12 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 78675 invoked by uid 500); 3 Feb 2014 20:26:11 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 78273 invoked by uid 99); 3 Feb 2014 20:26:03 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Feb 2014 20:26:03 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D58A6918654; Mon, 3 Feb 2014 20:26:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: naika@apache.org To: commits@cordova.apache.org Date: Mon, 03 Feb 2014 20:26:23 -0000 Message-Id: In-Reply-To: <3451b70c458e450682b290fb4edc80c0@git.apache.org> References: <3451b70c458e450682b290fb4edc80c0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [22/32] git commit: CB-5793 Don't clean before build and change output directory to ant-build to avoid conflicts with Eclipse. CB-5793 Don't clean before build and change output directory to ant-build to avoid conflicts with Eclipse. Project: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/commit/1158b5f5 Tree: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/tree/1158b5f5 Diff: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/diff/1158b5f5 Branch: refs/heads/3.4.x Commit: 1158b5f5d34d13c71f6539a326d8f350fae7007f Parents: bf875dc Author: Andrew Grieve Authored: Sun Jan 19 23:08:05 2014 -0500 Committer: Archana Naik Committed: Mon Feb 3 11:09:46 2014 -0800 ---------------------------------------------------------------------- bin/templates/cordova/lib/build.js | 38 ++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/1158b5f5/bin/templates/cordova/lib/build.js ---------------------------------------------------------------------- diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js index 7ea7d09..5e8ce0a 100644 --- a/bin/templates/cordova/lib/build.js +++ b/bin/templates/cordova/lib/build.js @@ -20,7 +20,6 @@ */ var shell = require('shelljs'), - clean = require('./clean'), spawn = require('./spawn'), Q = require('q'), path = require('path'), @@ -34,13 +33,12 @@ var shell = require('shelljs'), module.exports.run = function(build_type) { //default build type build_type = typeof build_type !== 'undefined' ? build_type : "--debug"; - var args; + var args = ['debug', '-f', path.join(ROOT, 'build.xml'), '-Dout.dir=ant-build', '-Dgen.dir=ant-build/gen']; switch(build_type) { case '--debug' : - args = ['debug', '-f', path.join(ROOT, 'build.xml')]; break; case '--release' : - args = ['release', '-f', path.join(ROOT, 'build.xml')]; + args[0] = 'release'; break; case '--nobuild' : console.log('Skipping build...'); @@ -48,10 +46,7 @@ module.exports.run = function(build_type) { default : return Q.reject('Build option \'' + build_type + '\' not recognized.'); } - return clean.run() // TODO: Can we stop cleaning every time and let ant build incrementally? - .then(function() { - return spawn('ant', args); - }); + return spawn('ant', args); } /* @@ -59,17 +54,26 @@ module.exports.run = function(build_type) { * the script will error out. (should we error or just return undefined?) */ module.exports.get_apk = function() { - if(fs.existsSync(path.join(ROOT, 'bin'))) { - var bin_files = fs.readdirSync(path.join(ROOT, 'bin')); - for (file in bin_files) { - if(path.extname(bin_files[file]) == '.apk') { - return path.join(ROOT, 'bin', bin_files[file]); - } + var binDir = path.join(ROOT, 'ant-build'); + if (fs.existsSync(binDir)) { + var candidates = fs.readdirSync(binDir).filter(function(p) { + // Need to choose between release and debug .apk. + return path.extname(p) == '.apk'; + }).map(function(p) { + p = path.join(binDir, p); + return { p: p, t: fs.statSync(p).mtime }; + }).sort(function(a,b) { + return a.t > b.t ? -1 : + a.t < b.t ? 1 : 0; + }); + if (candidates.length === 0) { + console.error('ERROR : No .apk found in \'ant-build\' directory'); + process.exit(2); } - console.error('ERROR : No .apk found in \'bin\' folder'); - process.exit(2); + console.log('Using apk: ' + candidates[0].p); + return candidates[0].p; } else { - console.error('ERROR : unable to find project bin folder, could not locate .apk'); + console.error('ERROR : unable to find project ant-build directory, could not locate .apk'); process.exit(2); } }