@@ -12,7 +12,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
1212 private static VALUES_DIRNAME = "values" ;
1313 private static VALUES_VERSION_DIRNAME_PREFIX = AndroidProjectService . VALUES_DIRNAME + "-v" ;
1414 private static ANDROID_PLATFORM_NAME = "android" ;
15- private static LIBS_FOLDER_NAME = "libs" ;
1615 private static MIN_RUNTIME_VERSION_WITH_GRADLE = "1.3.0" ;
1716
1817 private _androidProjectPropertiesManagers : IDictionary < IAndroidProjectPropertiesManager > ;
@@ -252,9 +251,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
252251 this . $fs . ensureDirectoryExists ( targetPath ) . wait ( ) ;
253252
254253 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 ) ;
258254 } ) . future < void > ( ) ( ) ;
259255 }
260256
@@ -280,25 +276,46 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
280276 public preparePluginNativeCode ( pluginData : IPluginData ) : IFuture < void > {
281277 return ( ( ) => {
282278 let pluginPlatformsFolderPath = this . getPluginPlatformsFolderPath ( pluginData , AndroidProjectService . ANDROID_PLATFORM_NAME ) ;
279+ this . processResourcesFromPlugin ( pluginData . name , pluginPlatformsFolderPath ) . wait ( ) ;
280+ } ) . future < void > ( ) ( ) ;
281+ }
283282
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 ( ) ;
288289 }
289290 } ) . future < void > ( ) ( ) ;
290291 }
291292
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+
292314 public removePluginNativeCode ( pluginData : IPluginData ) : IFuture < void > {
293315 return ( ( ) => {
294316 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 ( ) ;
302319 } catch ( e ) {
303320 if ( e . code === "ENOENT" ) {
304321 this . $logger . debug ( "No native code jars found: " + e . message ) ;
0 commit comments