feat!: unify & fix gradle library/tooling overrides (#1212)

* enhancement: Control SDK versions and other default projects in one place
* fix: target/compile sdk usage
* refactor: cleanup gradle process
* chore: cleanup and remove unused changes
* chore: remove more unneeded FILE_PATH
* chore: fix lint error
* revert change intended to be part of a different PR
* chore: apply changes to revert to fit new changes
* fix: Ensure proper types
* breaking: Removed TempateFile class
  * Replaced the one and only usage of it with the properties-parser editor.
  * Breaking change because we are converting a method into an asynchronous method.
* refactor: Use the sync version of properties editor
* Gh 1178 fix sdk use gradlearg fix (#2)
* fix: readd gradleArg support
* fix: variable name
* refactor: remove unused mock variables
* Update bin/templates/cordova/lib/builders/ProjectBuilder.js
* Update bin/lib/create.js
* fix: const naming (review suggestion)
* fix: use defaults for framework building
* chore: apply review suggestion
* chore: rename config.json & defaults.json (review suggestions)
* refactor: updateUserProjectGradleConfig method
* refactor: minor changes in updateUserProjectGradleConfig
* refactor: major changes in updateUserProjectGradleConfig
* fix: wrong handling of missing preferences
* fix: usage of undefined this
* fix(create.spec): mocking of getPreference
* test(check_reqs): reduce diff size
* refactor: add wrapper to load gradle config defaults
* fix(check_reqs): get_target
  * Reads default SDK from default gradle config now
* fix(check_reqs.spec): return correct types from mocks
* revert to using get_target in create
* fix: e2e test

Co-authored-by: Erisu <ellis.bryan@gmail.com>
Co-authored-by: Raphael von der Grün <raphinesse@gmail.com>
This commit is contained in:
Norman Breau
2021-07-06 03:38:28 -03:00
committed by GitHub
parent 47aa116b1d
commit 510596f515
22 changed files with 268 additions and 254 deletions
+7 -37
View File
@@ -281,30 +281,15 @@ describe('check_reqs', function () {
check_reqs.__set__('ConfigParser', ConfigParser);
});
it('should retrieve target from framework project.properties file', function () {
it('should retrieve DEFAULT_TARGET_API', function () {
var target = check_reqs.get_target();
expect(target).toBeDefined();
expect(target).toContain('android-' + DEFAULT_TARGET_API);
});
it('should throw error if target cannot be found', function () {
spyOn(fs, 'existsSync').and.returnValue(false);
expect(function () {
check_reqs.get_target();
}).toThrow();
});
it('should override target from config.xml preference', () => {
var realExistsSync = fs.existsSync;
spyOn(fs, 'existsSync').and.callFake(function (path) {
if (path.indexOf('config.xml') > -1) {
return true;
} else {
return realExistsSync.call(fs, path);
}
});
getPreferenceSpy.and.returnValue(DEFAULT_TARGET_API + 1);
spyOn(fs, 'existsSync').and.returnValue(true);
getPreferenceSpy.and.returnValue(String(DEFAULT_TARGET_API + 1));
var target = check_reqs.get_target();
@@ -313,16 +298,8 @@ describe('check_reqs', function () {
});
it('should fallback to default target if config.xml has invalid preference', () => {
var realExistsSync = fs.existsSync;
spyOn(fs, 'existsSync').and.callFake(function (path) {
if (path.indexOf('config.xml') > -1) {
return true;
} else {
return realExistsSync.call(fs, path);
}
});
getPreferenceSpy.and.returnValue(NaN);
spyOn(fs, 'existsSync').and.returnValue(true);
getPreferenceSpy.and.returnValue('android-99');
var target = check_reqs.get_target();
@@ -331,18 +308,11 @@ describe('check_reqs', function () {
});
it('should warn if target sdk preference is lower than the minimum required target SDK', () => {
var realExistsSync = fs.existsSync;
spyOn(fs, 'existsSync').and.callFake(function (path) {
if (path.indexOf('config.xml') > -1) {
return true;
} else {
return realExistsSync.call(fs, path);
}
});
spyOn(fs, 'existsSync').and.returnValue(true);
spyOn(events, 'emit');
getPreferenceSpy.and.returnValue(DEFAULT_TARGET_API - 1);
getPreferenceSpy.and.returnValue(String(DEFAULT_TARGET_API - 1));
var target = check_reqs.get_target();
+1
View File
@@ -809,6 +809,7 @@ describe('prepare', () => {
prepare.__set__('events', {
emit: jasmine.createSpy('emit')
});
prepare.__set__('updateUserProjectGradleConfig', jasmine.createSpy());
prepare.__set__('updateWww', jasmine.createSpy());
prepare.__set__('updateProjectAccordingTo', jasmine.createSpy('updateProjectAccordingTo')
.and.returnValue(Promise.resolve()));