Skip to content

clean-up after release build in android to prevent runtime errors #2452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/definitions/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ interface IPlatformProjectService {
* @returns {void}
*/
ensureConfigurationFileInAppResources(): void;

/**
* Removes build artifacts specific to the platform
* @returns {void}
*/
cleanProject(projectRoot: string, options: string[]): IFuture<void>
}

interface IAndroidProjectPropertiesManager {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
return Future.fromResult();
}

private cleanProject(projectRoot: string, options: string[]): IFuture<void> {
public cleanProject(projectRoot: string, options: string[]): IFuture<void> {
return (() => {
options.unshift("clean");

Expand Down
5 changes: 5 additions & 0 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,15 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
this.platformData.configurationFileName
);
}

public ensureConfigurationFileInAppResources(): void {
return null;
}

public cleanProject(projectRoot: string, options: string[]): IFuture<void> {
return Future.fromResult();
}

private mergeInfoPlists(): IFuture<void> {
return (() => {
let projectDir = this.$projectData.projectDir;
Expand Down
10 changes: 10 additions & 0 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,16 @@ export class PlatformService implements IPlatformService {
this.ensurePlatformInstalled(platform).wait();
let changesInfo = this.$projectChangesService.checkForChanges(platform);
if (changesInfo.hasChanges) {
// android build artifacts need to be cleaned up when switching from release to debug builds
if (platform.toLowerCase() === "android") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the whole logic is Android specific, instead of using this if, you can move the whole code inside AndroidProjectService's cleanProject method. Here you can just call:

platformData.platformProjectService.cleanProject(platformData.projectRoot, []).wait();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about that earlier, but I don't think cleanProject should depend on conditions specific to the prepare phase, and the android test prevents unnecessary prepareInfo checks when preparing an ios project.

let previousPrepareInfo = this.$projectChangesService.getPrepareInfo(platform);
// clean up prepared plugins when not building for release
if (previousPrepareInfo && previousPrepareInfo.release !== this.$options.release) {
let platformData = this.$platformsData.getPlatformData(platform);
platformData.platformProjectService.cleanProject(platformData.projectRoot, []).wait();
}
}

this.preparePlatformCore(platform, changesInfo).wait();
this.$projectChangesService.savePrepareInfo(platform);
} else {
Expand Down
3 changes: 3 additions & 0 deletions test/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ export class PlatformProjectServiceStub implements IPlatformProjectService {
ensureConfigurationFileInAppResources(): void {
return null;
}
cleanProject(projectRoot: string, options: string[]): IFuture<void> {
return Future.fromResult();
}
}

export class ProjectDataService implements IProjectDataService {
Expand Down