mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
Improve Gradle Build Arguments (#699)
* Remove `uses-sdk` from AndroidManifest * Remove dependency `elementtree` * Updated Build Command Help Menu Printout * Cleanup `minSdkVersion` printout * Added `maxSdkVersion`, but not recommended to set. * Added `targetSdkVersion` * Update the `GradlePropertiesParser` & Test Spec * Always Set Overriding Changes * Update existing properties * Update configure method
This commit is contained in:
@@ -29,9 +29,6 @@ describe('AndroidManifest', () => {
|
||||
const ACTIVITY_LAUNCH_MODE = 'singleTop';
|
||||
const ACTIVITY_NAME = 'MainActivity';
|
||||
const ACTIVITY_ORIENTATION = 'portrait';
|
||||
const MIN_SDK_VERSION = '12';
|
||||
const MAX_SDK_VERSION = '88';
|
||||
const TARGET_SDK_VERSION = '27';
|
||||
|
||||
const DEFAULT_MANIFEST = `<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest android:hardwareAccelerated="true" android:versionCode="${VERSION_CODE}" android:versionName="${VERSION_NAME}"
|
||||
@@ -51,7 +48,6 @@ describe('AndroidManifest', () => {
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="${MIN_SDK_VERSION}" android:maxSdkVersion="${MAX_SDK_VERSION}" android:targetSdkVersion="${TARGET_SDK_VERSION}" />
|
||||
</manifest>`;
|
||||
|
||||
const manifestPath = path.join(os.tmpdir(), `AndroidManifest${Date.now()}.xml`);
|
||||
@@ -190,78 +186,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);
|
||||
|
||||
Reference in New Issue
Block a user