From c386f2d1d09951a5fcd62b94eb2c392cc40a5b8b Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 21 Jan 2019 09:34:02 -0500 Subject: [PATCH 1/2] Quick fix to use SDK versions from AndroidManifest --- .../cordova/lib/builders/ProjectBuilder.js | 47 ++++++++++++-- bin/templates/project/app/build.gradle | 10 +++ bin/templates/project/build.gradle | 6 +- spec/unit/builders/ProjectBuilder.spec.js | 64 ++++++++++++++++--- 4 files changed, 110 insertions(+), 17 deletions(-) diff --git a/bin/templates/cordova/lib/builders/ProjectBuilder.js b/bin/templates/cordova/lib/builders/ProjectBuilder.js index c5ad00d34a..dd1e58ebd7 100644 --- a/bin/templates/cordova/lib/builders/ProjectBuilder.js +++ b/bin/templates/cordova/lib/builders/ProjectBuilder.js @@ -89,7 +89,7 @@ class ProjectBuilder { }; } - extractRealProjectNameFromManifest () { + getAndroidManifestInfo () { var manifestPath = path.join(this.root, 'app', 'src', 'main', 'AndroidManifest.xml'); var manifestData = fs.readFileSync(manifestPath, 'utf8'); var m = / { }); }); - describe('extractRealProjectNameFromManifest', () => { + describe('getAndroidManifestInfo', () => { it('should get the project name from the Android Manifest', () => { const projectName = 'unittestproject'; const projectId = `io.cordova.${projectName}`; - const manifest = ` - `; + const manifest = + ` + + + `; spyOn(fs, 'readFileSync').and.returnValue(manifest); - expect(builder.extractRealProjectNameFromManifest()).toBe(projectName); + expect(builder.getAndroidManifestInfo().packageName).toBe(projectId); + }); + + it('should get the min & target SDK versions from the Android Manifest', () => { + const projectName = 'unittestproject'; + const projectId = `io.cordova.${projectName}`; + const manifest = + ` + + + `; + + spyOn(fs, 'readFileSync').and.returnValue(manifest); + + expect(builder.getAndroidManifestInfo().minSdkVersion).toBe(22); + expect(builder.getAndroidManifestInfo().targetSdkVersion).toBe(25); }); it('should throw an error if there is no package in the Android manifest', () => { - const manifest = ` - `; + const manifest = + ` + + + `; + + spyOn(fs, 'readFileSync').and.returnValue(manifest); + + expect(() => builder.getAndroidManifestInfo()).toThrow(jasmine.any(CordovaError)); + }); + + it('should throw an error if there is no android:minSdkVersion in the Android manifest', () => { + const projectName = 'unittestproject'; + const projectId = `io.cordova.${projectName}`; + const manifest = + ` + + + `; + + spyOn(fs, 'readFileSync').and.returnValue(manifest); + + expect(() => builder.getAndroidManifestInfo()).toThrow(jasmine.any(CordovaError)); + }); + + it('should throw an error if there is no android:targetSdkVersion in the Android manifest', () => { + const projectName = 'unittestproject'; + const projectId = `io.cordova.${projectName}`; + const manifest = + ` + + + `; spyOn(fs, 'readFileSync').and.returnValue(manifest); - expect(() => builder.extractRealProjectNameFromManifest()).toThrow(jasmine.any(CordovaError)); + expect(() => builder.getAndroidManifestInfo()).toThrow(jasmine.any(CordovaError)); }); }); From dec5926a3f072b0258dc013e8f16df8fc272fe7f Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 23 Jan 2019 22:59:37 -0500 Subject: [PATCH 2/2] empty commit to retrigger build