forked from github/cordova-android
Finishing the linting
This commit is contained in:
parent
e456175a81
commit
a7304b9a19
@ -48,8 +48,9 @@ function copyJsAndLibrary(projectPath, shared, projectName, isLegacy) {
|
||||
var srcCordovaJsPath = path.join(ROOT, 'bin', 'templates', 'project', 'assets', 'www', 'cordova.js');
|
||||
var app_path = path.join(projectPath, 'app', 'src', 'main');
|
||||
|
||||
if(isLegacy)
|
||||
if (isLegacy) {
|
||||
app_path = projectPath;
|
||||
}
|
||||
|
||||
shell.cp('-f', srcCordovaJsPath, path.join(app_path, 'assets', 'www', 'cordova.js'));
|
||||
|
||||
|
3
bin/templates/cordova/Api.js
vendored
3
bin/templates/cordova/Api.js
vendored
@ -335,8 +335,9 @@ Api.prototype.removePlugin = function (plugin, uninstallOptions) {
|
||||
*/
|
||||
Api.prototype.build = function (buildOptions) {
|
||||
var self = this;
|
||||
if(this.android_studio)
|
||||
if (this.android_studio) {
|
||||
buildOptions.studio = true;
|
||||
}
|
||||
return require('./lib/check_reqs').run().then(function () {
|
||||
return require('./lib/build').run.call(self, buildOptions);
|
||||
}).then(function (buildResults) {
|
||||
|
3
bin/templates/cordova/lib/build.js
vendored
3
bin/templates/cordova/lib/build.js
vendored
@ -55,8 +55,9 @@ function parseOpts (options, resolvedTarget, projectRoot) {
|
||||
extraArgs: []
|
||||
};
|
||||
|
||||
if (options.argv.gradle || options.argv.studio)
|
||||
if (options.argv.gradle || options.argv.studio) {
|
||||
ret.buildMethod = options.argv.studio ? 'studio' : 'gradle';
|
||||
}
|
||||
|
||||
// This comes from cordova/run
|
||||
if (options.studio) ret.buildMethod = 'studio';
|
||||
|
@ -49,7 +49,6 @@ GenericBuilder.prototype.clean = function () {
|
||||
GenericBuilder.prototype.findOutputApks = function (build_type, arch) {
|
||||
var self = this;
|
||||
return Object.keys(this.binDirs).reduce(function (result, builderName) {
|
||||
console.log('builderName:'+ builderName);
|
||||
var binDir = self.binDirs[builderName];
|
||||
return result.concat(findOutputApksHelper(binDir, build_type, builderName === 'ant' ? null : arch));
|
||||
}, []).sort(apkSorter);
|
||||
|
@ -114,7 +114,6 @@ GradleBuilder.prototype.extractRealProjectNameFromManifest = function () {
|
||||
return packageName.substring(lastDotIndex + 1);
|
||||
};
|
||||
|
||||
|
||||
// Makes the project buildable, minus the gradle wrapper.
|
||||
GradleBuilder.prototype.prepBuildFiles = function () {
|
||||
// Update the version of build.gradle in each dependent library.
|
||||
@ -143,7 +142,6 @@ GradleBuilder.prototype.prepBuildFiles = function () {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var name = this.extractRealProjectNameFromManifest();
|
||||
// Remove the proj.id/name- prefix from projects: https://issues.apache.org/jira/browse/CB-9149
|
||||
var settingsGradlePaths = subProjects.map(function (p) {
|
||||
@ -163,14 +161,13 @@ GradleBuilder.prototype.prepBuildFiles = function () {
|
||||
var depsList = '';
|
||||
var root = this.root;
|
||||
|
||||
|
||||
// Cordova Plugins can be written as library modules that would use Cordova as a
|
||||
// dependency. Because we need to make sure that Cordova is compiled only once for
|
||||
// dexing, we make sure to exclude CordovaLib from these modules
|
||||
var insertExclude = function (p) {
|
||||
var gradlePath = path.join(root, p, 'build.gradle');
|
||||
var projectGradleFile = fs.readFileSync(gradlePath, 'utf-8');
|
||||
if(projectGradleFile.indexOf('CordovaLib') != -1) {
|
||||
if (projectGradleFile.indexOf('CordovaLib') !== -1) {
|
||||
depsList += '{\n exclude module:("CordovaLib")\n }\n';
|
||||
} else {
|
||||
depsList += '\n';
|
||||
@ -186,7 +183,6 @@ GradleBuilder.prototype.prepBuildFiles = function () {
|
||||
insertExclude(p);
|
||||
});
|
||||
|
||||
|
||||
// For why we do this mapping: https://issues.apache.org/jira/browse/CB-8390
|
||||
var SYSTEM_LIBRARY_MAPPINGS = [
|
||||
[/^\/?extras\/android\/support\/(.*)$/, 'com.android.support:support-$1:+'],
|
||||
|
@ -43,9 +43,9 @@ function StudioBuilder (projectRoot) {
|
||||
util.inherits(StudioBuilder, GenericBuilder);
|
||||
|
||||
StudioBuilder.prototype.getArgs = function (cmd, opts) {
|
||||
if (cmd == 'release') {
|
||||
if (cmd === 'release') {
|
||||
cmd = 'cdvBuildRelease';
|
||||
} else if (cmd == 'debug') {
|
||||
} else if (cmd === 'debug') {
|
||||
cmd = 'cdvBuildDebug';
|
||||
}
|
||||
var args = [cmd, '-b', path.join(this.root, 'build.gradle')];
|
||||
@ -79,7 +79,6 @@ StudioBuilder.prototype.runGradleWrapper = function(gradle_cmd) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
StudioBuilder.prototype.readProjectProperties = function () {
|
||||
|
||||
function findAllUniq (data, r) {
|
||||
@ -112,8 +111,6 @@ StudioBuilder.prototype.extractRealProjectNameFromManifest = function () {
|
||||
return packageName.substring(lastDotIndex + 1);
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Makes the project buildable, minus the gradle wrapper.
|
||||
StudioBuilder.prototype.prepBuildFiles = function () {
|
||||
// Update the version of build.gradle in each dependent library.
|
||||
@ -141,12 +138,12 @@ StudioBuilder.prototype.prepBuildFiles = function() {
|
||||
var realDir = p.replace(/[/\\]/g, ':');
|
||||
var libName = realDir.replace(name + '-', '');
|
||||
var str = 'include ":' + libName + '"\n';
|
||||
if(realDir.indexOf(name+'-')!==-1)
|
||||
if (realDir.indexOf(name + '-') !== -1) {
|
||||
str += 'project(":' + libName + '").projectDir = new File("' + p + '")\n';
|
||||
}
|
||||
return str;
|
||||
});
|
||||
|
||||
|
||||
fs.writeFileSync(path.join(this.root, 'settings.gradle'),
|
||||
'// GENERATED FILE - DO NOT EDIT\n' +
|
||||
'include ":"\n' + settingsGradlePaths.join(''));
|
||||
@ -158,10 +155,9 @@ StudioBuilder.prototype.prepBuildFiles = function() {
|
||||
var insertExclude = function (p) {
|
||||
var gradlePath = path.join(root, p, 'build.gradle');
|
||||
var projectGradleFile = fs.readFileSync(gradlePath, 'utf-8');
|
||||
if(projectGradleFile.indexOf('CordovaLib') != -1) {
|
||||
if (projectGradleFile.indexOf('CordovaLib') !== -1) {
|
||||
depsList += '{\n exclude module:("CordovaLib")\n }\n';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
depsList += '\n';
|
||||
}
|
||||
};
|
||||
@ -218,9 +214,7 @@ StudioBuilder.prototype.prepEnv = function(opts) {
|
||||
// If it's not set, do nothing, assuming that we're using a future version of gradle that we don't want to mess with.
|
||||
// For some reason, using ^ and $ don't work. This does the job, though.
|
||||
var distributionUrlRegex = /distributionUrl.*zip/;
|
||||
/*jshint -W069 */
|
||||
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-3.3-all.zip';
|
||||
/*jshint +W069 */
|
||||
var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties');
|
||||
shell.chmod('u+w', gradleWrapperPropertiesPath);
|
||||
shell.sed('-i', distributionUrlRegex, 'distributionUrl=' + distributionUrl, gradleWrapperPropertiesPath);
|
||||
@ -241,7 +235,7 @@ StudioBuilder.prototype.prepEnv = function(opts) {
|
||||
*/
|
||||
StudioBuilder.prototype.build = function (opts) {
|
||||
var wrapper = path.join(this.root, 'gradlew');
|
||||
var args = this.getArgs(opts.buildType == 'debug' ? 'debug' : 'release', opts);
|
||||
var args = this.getArgs(opts.buildType === 'debug' ? 'debug' : 'release', opts);
|
||||
|
||||
return spawn(wrapper, args, {stdio: 'pipe'})
|
||||
.progress(function (stdio) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user