@@ -239,16 +239,9 @@ export class PlatformService extends EventEmitter implements IPlatformService {
239
239
this . $logger . trace ( "Changes info in prepare platform:" , changesInfo ) ;
240
240
241
241
if ( changesInfo . hasChanges ) {
242
- // android build artifacts need to be cleaned up when switching from release to debug builds
243
- if ( platform . toLowerCase ( ) === "android" ) {
244
- let previousPrepareInfo = this . $projectChangesService . getPrepareInfo ( platform , projectData ) ;
245
- // clean up prepared plugins when not building for release
246
- if ( previousPrepareInfo && previousPrepareInfo . release !== appFilesUpdaterOptions . release ) {
247
- await platformData . platformProjectService . cleanProject ( platformData . projectRoot , projectData ) ;
248
- }
249
- }
250
-
242
+ await this . cleanProject ( platform , appFilesUpdaterOptions , platformData , projectData ) ;
251
243
await this . preparePlatformCore ( platform , appFilesUpdaterOptions , projectData , platformSpecificData , changesInfo , filesToSync ) ;
244
+
252
245
this . $projectChangesService . savePrepareInfo ( platform , projectData ) ;
253
246
} else {
254
247
this . $logger . out ( "Skipping prepare." ) ;
@@ -275,6 +268,25 @@ export class PlatformService extends EventEmitter implements IPlatformService {
275
268
}
276
269
}
277
270
271
+ private async cleanProject ( platform : string , appFilesUpdaterOptions : IAppFilesUpdaterOptions , platformData : IPlatformData , projectData : IProjectData ) : Promise < void > {
272
+ // android build artifacts need to be cleaned up
273
+ // when switching between debug, release and webpack builds
274
+ if ( platform . toLowerCase ( ) !== "android" ) {
275
+ return ;
276
+ }
277
+
278
+ const previousPrepareInfo = this . $projectChangesService . getPrepareInfo ( platform , projectData ) ;
279
+ if ( ! previousPrepareInfo ) {
280
+ return ;
281
+ }
282
+
283
+ const { release : previousWasRelease , bundle : previousWasBundle } = previousPrepareInfo ;
284
+ const { release : currentIsRelease , bundle : currentIsBundle } = appFilesUpdaterOptions ;
285
+ if ( ( previousWasRelease !== currentIsRelease ) || ( previousWasBundle !== currentIsBundle ) ) {
286
+ await platformData . platformProjectService . cleanProject ( platformData . projectRoot , projectData ) ;
287
+ }
288
+ }
289
+
278
290
/* Hooks are expected to use "filesToSync" parameter, as to give plugin authors additional information about the sync process.*/
279
291
@helpers . hook ( 'prepare' )
280
292
private async preparePlatformCore ( platform : string , appFilesUpdaterOptions : IAppFilesUpdaterOptions , projectData : IProjectData , platformSpecificData : IPlatformSpecificData , changesInfo ?: IProjectChangesInfo , filesToSync ?: Array < String > ) : Promise < void > {
0 commit comments