Skip to content

Commit 16d7174

Browse files
committed
apply PR #2452 based to master
1 parent 2e373d4 commit 16d7174

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

lib/definitions/project.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ interface IPlatformProjectService {
215215
* @returns {void}
216216
*/
217217
stopServices(): Promise<ISpawnResult>;
218+
219+
/**
220+
* Removes build artifacts specific to the platform
221+
* @returns {void}
222+
*/
223+
cleanProject(projectRoot: string, options: string[]): Promise<void>
218224
}
219225

220226
interface IAndroidProjectPropertiesManager {

lib/services/android-project-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
405405
return this.$childProcess.spawnFromEvent(gradleBin, ["--stop", "--quiet"], "close", { stdio: "inherit", cwd: projectRoot });
406406
}
407407

408-
private async cleanProject(projectRoot: string, options: string[]): Promise<void> {
408+
public async cleanProject(projectRoot: string, options: string[]): Promise<void> {
409409
options.unshift("clean");
410410

411411
let gradleBin = path.join(projectRoot, "gradlew");

lib/services/ios-project-service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,10 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
636636
return Promise.resolve({stderr: "", stdout: "", exitCode: 0});
637637
}
638638

639+
public async cleanProject(projectRoot: string, options: string[]): Promise<void> {
640+
return Promise.resolve();
641+
}
642+
639643
private async mergeInfoPlists(): Promise<void> {
640644
let projectDir = this.$projectData.projectDir;
641645
let infoPlistPath = this.$options.baseConfig || path.join(projectDir, constants.APP_FOLDER_NAME, constants.APP_RESOURCES_FOLDER_NAME, this.platformData.normalizedPlatformName, this.platformData.configurationFileName);

lib/services/platform-service.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ export class PlatformService implements IPlatformService {
216216
this.$logger.trace("Changes info in prepare platform:", changesInfo);
217217

218218
if (changesInfo.hasChanges) {
219+
// android build artifacts need to be cleaned up when switching from release to debug builds
220+
if (platform.toLowerCase() === "android") {
221+
let previousPrepareInfo = this.$projectChangesService.getPrepareInfo(platform);
222+
// clean up prepared plugins when not building for release
223+
if (previousPrepareInfo && previousPrepareInfo.release !== this.$options.release) {
224+
let platformData = this.$platformsData.getPlatformData(platform);
225+
await platformData.platformProjectService.cleanProject(platformData.projectRoot, []);
226+
}
227+
}
228+
219229
await this.preparePlatformCore(platform, changesInfo);
220230
this.$projectChangesService.savePrepareInfo(platform);
221231
} else {

test/stubs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ export class PlatformProjectServiceStub implements IPlatformProjectService {
345345
async stopServices(): Promise<ISpawnResult> {
346346
return Promise.resolve({stderr: "", stdout: "", exitCode: 0});
347347
}
348+
async cleanProject(projectRoot: string, options: string[]): Promise<void> {
349+
return Promise.resolve();
350+
}
348351
}
349352

350353
export class ProjectDataService implements IProjectDataService {

0 commit comments

Comments
 (0)