1
1
2
2
import { hook } from "../../common/helpers" ;
3
3
import { 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" ;
6
5
7
6
export class PrepareNativePlatformService implements IPrepareNativePlatformService {
8
7
9
8
constructor (
10
- private $androidResourcesMigrationService : IAndroidResourcesMigrationService ,
11
- private $fs : IFileSystem ,
12
9
public $hooksService : IHooksService ,
13
10
private $nodeModulesBuilder : INodeModulesBuilder ,
14
11
private $projectChangesService : IProjectChangesService ,
@@ -34,10 +31,7 @@ export class PrepareNativePlatformService implements IPrepareNativePlatformServi
34
31
await this . cleanProject ( platformData , projectData , { release } ) ;
35
32
}
36
33
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 ) ;
41
35
42
36
if ( hasChangesRequirePrepare ) {
43
37
await platformData . platformProjectService . prepareProject ( projectData , prepareData ) ;
@@ -58,43 +52,6 @@ export class PrepareNativePlatformService implements IPrepareNativePlatformServi
58
52
return hasChanges ;
59
53
}
60
54
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
-
98
55
private async cleanProject ( platformData : IPlatformData , projectData : IProjectData , options : { release : boolean } ) : Promise < void > {
99
56
// android build artifacts need to be cleaned up
100
57
// when switching between debug, release and webpack builds
0 commit comments