11
22import { hook } from "../../common/helpers" ;
33import { performanceLog } from "../../common/decorators" ;
4- import * as path from "path" ;
5- import { NativePlatformStatus , APP_FOLDER_NAME , APP_RESOURCES_FOLDER_NAME } from "../../constants" ;
4+ import { NativePlatformStatus } from "../../constants" ;
65
76export class PrepareNativePlatformService implements IPrepareNativePlatformService {
87
98 constructor (
10- private $androidResourcesMigrationService : IAndroidResourcesMigrationService ,
11- private $fs : IFileSystem ,
129 public $hooksService : IHooksService ,
1310 private $nodeModulesBuilder : INodeModulesBuilder ,
1411 private $projectChangesService : IProjectChangesService ,
@@ -34,10 +31,7 @@ export class PrepareNativePlatformService implements IPrepareNativePlatformServi
3431 await this . cleanProject ( platformData , projectData , { release } ) ;
3532 }
3633
37- // Move the native application resources from platforms/.../app/App_Resources
38- // to the right places in the native project,
39- // because webpack copies them on every build (not every change).
40- this . prepareAppResources ( platformData , projectData ) ;
34+ platformData . platformProjectService . prepareAppResources ( projectData ) ;
4135
4236 if ( hasChangesRequirePrepare ) {
4337 await platformData . platformProjectService . prepareProject ( projectData , prepareData ) ;
@@ -58,43 +52,6 @@ export class PrepareNativePlatformService implements IPrepareNativePlatformServi
5852 return hasChanges ;
5953 }
6054
61- private prepareAppResources ( platformData : IPlatformData , projectData : IProjectData ) : void {
62- const appDestinationDirectoryPath = path . join ( platformData . appDestinationDirectoryPath , APP_FOLDER_NAME ) ;
63- const appResourcesDestinationDirectoryPath = path . join ( appDestinationDirectoryPath , APP_RESOURCES_FOLDER_NAME ) ;
64-
65- if ( this . $fs . exists ( appResourcesDestinationDirectoryPath ) ) {
66- platformData . platformProjectService . prepareAppResources ( appResourcesDestinationDirectoryPath , projectData ) ;
67- const appResourcesDestination = platformData . platformProjectService . getAppResourcesDestinationDirectoryPath ( projectData ) ;
68- this . $fs . ensureDirectoryExists ( appResourcesDestination ) ;
69-
70- if ( platformData . normalizedPlatformName . toLowerCase ( ) === "android" ) {
71- const appResourcesDirectoryPath = projectData . getAppResourcesDirectoryPath ( ) ;
72- const appResourcesDirStructureHasMigrated = this . $androidResourcesMigrationService . hasMigrated ( appResourcesDirectoryPath ) ;
73- const appResourcesAndroid = path . join ( appResourcesDirectoryPath , platformData . normalizedPlatformName ) ;
74-
75- if ( appResourcesDirStructureHasMigrated ) {
76- this . $fs . copyFile ( path . join ( appResourcesAndroid , "src" , "*" ) , appResourcesDestination ) ;
77-
78- this . $fs . deleteDirectory ( appResourcesDestinationDirectoryPath ) ;
79- return ;
80- }
81-
82- // https://github.com/NativeScript/android-runtime/issues/899
83- // App_Resources/Android/libs is reserved to user's aars and jars, but they should not be copied as resources
84- this . $fs . copyFile ( path . join ( appResourcesDestinationDirectoryPath , platformData . normalizedPlatformName , "*" ) , appResourcesDestination ) ;
85- this . $fs . deleteDirectory ( path . join ( appResourcesDestination , "libs" ) ) ;
86-
87- this . $fs . deleteDirectory ( appResourcesDestinationDirectoryPath ) ;
88-
89- return ;
90- }
91-
92- this . $fs . copyFile ( path . join ( appResourcesDestinationDirectoryPath , platformData . normalizedPlatformName , "*" ) , appResourcesDestination ) ;
93-
94- this . $fs . deleteDirectory ( appResourcesDestinationDirectoryPath ) ;
95- }
96- }
97-
9855 private async cleanProject ( platformData : IPlatformData , projectData : IProjectData , options : { release : boolean } ) : Promise < void > {
9956 // android build artifacts need to be cleaned up
10057 // when switching between debug, release and webpack builds
0 commit comments