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