[ https://issues.apache.org/jira/browse/CB-6698?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14011207#comment-14011207 ]
ASF GitHub Bot commented on CB-6698: ------------------------------------ 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. > Plugman support for referencing Android libraries > ------------------------------------------------- > > Key: CB-6698 > URL: https://issues.apache.org/jira/browse/CB-6698 > Project: Apache Cordova > Issue Type: New Feature > Components: Plugman > Reporter: Martin Bektchiev > Assignee: Martin Bektchiev > > Make plugman capable of referencing an Android library project from within a > plugin. > Currently there's no viable way to do it and it is becoming common to try to > circumvent this limitation by abusing *plugin.xml* to (try to) merge a > library's resources, code and configuration. (see > https://github.com/wildabeast/BarcodeScanner) -- This message was sent by Atlassian JIRA (v6.2#6252)