mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
CB-12169: Check for build directory before running a clean
This commit is contained in:
parent
e856613787
commit
c2ddd2da7f
6
bin/templates/cordova/Api.js
vendored
6
bin/templates/cordova/Api.js
vendored
@ -72,6 +72,7 @@ function Api(platform, platformRootDir, events) {
|
||||
defaultConfigXml: path.join(self.root, 'cordova/defaults.xml'),
|
||||
strings: path.join(self.root, 'res/values/strings.xml'),
|
||||
manifest: path.join(self.root, 'AndroidManifest.xml'),
|
||||
build: path.join(self.root, 'build'),
|
||||
// NOTE: Due to platformApi spec we need to return relative paths here
|
||||
cordovaJs: 'bin/templates/project/assets/www/cordova.js',
|
||||
cordovaJsSrc: 'cordova-js-src'
|
||||
@ -244,8 +245,9 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
|
||||
// Skip cleaning prepared files when not invoking via cordova CLI.
|
||||
opts.noPrepare = true;
|
||||
|
||||
if(!(AndroidStudio.isAndroidStudioProject(self.root)))
|
||||
if(!AndroidStudio.isAndroidStudioProject(self.root) && !project.isClean()) {
|
||||
return self.clean(opts);
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
return PluginManager.get(self.platform, self.locations, project)
|
||||
@ -396,6 +398,8 @@ Api.prototype.clean = function(cleanOptions) {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Performs a requirements check for current platform. Each platform defines its
|
||||
* own set of requirements, which should be resolved before platform can be
|
||||
|
9
bin/templates/cordova/lib/AndroidProject.js
vendored
9
bin/templates/cordova/lib/AndroidProject.js
vendored
@ -197,5 +197,14 @@ AndroidProject.prototype.getUninstaller = function (type) {
|
||||
return pluginHandlers.getUninstaller(type);
|
||||
};
|
||||
|
||||
/*
|
||||
* This checks if an Android project is clean or has old build artifacts
|
||||
*/
|
||||
|
||||
AndroidProject.prototype.isClean = function() {
|
||||
var build_path = path.join(this.projectDir, "build");
|
||||
//If the build directory doesn't exist, it's clean
|
||||
return !(fs.existsSync(build_path));
|
||||
};
|
||||
|
||||
module.exports = AndroidProject;
|
||||
|
Loading…
Reference in New Issue
Block a user