mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 09:02:50 +08:00
CB-11964 Call clean after plugin install and mock it in tests
This commit is contained in:
parent
6418add83d
commit
5db2de95f5
20
bin/templates/cordova/Api.js
vendored
20
bin/templates/cordova/Api.js
vendored
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
var path = require('path');
|
||||
var Q = require('q');
|
||||
|
||||
var AndroidProject = require('./lib/AndroidProject');
|
||||
var AndroidStudio = require('./lib/AndroidStudio');
|
||||
@ -200,6 +201,7 @@ Api.prototype.prepare = function (cordovaProject, prepareOptions) {
|
||||
*/
|
||||
Api.prototype.addPlugin = function (plugin, installOptions) {
|
||||
var project = AndroidProject.getProjectFile(this.root);
|
||||
var self = this;
|
||||
|
||||
installOptions = installOptions || {};
|
||||
installOptions.variables = installOptions.variables || {};
|
||||
@ -212,13 +214,17 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
|
||||
installOptions.android_studio = true;
|
||||
}
|
||||
|
||||
//CB-11964: Do a clean when installing the plugin code to get around
|
||||
//the Gradle bug introduced by the Android Gradle Plugin Version 2.2
|
||||
//TODO: Delete when the next version of Android Gradle plugin comes out
|
||||
|
||||
this.clean();
|
||||
return PluginManager.get(this.platform, this.locations, project)
|
||||
.addPlugin(plugin, installOptions)
|
||||
return Q()
|
||||
.then(function () {
|
||||
//CB-11964: Do a clean when installing the plugin code to get around
|
||||
//the Gradle bug introduced by the Android Gradle Plugin Version 2.2
|
||||
//TODO: Delete when the next version of Android Gradle plugin comes out
|
||||
return self.clean();
|
||||
})
|
||||
.then(function () {
|
||||
return PluginManager.get(self.platform, self.locations, project)
|
||||
.addPlugin(plugin, installOptions);
|
||||
})
|
||||
.then(function () {
|
||||
if (plugin.getFrameworks(this.platform).length === 0) return;
|
||||
|
||||
|
@ -23,6 +23,7 @@ var Q = require('q');
|
||||
var os = require('os');
|
||||
var path = require('path');
|
||||
var common = require('cordova-common');
|
||||
var rewire = require('rewire');
|
||||
|
||||
var AndroidProject = require('../../bin/templates/cordova/lib/AndroidProject');
|
||||
var builders = require('../../bin/templates/cordova/lib/builders/builders');
|
||||
@ -33,7 +34,8 @@ var FIXTURES = path.join(__dirname, '../e2e/fixtures');
|
||||
var FAKE_PROJECT_DIR = path.join(os.tmpdir(), 'plugin-test-project');
|
||||
|
||||
describe('addPlugin method', function () {
|
||||
var api, fail, gradleBuilder;
|
||||
var api, fail, gradleBuilder, oldClean;
|
||||
var Api = rewire('../../bin/templates/cordova/Api');
|
||||
|
||||
beforeEach(function() {
|
||||
var pluginManager = jasmine.createSpyObj('pluginManager', ['addPlugin']);
|
||||
@ -43,7 +45,8 @@ describe('addPlugin method', function () {
|
||||
var projectSpy = jasmine.createSpyObj('AndroidProject', ['getPackageName', 'write']);
|
||||
spyOn(AndroidProject, 'getProjectFile').andReturn(projectSpy);
|
||||
|
||||
var Api = require('../../bin/templates/cordova/Api');
|
||||
oldClean = Api.__get__('Api.prototype.clean');
|
||||
Api.__set__('Api.prototype.clean', Q);
|
||||
api = new Api('android', FAKE_PROJECT_DIR);
|
||||
|
||||
fail = jasmine.createSpy('fail');
|
||||
@ -51,6 +54,10 @@ describe('addPlugin method', function () {
|
||||
spyOn(builders, 'getBuilder').andReturn(gradleBuilder);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
Api.__set__('Api.prototype.clean', oldClean);
|
||||
});
|
||||
|
||||
it('should call gradleBuilder.prepBuildFiles for every plugin with frameworks', function(done) {
|
||||
api.addPlugin(new PluginInfo(path.join(FIXTURES, 'cordova-plugin-fake')))
|
||||
.catch(fail)
|
||||
|
Loading…
Reference in New Issue
Block a user