cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kamrik <...@git.apache.org>
Subject [GitHub] cordova-lib pull request: CB-6698: Support library references for ...
Date Wed, 28 May 2014 15:34:20 GMT
Github user kamrik commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/21#discussion_r13137628
  
    --- Diff: cordova-lib/src/plugman/platforms/android.js ---
    @@ -80,10 +84,115 @@ module.exports = {
         },
         "framework": {
             install:function(source_el, plugin_dir, project_dir, plugin_id) {
    -            events.emit('verbose', 'framework.install is not supported for android');
    +            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) {
    +                subDir = path.resolve(project_dir, src);
    +            } else {
    +                var localProperties = properties_parser.createEditor(path.resolve(project_dir,
"local.properties"));
    +                subDir = path.resolve(localProperties.get("sdk.dir"), src);
    +            }
    +            var projectConfig = module.exports.parseProjectFile(project_dir);
    +            projectConfig.addSubProject(parentDir, subDir);
             },
             uninstall:function(source_el, project_dir, plugin_id) {
    -            events.emit('verbose', 'framework.uninstall is not supported for android');
    +            var src = source_el.attrib.src;
    +            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 = path.resolve(project_dir, src);
    +            var projectConfig = module.exports.parseProjectFile(project_dir);
    +            projectConfig.removeSubProject(parentDir, subDir);
             }
    +    },
    +    parseProjectFile: function(project_dir){
    +        if (!projectFileCache[project_dir]) {
    +            projectFileCache[project_dir] = {
    --- End diff --
    
    This is an inline definition of a pretty rich object with non trivial methods. I think
it will be way more readable to define a separate class like AndroidProjectFile (naming is
up to you) and have this line look like this:
    projectFileCache[project_dir] = new AndroidProjectFile(...);
    
    I would even define the AndroidProjectFile class in a separate js file, this way other
platforms similar to Android might reuse or subclass it if they want.
    The windows8 parser does something similar with the util/w8jsproj.js
    
    Otherwise LGTM.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message