You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2019/02/12 16:22:55 UTC
[cordova-android] branch master updated: Remove uses-sdk from
AndroidManifest.xml (#664)
This is an automated email from the ASF dual-hosted git repository.
brodybits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-android.git
The following commit(s) were added to refs/heads/master by this push:
new bb45f4f Remove uses-sdk from AndroidManifest.xml (#664)
bb45f4f is described below
commit bb45f4f3ba920c06ab907cd10116095915801fe6
Author: Chris Brody <ch...@gmail.com>
AuthorDate: Tue Feb 12 11:22:49 2019 -0500
Remove uses-sdk from AndroidManifest.xml (#664)
* Remove uses-sdk from AndroidManifest.xml
since uses-sdk values are now superseded by Gradle files
* remove elementtree no longer needed
* remove internal capitalize function no longer needed
* remove AndroidManifest SDK version tests no longer needed
resolves #629
---
bin/lib/create.js | 1 -
bin/templates/cordova/lib/AndroidManifest.js | 30 ------------
bin/templates/cordova/lib/prepare.js | 3 --
package.json | 1 -
spec/unit/AndroidManifest.spec.js | 72 ----------------------------
5 files changed, 107 deletions(-)
diff --git a/bin/lib/create.js b/bin/lib/create.js
index d6451a7..3f5bcb1 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -321,7 +321,6 @@ exports.create = function (project_path, config, options, events) {
var manifest = new AndroidManifest(path.join(project_template_dir, 'AndroidManifest.xml'));
manifest.setPackageId(package_name)
- .setTargetSdkVersion(target_api.split('-')[1])
.getActivity().setName(safe_activity_name);
var manifest_path = path.join(app_path, 'AndroidManifest.xml');
diff --git a/bin/templates/cordova/lib/AndroidManifest.js b/bin/templates/cordova/lib/AndroidManifest.js
index 4fe1c2b..a4489f1 100644
--- a/bin/templates/cordova/lib/AndroidManifest.js
+++ b/bin/templates/cordova/lib/AndroidManifest.js
@@ -18,7 +18,6 @@
*/
var fs = require('fs');
-var et = require('elementtree');
var xml = require('cordova-common').xmlHelpers;
var DEFAULT_ORIENTATION = 'default';
@@ -98,31 +97,6 @@ AndroidManifest.prototype.getActivity = function () {
};
};
-['minSdkVersion', 'maxSdkVersion', 'targetSdkVersion'].forEach(function (sdkPrefName) {
- // Copy variable reference to avoid closure issues
- var prefName = sdkPrefName;
-
- AndroidManifest.prototype['get' + capitalize(prefName)] = function () {
- var usesSdk = this.doc.getroot().find('./uses-sdk');
- return usesSdk && usesSdk.attrib['android:' + prefName];
- };
-
- AndroidManifest.prototype['set' + capitalize(prefName)] = function (prefValue) {
- var usesSdk = this.doc.getroot().find('./uses-sdk');
-
- if (!usesSdk && prefValue) { // if there is no required uses-sdk element, we should create it first
- usesSdk = new et.Element('uses-sdk');
- this.doc.getroot().append(usesSdk);
- }
-
- if (prefValue) {
- usesSdk.attrib['android:' + prefName] = prefValue;
- }
-
- return this;
- };
-});
-
AndroidManifest.prototype.getDebuggable = function () {
return this.doc.getroot().find('./application').attrib['android:debuggable'] === 'true';
};
@@ -150,7 +124,3 @@ AndroidManifest.prototype.write = function (destPath) {
};
module.exports = AndroidManifest;
-
-function capitalize (str) {
- return str.charAt(0).toUpperCase() + str.slice(1);
-}
diff --git a/bin/templates/cordova/lib/prepare.js b/bin/templates/cordova/lib/prepare.js
index 2eb0888..fcf5a95 100644
--- a/bin/templates/cordova/lib/prepare.js
+++ b/bin/templates/cordova/lib/prepare.js
@@ -199,9 +199,6 @@ function updateProjectAccordingTo (platformConfig, locations) {
manifest.setVersionName(platformConfig.version())
.setVersionCode(platformConfig.android_versionCode() || default_versionCode(platformConfig.version()))
.setPackageId(androidPkgName)
- .setMinSdkVersion(platformConfig.getPreference('android-minSdkVersion', 'android'))
- .setMaxSdkVersion(platformConfig.getPreference('android-maxSdkVersion', 'android'))
- .setTargetSdkVersion(platformConfig.getPreference('android-targetSdkVersion', 'android'))
.write();
// Java file paths shouldn't be hard coded
diff --git a/package.json b/package.json
index 4e7051f..e0bdffa 100644
--- a/package.json
+++ b/package.json
@@ -31,7 +31,6 @@
"dependencies": {
"android-versions": "^1.3.0",
"cordova-common": "^3.1.0",
- "elementtree": "^0.1.7",
"nopt": "^4.0.1",
"properties-parser": "^0.3.1",
"q": "^1.4.1",
diff --git a/spec/unit/AndroidManifest.spec.js b/spec/unit/AndroidManifest.spec.js
index 84c577b..692f685 100644
--- a/spec/unit/AndroidManifest.spec.js
+++ b/spec/unit/AndroidManifest.spec.js
@@ -190,78 +190,6 @@ describe('AndroidManifest', () => {
});
});
- describe('minSdkVersion', () => {
- it('should get minSdkVersion', () => {
- expect(manifest.getMinSdkVersion()).toBe(MIN_SDK_VERSION);
- });
-
- it('should set minSdkVersion', () => {
- const newMinSdkVersion = `${MIN_SDK_VERSION}111`;
- manifest.setMinSdkVersion(newMinSdkVersion);
- expect(manifest.getMinSdkVersion()).toBe(newMinSdkVersion);
- });
-
- it('should create the uses-sdk node if it does not exist when setting minSdkVersion', () => {
- const root = manifest.doc.getroot();
- root.remove(root.find('./uses-sdk'));
-
- expect(root.find('./uses-sdk')).toBe(null);
-
- manifest.setMinSdkVersion(1);
-
- expect(root.find('./uses-sdk')).not.toBe(null);
- expect(manifest.getMinSdkVersion()).toBe(1);
- });
- });
-
- describe('maxSdkVersion', () => {
- it('should get maxSdkVersion', () => {
- expect(manifest.getMaxSdkVersion()).toBe(MAX_SDK_VERSION);
- });
-
- it('should set maxSdkVersion', () => {
- const newMaxSdkVersion = `${MAX_SDK_VERSION}999`;
- manifest.setMaxSdkVersion(newMaxSdkVersion);
- expect(manifest.getMaxSdkVersion()).toBe(newMaxSdkVersion);
- });
-
- it('should create the uses-sdk node if it does not exist when setting maxSdkVersion', () => {
- const root = manifest.doc.getroot();
- root.remove(root.find('./uses-sdk'));
-
- expect(root.find('./uses-sdk')).toBe(null);
-
- manifest.setMaxSdkVersion(1);
-
- expect(root.find('./uses-sdk')).not.toBe(null);
- expect(manifest.getMaxSdkVersion()).toBe(1);
- });
- });
-
- describe('targetSdkVersion', () => {
- it('should get targetSdkVersion', () => {
- expect(manifest.getTargetSdkVersion()).toBe(TARGET_SDK_VERSION);
- });
-
- it('should set targetSdkVersion', () => {
- const newTargetSdkVersion = `${TARGET_SDK_VERSION}555`;
- manifest.setTargetSdkVersion(newTargetSdkVersion);
- expect(manifest.getTargetSdkVersion()).toBe(newTargetSdkVersion);
- });
-
- it('should create the uses-sdk node if it does not exist when setting targetSdkVersion', () => {
- const root = manifest.doc.getroot();
- root.remove(root.find('./uses-sdk'));
-
- expect(root.find('./uses-sdk')).toBe(null);
-
- manifest.setTargetSdkVersion(1);
-
- expect(root.find('./uses-sdk')).not.toBe(null);
- expect(manifest.getTargetSdkVersion()).toBe(1);
- });
- });
-
describe('debuggable', () => {
it('should get debuggable', () => {
expect(manifest.getDebuggable()).toBe(true);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org