cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [1/9] android commit: CB-8978 Prepare copy resource-files from config.xml
Date Tue, 28 Mar 2017 05:25:33 GMT
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 <darryl@ayogo.com>
Authored: Thu Jul 28 12:44:50 2016 -0700
Committer: Steve Gill <stevengill97@gmail.com>
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


Mime
View raw message