Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E92B5200C53 for ; Tue, 28 Mar 2017 07:25:35 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E7BF6160BA4; Tue, 28 Mar 2017 05:25:35 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3CC96160B9F for ; Tue, 28 Mar 2017 07:25:35 +0200 (CEST) Received: (qmail 9160 invoked by uid 500); 28 Mar 2017 05:25:34 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 8827 invoked by uid 99); 28 Mar 2017 05:25:33 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Mar 2017 05:25:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 62FFCDFF36; Tue, 28 Mar 2017 05:25:33 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: steven@apache.org To: commits@cordova.apache.org Date: Tue, 28 Mar 2017 05:25:33 -0000 Message-Id: <6e1b0156eef04d7b9f6c56ec70385586@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/9] android commit: CB-8978 Prepare copy resource-files from config.xml archived-at: Tue, 28 Mar 2017 05:25:36 -0000 Repository: cordova-android Updated Branches: refs/heads/master 08c80f77a -> a8af103ff CB-8978 Prepare copy resource-files from config.xml This closes #321 Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/0df50c3f Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/0df50c3f Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/0df50c3f Branch: refs/heads/master Commit: 0df50c3f33e94faad04ca8133bc6d9fa753cff4d Parents: 08c80f7 Author: Darryl Pogue Authored: Thu Jul 28 12:44:50 2016 -0700 Committer: Steve Gill Committed: Mon Mar 27 22:13:13 2017 -0700 ---------------------------------------------------------------------- bin/templates/cordova/lib/prepare.js | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-android/blob/0df50c3f/bin/templates/cordova/lib/prepare.js ---------------------------------------------------------------------- diff --git a/bin/templates/cordova/lib/prepare.js b/bin/templates/cordova/lib/prepare.js index 10a69ea..504eb61 100644 --- a/bin/templates/cordova/lib/prepare.js +++ b/bin/templates/cordova/lib/prepare.js @@ -48,6 +48,7 @@ module.exports.prepare = function (cordovaProject, options) { .then(function () { updateIcons(cordovaProject, path.relative(cordovaProject.root, self.locations.res)); updateSplashes(cordovaProject, path.relative(cordovaProject.root, self.locations.res)); + updateFileResources(cordovaProject, path.relative(cordovaProject.root, self.locations.root)); }) .then(function () { events.emit('verbose', 'Prepared android project successfully'); @@ -72,6 +73,7 @@ module.exports.clean = function (options) { cleanWww(projectRoot, self.locations); cleanIcons(projectRoot, projectConfig, path.relative(projectRoot, self.locations.res)); cleanSplashes(projectRoot, projectConfig, path.relative(projectRoot, self.locations.res)); + cleanFileResources(projectRoot, projectConfig, path.relative(projectRoot, self.locations.root)); }); }; @@ -401,6 +403,44 @@ function mapImageResources(rootDir, subDir, type, resourceName) { return pathMap; } + +function updateFileResources(cordovaProject, platformDir) { + var files = cordovaProject.projectConfig.getFileResources('android'); + + // if there are resource-file elements in config.xml + if (files.length === 0) { + events.emit('verbose', 'This app does not have additional resource files defined'); + return; + } + + var resourceMap = {}; + files.forEach(function(res) { + var targetPath = path.join(platformDir, res.target); + resourceMap[targetPath] = res.src; + }); + + events.emit('verbose', 'Updating resource files at ' + platformDir); + FileUpdater.updatePaths( + resourceMap, { rootDir: cordovaProject.root }, logFileOp); +} + + +function cleanFileResources(projectRoot, projectConfig, platformDir) { + var files = projectConfig.getFileResources('android'); + if (files.length > 0) { + events.emit('verbose', 'Cleaning resource files at ' + platformDir); + + var resourceMap = {}; + files.forEach(function(res) { + var filePath = path.join(platformDir, res.target); + resourceMap[filePath] = null; + }); + + FileUpdater.updatePaths( + resourceMap, { rootDir: projectRoot, all: true}, logFileOp); + } +} + /** * Gets and validates 'AndroidLaunchMode' prepference from config.xml. Returns * preference value and warns if it doesn't seems to be valid --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org