@@ -12,7 +12,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
12
12
private static VALUES_DIRNAME = "values" ;
13
13
private static VALUES_VERSION_DIRNAME_PREFIX = AndroidProjectService . VALUES_DIRNAME + "-v" ;
14
14
private static ANDROID_PLATFORM_NAME = "android" ;
15
- private static LIBS_FOLDER_NAME = "libs" ;
16
15
private static MIN_RUNTIME_VERSION_WITH_GRADLE = "1.3.0" ;
17
16
18
17
private _androidProjectPropertiesManagers : IDictionary < IAndroidProjectPropertiesManager > ;
@@ -252,9 +251,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
252
251
this . $fs . ensureDirectoryExists ( targetPath ) . wait ( ) ;
253
252
254
253
shell . cp ( "-f" , path . join ( libraryPath , "*.jar" ) , targetPath ) ;
255
- let projectLibsDir = path . join ( this . platformData . projectRoot , "libs" ) ;
256
- this . $fs . ensureDirectoryExists ( projectLibsDir ) . wait ( ) ;
257
- shell . cp ( "-f" , path . join ( libraryPath , "*.jar" ) , projectLibsDir ) ;
258
254
} ) . future < void > ( ) ( ) ;
259
255
}
260
256
@@ -280,25 +276,46 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
280
276
public preparePluginNativeCode ( pluginData : IPluginData ) : IFuture < void > {
281
277
return ( ( ) => {
282
278
let pluginPlatformsFolderPath = this . getPluginPlatformsFolderPath ( pluginData , AndroidProjectService . ANDROID_PLATFORM_NAME ) ;
279
+ this . processResourcesFromPlugin ( pluginData . name , pluginPlatformsFolderPath ) . wait ( ) ;
280
+ } ) . future < void > ( ) ( ) ;
281
+ }
283
282
284
- // Handle *.jars inside libs folder
285
- let libsFolderPath = path . join ( pluginPlatformsFolderPath , AndroidProjectService . LIBS_FOLDER_NAME ) ;
286
- if ( this . $fs . exists ( libsFolderPath ) . wait ( ) ) {
287
- this . addLibrary ( libsFolderPath ) . wait ( ) ;
283
+ public processConfigurationFilesFromAppResources ( ) : IFuture < void > {
284
+ return ( ( ) => {
285
+ // Process androidManifest.xml from App_Resources
286
+ let manifestFilePath = path . join ( this . $projectData . appResourcesDirectoryPath , this . platformData . normalizedPlatformName , this . platformData . configurationFileName ) ;
287
+ if ( this . $fs . exists ( manifestFilePath ) . wait ( ) ) {
288
+ this . processResourcesFromPlugin ( "NativescriptAppResources" , path . dirname ( manifestFilePath ) ) . wait ( ) ;
288
289
}
289
290
} ) . future < void > ( ) ( ) ;
290
291
}
291
292
293
+ private processResourcesFromPlugin ( pluginName : string , pluginPlatformsFolderPath : string ) : IFuture < void > {
294
+ return ( ( ) => {
295
+ let configurationsDirectoryPath = path . join ( this . platformData . projectRoot , "configurations" ) ;
296
+ this . $fs . ensureDirectoryExists ( configurationsDirectoryPath ) . wait ( ) ;
297
+
298
+ let pluginConfigurationDirectoryPath = path . join ( configurationsDirectoryPath , pluginName ) ;
299
+ this . $fs . ensureDirectoryExists ( pluginConfigurationDirectoryPath ) . wait ( ) ;
300
+
301
+ // Copy include.gradle file
302
+ let includeGradleFilePath = path . join ( pluginPlatformsFolderPath , "include.gradle" ) ;
303
+ if ( this . $fs . exists ( includeGradleFilePath ) . wait ( ) ) {
304
+ shell . cp ( "-f" , includeGradleFilePath , pluginConfigurationDirectoryPath ) ;
305
+ }
306
+
307
+ // Copy all resources from plugin
308
+ let resourcesDestinationDirectoryPath = path . join ( this . platformData . projectRoot , "src" , pluginName ) ;
309
+ this . $fs . ensureDirectoryExists ( resourcesDestinationDirectoryPath ) . wait ( ) ;
310
+ shell . cp ( "-Rf" , path . join ( pluginPlatformsFolderPath , "*" ) , resourcesDestinationDirectoryPath ) ;
311
+ } ) . future < void > ( ) ( ) ;
312
+ }
313
+
292
314
public removePluginNativeCode ( pluginData : IPluginData ) : IFuture < void > {
293
315
return ( ( ) => {
294
316
try {
295
- let pluginPlatformsFolderPath = this . getPluginPlatformsFolderPath ( pluginData , AndroidProjectService . ANDROID_PLATFORM_NAME ) ;
296
- let libsFolderPath = path . join ( pluginPlatformsFolderPath , AndroidProjectService . LIBS_FOLDER_NAME ) ;
297
-
298
- if ( this . $fs . exists ( libsFolderPath ) . wait ( ) ) {
299
- let pluginJars = this . $fs . enumerateFilesInDirectorySync ( libsFolderPath ) ;
300
- _ . each ( pluginJars , jarName => this . $fs . deleteFile ( path . join ( libsFolderPath , jarName ) ) . wait ( ) ) ;
301
- }
317
+ this . $fs . deleteDirectory ( path . join ( this . platformData . projectRoot , "configurations" , pluginData . name ) ) . wait ( ) ;
318
+ this . $fs . deleteDirectory ( path . join ( this . platformData . projectRoot , "src" , pluginData . name ) ) . wait ( ) ;
302
319
} catch ( e ) {
303
320
if ( e . code === "ENOENT" ) {
304
321
this . $logger . debug ( "No native code jars found: " + e . message ) ;
0 commit comments