CB-12612 : removing old amazon-fireos code This closes #532
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/0d637f2d Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/0d637f2d Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/0d637f2d Branch: refs/heads/common-2.0.x Commit: 0d637f2d67a95ef709443eaa9d7481eb14f79b8d Parents: 08d47d8 Author: Audrey So <audre...@apache.org> Authored: Tue Mar 28 15:41:59 2017 -0700 Committer: Steve Gill <stevengil...@gmail.com> Committed: Wed Apr 5 16:20:53 2017 -0500 ---------------------------------------------------------------------- cordova-lib/spec-cordova/prepare.spec.js | 2 - .../plugins/com.adobe.vars/plugin.xml | 9 - .../org.test.plugins.dummyplugin/plugin.xml | 28 +- .../org.test.plugins.faultyplugin/plugin.xml | 26 -- .../cordova/metadata/amazon_fireos_parser.js | 361 ------------------- cordova-lib/src/cordova/platform.js | 5 +- cordova-lib/src/platforms/platformsConfig.json | 7 - .../src/plugman/platforms/amazon-fireos.js | 179 --------- 8 files changed, 2 insertions(+), 615 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0d637f2d/cordova-lib/spec-cordova/prepare.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/prepare.spec.js b/cordova-lib/spec-cordova/prepare.spec.js index ed740c7..c9b0911 100644 --- a/cordova-lib/spec-cordova/prepare.spec.js +++ b/cordova-lib/spec-cordova/prepare.spec.js @@ -143,7 +143,6 @@ describe('prepare command', function() { 'osx', 'android', 'ubuntu', - 'amazon-fireos', 'wp8', 'blackberry10', 'firefoxos', @@ -158,7 +157,6 @@ describe('prepare command', function() { path.join('/','some','path','platforms','osx','www'), path.join('/','some','path','platforms','android','www'), path.join('/','some','path','platforms','ubuntu','www'), - path.join('/','some','path','platforms','amazon-fireos','www'), path.join('/','some','path','platforms','wp8','www'), path.join('/','some','path','platforms','blackberry10','www'), path.join('/','some','path','platforms','firefoxos','www'), http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0d637f2d/cordova-lib/spec-plugman/plugins/com.adobe.vars/plugin.xml ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/plugins/com.adobe.vars/plugin.xml b/cordova-lib/spec-plugman/plugins/com.adobe.vars/plugin.xml index d1e1bff..a67b7b2 100644 --- a/cordova-lib/spec-plugman/plugins/com.adobe.vars/plugin.xml +++ b/cordova-lib/spec-plugman/plugins/com.adobe.vars/plugin.xml @@ -36,15 +36,6 @@ </config-file> </platform> - - <!-- amazon fireos --> - <platform name="amazon-fireos"> - <config-file target="AndroidManifest.xml" parent="/manifest"> - <poop name="GoogleMapsApiKey" value="$API_KEY" /> - <package>$PACKAGE_NAME</package> - </config-file> - - </platform> <!-- ios --> <platform name="ios"> http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0d637f2d/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml index 5339b97..5cd13cd 100644 --- a/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml +++ b/cordova-lib/spec-plugman/plugins/org.test.plugins.dummyplugin/plugin.xml @@ -72,33 +72,7 @@ target-dir="src/com/phonegap/plugins/dummyplugin" /> <lib-file src="src/android/TestLib.jar" /> </platform> - - <!-- amazon fireos --> - <platform name="amazon-fireos"> - <config-file target="AndroidManifest.xml" parent="/manifest/application"> - <activity android:name="DummyPlugin.org.test.plugins.dummyplugin" - android:label="@string/app_name"> - <intent-filter> - </intent-filter> - </activity> - </config-file> - - <!-- CDV < 2.0 --> - <config-file target="res/xml/plugins.xml" parent="/plugins"> - <plugin name="org.test.plugins.dummyplugin" - value="DummyPlugin.org.test.plugins.dummyplugin"/> - </config-file> - - <!-- CDV 2.0+ (for now) --> - <config-file target="res/xml/config.xml" parent="/cordova/plugins"> - <plugin name="org.test.plugins.dummyplugin" - value="DummyPlugin.org.test.plugins.dummyplugin"/> - </config-file> - - <source-file src="src/android/DummyPlugin.java" - target-dir="src/com/phonegap/plugins/dummyplugin" /> - <lib-file src="src/android/TestLib.jar" /> - </platform> + <!-- blackberry10 --> <platform name="blackberry10"> http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0d637f2d/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/plugin.xml ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/plugin.xml b/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/plugin.xml index b8eb476..36a7d6a 100644 --- a/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/plugin.xml +++ b/cordova-lib/spec-plugman/plugins/org.test.plugins.faultyplugin/plugin.xml @@ -61,32 +61,6 @@ target-dir="src/com/phonegap/plugins/faultyplugin" /> </platform> - <!-- android --> - <platform name="amazon-fireos"> - <config-file target="AndroidManifest.xml" parent="/manifest/application"> - <activity android:name="org.test.plugins.faultyplugin.org.test.plugins.faultyplugin" - android:label="@string/app_name"> - <intent-filter> - </intent-filter> - </activity> - </config-file> - - <!-- CDV < 2.0 --> - <config-file target="res/xml/plugins.xml" parent="/plugins"> - <plugin name="org.test.plugins.faultyplugin" - value="org.test.plugins.faultyplugin.org.test.plugins.faultyplugin"/> - </config-file> - - <!-- CDV 2.0+ (for now) --> - <config-file target="res/xml/config.xml" parent="/cordova/plugins"> - <plugin name="org.test.plugins.faultyplugin" - value="org.test.plugins.faultyplugin.org.test.plugins.faultyplugin"/> - </config-file> - - <!-- this file doesn't exist --> - <source-file src="src/android/NotHere.java" - target-dir="src/com/phonegap/plugins/faultyplugin" /> - </platform> <!-- ios --> <platform name="ios"> http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0d637f2d/cordova-lib/src/cordova/metadata/amazon_fireos_parser.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/cordova/metadata/amazon_fireos_parser.js b/cordova-lib/src/cordova/metadata/amazon_fireos_parser.js deleted file mode 100644 index 5e82241..0000000 --- a/cordova-lib/src/cordova/metadata/amazon_fireos_parser.js +++ /dev/null @@ -1,361 +0,0 @@ -/** - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ - -var fs = require('fs'), - path = require('path'), - et = require('elementtree'), - xml = require('cordova-common').xmlHelpers, - util = require('../util'), - events = require('cordova-common').events, - shell = require('shelljs'), - Q = require('q'), - Parser = require('./parser'), - ConfigParser = require('cordova-common').ConfigParser, - CordovaError = require('cordova-common').CordovaError; - - -function amazon_fireos_parser(project) { - if (!fs.existsSync(path.join(project, 'AndroidManifest.xml'))) { - throw new CordovaError('The provided path "' + project + '" is not an Android project.'); - } - - // Call the base class constructor - Parser.call(this, 'amazon_fireos', project); - - this.path = project; - this.strings = path.join(this.path, 'res', 'values', 'strings.xml'); - this.manifest = path.join(this.path, 'AndroidManifest.xml'); - this.android_config = path.join(this.path, 'res', 'xml', 'config.xml'); -} - -require('util').inherits(amazon_fireos_parser, Parser); - -module.exports = amazon_fireos_parser; - -amazon_fireos_parser.prototype.findAndroidLaunchModePreference = function(config) { - var launchMode = config.getPreference('AndroidLaunchMode'); - if (!launchMode) { - // Return a default value - return 'singleTop'; - } - - var expectedValues = ['standard', 'singleTop', 'singleTask', 'singleInstance']; - var valid = expectedValues.indexOf(launchMode) !== -1; - if (!valid) { - events.emit('warn', 'Unrecognized value for AndroidLaunchMode preference: ' + launchMode); - events.emit('warn', ' Expected values are: ' + expectedValues.join(', ')); - // Note: warn, but leave the launch mode as developer wanted, in case the list of options changes in the future - } - - return launchMode; -}; - -// remove the default resource name from all drawable folders -// return the array of the densities in this project -amazon_fireos_parser.prototype.deleteDefaultResource = function (name) { - var densities = []; - var res = path.join(this.path, 'res'); - var dirs = fs.readdirSync(res); - - for (var i = 0; i < dirs.length; i++) { - var filename = dirs[i]; - if (filename.indexOf('drawable-') === 0) { - var density = filename.substr(9); - densities.push(density); - var template = path.join(res, filename, name); - try { - fs.unlinkSync(template); - events.emit('verbose', 'deleted: ' + template); - } catch (e) { - // ignored. template screen does probably not exist - } - } - } - return densities; -}; - -amazon_fireos_parser.prototype.copyImage = function(src, density, name) { - var destFolder = path.join(this.path, 'res', (density ? 'drawable-': 'drawable') + density); - var destFilePath = path.join(destFolder, name); - - // default template does not have default asset for this density - if (!fs.existsSync(destFolder)) { - fs.mkdirSync(destFolder); - } - events.emit('verbose', 'copying image from ' + src + ' to ' + destFilePath); - shell.cp('-f', src, destFilePath); -}; - -amazon_fireos_parser.prototype.handleSplashes = function (config) { - var resources = config.getSplashScreens('android'); - var destfilepath; - // if there are "splash" elements in config.xml - if (resources.length > 0) { - var densities = this.deleteDefaultResource('screen.png'); - events.emit('verbose', 'splash screens: ' + JSON.stringify(resources)); - var res = path.join(this.path, 'res'); - - if (resources.defaultResource) { - destfilepath = path.join(res, 'drawable', 'screen.png'); - events.emit('verbose', 'copying splash icon from ' + resources.defaultResource.src + ' to ' + destfilepath); - shell.cp('-f', resources.defaultResource.src, destfilepath); - } - for (var i = 0; i < densities.length; i++) { - var density = densities[i]; - var resource = resources.getByDensity(density); - if (resource) { - // copy splash screens. - destfilepath = path.join(res, 'drawable-' + density, 'screen.png'); - events.emit('verbose', 'copying splash icon from ' + resource.src + ' to ' + destfilepath); - shell.cp('-f', resource.src, destfilepath); - } - } - } -}; - -amazon_fireos_parser.prototype.handleIcons = function(config) { - var icons = config.getIcons('android'); - - // if there are icon elements in config.xml - if (icons.length === 0) { - events.emit('verbose', 'This app does not have launcher icons defined'); - return; - } - - this.deleteDefaultResource('icon.png'); - - var android_icons = {}; - var default_icon; - // http://developer.android.com/design/style/iconography.html - var sizeToDensityMap = { - 36: 'ldpi', - 48: 'mdpi', - 72: 'hdpi', - 96: 'xhdpi', - 144: 'xxhdpi', - 192: 'xxxhdpi' - }; - // find the best matching icon for a given density or size - // @output android_icons - var parseIcon = function(icon, icon_size) { - // do I have a platform icon for that density already - var density = icon.density || sizeToDensityMap[icon_size]; - if (!density) { - // invalid icon defition ( or unsupported size) - return; - } - var previous = android_icons[density]; - if (previous && previous.platform) { - return; - } - android_icons[density] = icon; - }; - - // iterate over all icon elements to find the default icon and call parseIcon - for (var i=0; i<icons.length; i++) { - var icon = icons[i]; - var size = icon.width; - if (!size) { - size = icon.height; - } - if (!size && !icon.density) { - if (default_icon) { - events.emit('verbose', 'more than one default icon: ' + JSON.stringify(icon)); - } else { - default_icon = icon; - } - } else { - parseIcon(icon, size); - } - } - var projectRoot = util.isCordova(this.path); - // copy the default icon to the drawable folder - if (default_icon) { - this.copyImage(path.join(projectRoot, default_icon.src), '', 'icon.png'); - } - - for (var density in android_icons) { - this.copyImage(path.join(projectRoot, android_icons[density].src), density, 'icon.png'); - } -}; - -amazon_fireos_parser.prototype.update_from_config = function(config) { - // TODO: share code for this func with Android. Or fix it and remove - // the below JSHint hacks line. - // jshint unused:false, indent:false, undef:true, loopfunc:true, shadow:true - if (config instanceof ConfigParser) { - } else throw new Error('update_from_config requires a ConfigParser object'); - - // Update app name by editing res/values/strings.xml - var name = config.name(); - var strings = xml.parseElementtreeSync(this.strings); - strings.find('string[@name="app_name"]').text = name; - fs.writeFileSync(this.strings, strings.write({indent: 4}), 'utf-8'); - events.emit('verbose', 'Wrote out Android application name to "' + name + '"'); - - this.handleSplashes(config); - this.handleIcons(config); - - var manifest = xml.parseElementtreeSync(this.manifest); - // Update the version by changing the AndroidManifest android:versionName - var version = config.version(); - var versionCode = config.android_versionCode() || default_versionCode(version); - manifest.getroot().attrib['android:versionName'] = version; - manifest.getroot().attrib['android:versionCode'] = versionCode; - - // Update package name by changing the AndroidManifest id and moving the entry class around to the proper package directory - var pkg = config.android_packageName() || config.packageName(); - pkg = pkg.replace(/-/g, '_'); // Java packages cannot support dashes - var orig_pkg = manifest.getroot().attrib.package; - manifest.getroot().attrib.package = pkg; - - var act = manifest.getroot().find('./application/activity'); - - // Set the android:screenOrientation in the AndroidManifest - var orientation = this.helper.getOrientation(config); - - if (orientation && !this.helper.isDefaultOrientation(orientation)) { - act.attrib['android:screenOrientation'] = orientation; - } else { - delete act.attrib['android:screenOrientation']; - } - - // Set android:launchMode in AndroidManifest - var androidLaunchModePref = this.findAndroidLaunchModePreference(config); - if (androidLaunchModePref) { - act.attrib['android:launchMode'] = androidLaunchModePref; - } else { // User has (explicitly) set an invalid value for AndroidLaunchMode preference - delete act.attrib['android:launchMode']; // use Android default value (standard) - } - - // Set min/max/target SDK version - //<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" ... /> - var usesSdk = manifest.getroot().find('./uses-sdk'); - ['minSdkVersion', 'maxSdkVersion', 'targetSdkVersion'].forEach(function(sdkPrefName) { - var sdkPrefValue = config.getPreference('android-' + sdkPrefName, 'android'); - if (!sdkPrefValue) return; - - if (!usesSdk) { // if there is no required uses-sdk element, we should create it first - usesSdk = new et.Element('uses-sdk'); - manifest.getroot().append(usesSdk); - } - usesSdk.attrib['android:' + sdkPrefName] = sdkPrefValue; - }); - - // Write out AndroidManifest.xml - fs.writeFileSync(this.manifest, manifest.write({indent: 4}), 'utf-8'); - - var orig_pkgDir = path.join(this.path, 'src', path.join.apply(null, orig_pkg.split('.'))); - var java_files = fs.readdirSync(orig_pkgDir).filter(function(f) { - return f.indexOf('.svn') == -1 && f.indexOf('.java') >= 0 && fs.readFileSync(path.join(orig_pkgDir, f), 'utf-8').match(/extends\s+CordovaActivity/); - }); - if (java_files.length === 0) { - throw new Error('No Java files found which extend CordovaActivity.'); - } else if(java_files.length > 1) { - events.emit('log', 'Multiple candidate Java files (.java files which extend CordovaActivity) found. Guessing at the first one, ' + java_files[0]); - } - - var orig_java_class = java_files[0]; - var pkgDir = path.join(this.path, 'src', path.join.apply(null, pkg.split('.'))); - shell.mkdir('-p', pkgDir); - var orig_javs = path.join(orig_pkgDir, orig_java_class); - var new_javs = path.join(pkgDir, orig_java_class); - var javs_contents = fs.readFileSync(orig_javs, 'utf-8'); - javs_contents = javs_contents.replace(/package [\w\.]*;/, 'package ' + pkg + ';'); - events.emit('verbose', 'Wrote out Android package name to "' + pkg + '"'); - fs.writeFileSync(new_javs, javs_contents, 'utf-8'); -}; - -// Returns the platform-specific www directory. -amazon_fireos_parser.prototype.www_dir = function() { - return path.join(this.path, 'assets', 'www'); -}; - -amazon_fireos_parser.prototype.config_xml = function(){ - return this.android_config; -}; - -// Used for creating platform_www in projects created by older versions. -amazon_fireos_parser.prototype.cordovajs_path = function(libDir) { - var jsPath = path.join(libDir, 'framework', 'assets', 'www', 'cordova.js'); - return path.resolve(jsPath); -}; - -amazon_fireos_parser.prototype.cordovajs_src_path = function(libDir) { - var jsPath = path.join(libDir, 'cordova-js-src'); - return path.resolve(jsPath); -}; - -// Replace the www dir with contents of platform_www and app www. -amazon_fireos_parser.prototype.update_www = function() { - var projectRoot = util.isCordova(this.path); - var app_www = util.projectWww(projectRoot); - var platform_www = path.join(this.path, 'platform_www'); - - // Clear the www dir - shell.rm('-rf', this.www_dir()); - shell.mkdir(this.www_dir()); - // Copy over all app www assets - shell.cp('-rf', path.join(app_www, '*'), this.www_dir()); - // Copy over stock platform www assets (cordova.js) - shell.cp('-rf', path.join(platform_www, '*'), this.www_dir()); -}; - -// update the overrides folder into the www folder -amazon_fireos_parser.prototype.update_overrides = function() { - var projectRoot = util.isCordova(this.path); - var merges_path = path.join(util.appDir(projectRoot), 'merges', 'amazon-fireos'); - if (fs.existsSync(merges_path)) { - var overrides = path.join(merges_path, '*'); - shell.cp('-rf', overrides, this.www_dir()); - } -}; - -// Returns a promise. -amazon_fireos_parser.prototype.update_project = function(cfg) { - var platformWww = path.join(this.path, 'assets'); - try { - this.update_from_config(cfg); - } catch(e) { - return Q.reject(e); - } - this.update_overrides(); - // delete any .svn folders copied over - util.deleteSvnFolders(platformWww); - return Q(); -}; - - -// Consturct the default value for versionCode as -// PATCH + MINOR * 100 + MAJOR * 10000 -// see http://developer.android.com/tools/publishing/versioning.html -function default_versionCode(version) { - var nums = version.split('-')[0].split('.'); - var versionCode = 0; - if (+nums[0]) { - versionCode += +nums[0] * 10000; - } - if (+nums[1]) { - versionCode += +nums[1] * 100; - } - if (+nums[2]) { - versionCode += +nums[2]; - } - return versionCode; -} http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0d637f2d/cordova-lib/src/cordova/platform.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js index 80a3ebe..fb11625 100644 --- a/cordova-lib/src/cordova/platform.js +++ b/cordova-lib/src/cordova/platform.js @@ -105,13 +105,10 @@ function addHelper(cmd, hooksRunner, projectRoot, targets, opts) { spec = platform; platform = null; } - if(platform === 'amazon-fireos') { - events.emit('warn', 'amazon-fireos has been deprecated. Please use android instead.'); - } + if(platform === 'wp8') { events.emit('warn', 'wp8 has been deprecated. Please use windows instead.'); } - if(fs.existsSync(path.join(projectRoot,'package.json'))) { pkgJson = cordova_util.requireNoCache(path.join(projectRoot, 'package.json')); } http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0d637f2d/cordova-lib/src/platforms/platformsConfig.json ---------------------------------------------------------------------- diff --git a/cordova-lib/src/platforms/platformsConfig.json b/cordova-lib/src/platforms/platformsConfig.json index bc578be..a31acf8 100644 --- a/cordova-lib/src/platforms/platformsConfig.json +++ b/cordova-lib/src/platforms/platformsConfig.json @@ -33,13 +33,6 @@ "version": "~4.3.4", "deprecated": false }, - "amazon-fireos": { - "parser_file": "../cordova/metadata/amazon_fireos_parser", - "handler_file": "../plugman/platforms/amazon-fireos", - "url": "https://git-wip-us.apache.org/repos/asf?p=cordova-amazon-fireos.git", - "version": "~3.6.3", - "deprecated": true - }, "wp8": { "hostos": ["win32"], "parser_file": "../cordova/metadata/wp8_parser", http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0d637f2d/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 deleted file mode 100644 index 6df4d5b..0000000 --- a/cordova-lib/src/plugman/platforms/amazon-fireos.js +++ /dev/null @@ -1,179 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ - -/* jshint laxcomma:true, sub:true */ - -var path = require('path') - , common = require('./common') - , events = require('cordova-common').events - , xml_helpers = require('cordova-common').xmlHelpers - , properties_parser = require('properties-parser') - , android_project = require('../util/android-project') - , CordovaError = require('cordova-common').CordovaError - ; - -var projectFileCache = {}; - -module.exports = { - www_dir:function(project_dir) { - return path.join(project_dir, 'assets', 'www'); - }, - // reads the package name out of the Android Manifest file - // @param string project_dir the absolute path to the directory containing the project - // @return string the name of the package - package_name:function (project_dir) { - var mDoc = xml_helpers.parseElementtreeSync(path.join(project_dir, 'AndroidManifest.xml')); - - return mDoc._root.attrib['package']; - }, - 'source-file':{ - install:function(obj, plugin_dir, project_dir, plugin_id) { - var src = obj.src; - if (!src) { - throw new CordovaError('<source-file> element is missing "src" attribute for plugin: ' + plugin_id); - } - var targetDir = obj.targetDir; - if (!targetDir) { - throw new CordovaError('<source-file> element is missing "target-dir" attribute for plugin: ' + plugin_id); - } - var dest = path.join(targetDir, path.basename(src)); - - common.copyNewFile(plugin_dir, src, project_dir, dest); - }, - uninstall:function(obj, project_dir, plugin_id, options) { - var dest = path.join(obj.targetDir, path.basename(obj.src)); - common.deleteJava(project_dir, dest); - } - }, - 'header-file': { - install:function(obj, plugin_dir, project_dir, plugin_id, options) { - events.emit('verbose', 'header-fileinstall is not supported for amazon-fireos'); - }, - uninstall:function(obj, project_dir, plugin_id, options) { - events.emit('verbose', 'header-file.uninstall is not supported for amazon-fireos'); - } - }, - 'lib-file':{ - install:function(obj, plugin_dir, project_dir, plugin_id, options) { - var src = obj.src; - var dest = path.join('libs', path.basename(src)); - common.copyFile(plugin_dir, src, project_dir, dest); - }, - uninstall:function(obj, project_dir, plugin_id, options) { - var src = obj.src; - var dest = path.join('libs', path.basename(src)); - common.removeFile(project_dir, dest); - } - }, - 'resource-file':{ - install:function(obj, plugin_dir, project_dir, plugin_id, options) { - var src = obj.src; - var target = obj.target; - events.emit('verbose', 'Copying resource file ' + src + ' to ' + target); - common.copyFile(plugin_dir, src, project_dir, target); - }, - uninstall:function(obj, project_dir, plugin_id, options) { - var target = obj.target; - common.removeFile(project_dir, target); - } - }, - 'framework': { - install:function(obj, plugin_dir, project_dir, plugin_id, options) { - var src = obj.src; - var custom = obj.custom; - if (!src) throw new CordovaError('src not specified in <framework> for plugin ' + plugin_id); - - events.emit('verbose', 'Installing Android library: ' + src); - var parent = obj.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 = obj.type; - if (type == 'gradleReference') { - //add reference to build.gradle - projectConfig.addGradleReference(parentDir, subDir); - } else { - projectConfig.addSubProject(parentDir, subDir); - } - }, - uninstall:function(obj, project_dir, plugin_id, options) { - var src = obj.src; - var custom = obj.custom; - if (!src) throw new CordovaError('src not specified in <framework> for plugin: ' + plugin_id); - - events.emit('verbose', 'Uninstalling Android library: ' + src); - var parent = obj.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 = obj.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; - }, - package_suffix: function (project_dir) { - var packageName = module.exports.package_name(project_dir); - var lastDotIndex = packageName.lastIndexOf('.'); - return packageName.substring(lastDotIndex + 1); - } -}; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org