cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject cordova-lib git commit: Amazon related changes. Added a type named "gradleReference" in framework according to https://git-wip-us.apache.org/repos/asf?p=cordova-lib.git; a=commit; h=02a96d757acc604610eb403cf11f79513ead4ac5
Date Sat, 06 Dec 2014 16:07:43 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master f99de0d2c -> 61c1c2862


Amazon related changes.
Added a type named "gradleReference" in framework according to
https://git-wip-us.apache.org/repos/asf?p=cordova-lib.git;a=commit;h=02a96d757acc604610eb403cf11f79513ead4ac5


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/61c1c286
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/61c1c286
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/61c1c286

Branch: refs/heads/master
Commit: 61c1c2862ca632171b9c3b9088449f3d452d77a0
Parents: f99de0d
Author: Ajitha <ajithas@amazon.com>
Authored: Mon Dec 1 13:21:47 2014 +0530
Committer: Archana Naik <naika@lab126.com>
Committed: Sat Dec 6 08:07:32 2014 -0800

----------------------------------------------------------------------
 .../src/plugman/platforms/amazon-fireos.js      | 78 +++++++++++++++++++-
 1 file changed, 76 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/61c1c286/cordova-lib/src/plugman/platforms/amazon-fireos.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/amazon-fireos.js b/cordova-lib/src/plugman/platforms/amazon-fireos.js
index 952a5d2..3b03d8e 100644
--- a/cordova-lib/src/plugman/platforms/amazon-fireos.js
+++ b/cordova-lib/src/plugman/platforms/amazon-fireos.js
@@ -26,8 +26,12 @@ var path = require('path')
    , common = require('./common')
    , events = require('../../events')
    , xml_helpers = require(path.join(__dirname, '..', '..', 'util', 'xml-helpers'))
+   , properties_parser = require('properties-parser')
+   , android_project = require('../util/android-project')
    ;
 
+var projectFileCache = {};
+
 module.exports = {
     www_dir:function(project_dir) {
         return path.join(project_dir, 'assets', 'www');
@@ -84,10 +88,80 @@ module.exports = {
     },
     'framework': {
         install:function(source_el, plugin_dir, project_dir, plugin_id) {
-            events.emit('verbose', 'framework.install is not supported for amazon-fireos');
+            var src = source_el.attrib.src;
+            var custom = source_el.attrib.custom;
+            if (!src) throw new Error('src not specified in framework element');
+
+            events.emit('verbose', 'Installing Android library: ' + src);
+            var parent = source_el.attrib.parent;
+            var parentDir = parent ? path.resolve(project_dir, parent) : project_dir;
+            var subDir;
+
+            if (custom) {
+                var subRelativeDir = module.exports.getCustomSubprojectRelativeDir(plugin_id,
project_dir, src);
+                common.copyNewFile(plugin_dir, src, project_dir, subRelativeDir);
+                subDir = path.resolve(project_dir, subRelativeDir);
+            } else {
+                var sdk_dir = module.exports.getProjectSdkDir(project_dir);
+                subDir = path.resolve(sdk_dir, src);
+            }
+
+            var projectConfig = module.exports.parseProjectFile(project_dir);
+            var type = source_el.attrib.type;
+            if (type == 'gradleReference') {
+                //add reference to build.gradle
+                projectConfig.addGradleReference(parentDir, subDir);
+            } else {
+                projectConfig.addSubProject(parentDir, subDir);
+            }
         },
         uninstall:function(source_el, project_dir, plugin_id) {
-            events.emit('verbose', 'framework.uninstall is not supported for amazon-fireos');
+            var src = source_el.attrib.src;
+            var custom = source_el.attrib.custom;
+            if (!src) throw new Error('src not specified in framework element');
+
+            events.emit('verbose', 'Uninstalling Android library: ' + src);
+            var parent = source_el.attrib.parent;
+            var parentDir = parent ? path.resolve(project_dir, parent) : project_dir;
+            var subDir;
+
+            if (custom) {
+                var subRelativeDir = module.exports.getCustomSubprojectRelativeDir(plugin_id,
project_dir, src);
+                common.removeFile(project_dir, subRelativeDir);
+                subDir = path.resolve(project_dir, subRelativeDir);
+            } else {
+                var sdk_dir = module.exports.getProjectSdkDir(project_dir);
+                subDir = path.resolve(sdk_dir, src);
+            }
+
+            var projectConfig = module.exports.parseProjectFile(project_dir);
+            var type = source_el.attrib.type;
+            if (type == 'gradleReference') {
+                projectConfig.removeGradleReference(parentDir, subDir);
+            } else {
+                projectConfig.removeSubProject(parentDir, subDir);
+            }
         }
+    },
+    parseProjectFile: function(project_dir){
+        if (!projectFileCache[project_dir]) {
+            projectFileCache[project_dir] = new android_project.AndroidProject();
+        }
+
+        return projectFileCache[project_dir];
+    },
+    purgeProjectFileCache:function(project_dir) {
+        delete projectFileCache[project_dir];
+    },
+    getProjectSdkDir: function (project_dir) {
+        var localProperties = properties_parser.createEditor(path.resolve(project_dir, 'local.properties'));
+        return localProperties.get('sdk.dir');
+    },
+    getCustomSubprojectRelativeDir: function (plugin_id, project_dir, src) {
+        // All custom subprojects are prefixed with the last portion of the package id.
+        // This is to avoid collisions when opening multiple projects in Eclipse that have
subprojects with the same name.
+        var prefix = module.exports.package_suffix(project_dir);
+        var subRelativeDir = path.join(plugin_id, prefix + '-' + path.basename(src));
+        return subRelativeDir;
     }
 };


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message