Skip to content

Commit

Permalink
Merge pull request #461 from Menardi/refactor_builders_with_tests
Browse files Browse the repository at this point in the history
Remove old builders code
  • Loading branch information
raphinesse committed Jul 21, 2018
2 parents b6e4598 + 4b0725d commit ebbd91f
Show file tree
Hide file tree
Showing 13 changed files with 746 additions and 869 deletions.
45 changes: 7 additions & 38 deletions bin/templates/cordova/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ var path = require('path');
var Q = require('q');

var AndroidProject = require('./lib/AndroidProject');
var AndroidStudio = require('./lib/AndroidStudio');
var PluginManager = require('cordova-common').PluginManager;

var CordovaLogger = require('cordova-common').CordovaLogger;
Expand Down Expand Up @@ -56,41 +55,27 @@ function setupEvents (externalEventEmitter) {
function Api (platform, platformRootDir, events) {
this.platform = PLATFORM;
this.root = path.resolve(__dirname, '..');
this.builder = 'gradle';
this.builder = 'studio';

setupEvents(events);

var self = this;

this.locations = {
root: self.root,
www: path.join(self.root, 'assets/www'),
res: path.join(self.root, 'res'),
www: path.join(self.root, 'app/src/main/assets/www'),
res: path.join(self.root, 'app/src/main/res'),
platformWww: path.join(self.root, 'platform_www'),
configXml: path.join(self.root, 'res/xml/config.xml'),
configXml: path.join(self.root, 'app/src/main/res/xml/config.xml'),
defaultConfigXml: path.join(self.root, 'cordova/defaults.xml'),
strings: path.join(self.root, 'res/values/strings.xml'),
manifest: path.join(self.root, 'AndroidManifest.xml'),
strings: path.join(self.root, 'app/src/main/res/values/strings.xml'),
manifest: path.join(self.root, 'app/src/main/AndroidManifest.xml'),
build: path.join(self.root, 'build'),
javaSrc: path.join(self.root, 'src'),
javaSrc: path.join(self.root, 'app/src/main/java/'),
// NOTE: Due to platformApi spec we need to return relative paths here
cordovaJs: 'bin/templates/project/assets/www/cordova.js',
cordovaJsSrc: 'cordova-js-src'
};

// XXX Override some locations for Android Studio projects
if (AndroidStudio.isAndroidStudioProject(self.root) === true) {
selfEvents.emit('log', 'Android Studio project detected');
this.builder = 'studio';
this.android_studio = true;
this.locations.configXml = path.join(self.root, 'app/src/main/res/xml/config.xml');
this.locations.strings = path.join(self.root, 'app/src/main/res/values/strings.xml');
this.locations.manifest = path.join(self.root, 'app/src/main/AndroidManifest.xml');
// We could have Java Source, we could have other languages
this.locations.javaSrc = path.join(self.root, 'app/src/main/java/');
this.locations.www = path.join(self.root, 'app/src/main/assets/www');
this.locations.res = path.join(self.root, 'app/src/main/res');
}
}

/**
Expand Down Expand Up @@ -228,22 +213,6 @@ Api.prototype.addPlugin = function (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
// Since clean doesn't just clean the build, it also wipes out www, we need
// to pass additional options.

// Do some basic argument parsing
var opts = {};

// Skip cleaning prepared files when not invoking via cordova CLI.
opts.noPrepare = true;

if (!AndroidStudio.isAndroidStudioProject(self.root) && !project.isClean()) {
return self.clean(opts);
}
}).then(function () {
return PluginManager.get(self.platform, self.locations, project).addPlugin(plugin, installOptions);
}).then(function () {
if (plugin.getFrameworks(this.platform).length === 0) return;
Expand Down
11 changes: 2 additions & 9 deletions bin/templates/cordova/lib/AndroidProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ var fs = require('fs');
var path = require('path');
var properties_parser = require('properties-parser');
var AndroidManifest = require('./AndroidManifest');
var AndroidStudio = require('./AndroidStudio');
var pluginHandlers = require('./pluginHandlers');

var projectFileCache = {};
Expand Down Expand Up @@ -62,10 +61,7 @@ function AndroidProject (projectDir) {
this._dirty = false;
this.projectDir = projectDir;
this.platformWww = path.join(this.projectDir, 'platform_www');
this.www = path.join(this.projectDir, 'assets/www');
if (AndroidStudio.isAndroidStudioProject(projectDir) === true) {
this.www = path.join(this.projectDir, 'app/src/main/assets/www');
}
this.www = path.join(this.projectDir, 'app/src/main/assets/www');
}

AndroidProject.getProjectFile = function (projectDir) {
Expand All @@ -92,10 +88,7 @@ AndroidProject.purgeCache = function (projectDir) {
* @return {String} The name of the package
*/
AndroidProject.prototype.getPackageName = function () {
var manifestPath = path.join(this.projectDir, 'AndroidManifest.xml');
if (AndroidStudio.isAndroidStudioProject(this.projectDir) === true) {
manifestPath = path.join(this.projectDir, 'app/src/main/AndroidManifest.xml');
}
var manifestPath = path.join(this.projectDir, 'app/src/main/AndroidManifest.xml');
return new AndroidManifest(manifestPath).getPackageId();
};

Expand Down
9 changes: 0 additions & 9 deletions bin/templates/cordova/lib/AndroidStudio.js

This file was deleted.

122 changes: 0 additions & 122 deletions bin/templates/cordova/lib/builders/GenericBuilder.js

This file was deleted.

Loading

0 comments on commit ebbd91f

Please sign in to comment.