Cordova plugin alternates with <source-file> tag to copy the entire contents of the directory

Is there a way to tell plugin.xml to copy each file to the plugin’s source folder in the directory of the target platform using either the single dir copy statement or automatically copy each file to the src directory.

Using copy as part of a large plugin is a nightmare, as we see the manual changes needed during mass refactoring.

+6
source share
2 answers

I still can not vote :( But Rafita is right. To expand this answer, I am doing the same because I have a large set of files that include Android activity, which includes many java source files, assets, layouts , and resources that should all be installed on the platforms (and combined with any existing ones created by the main Android plugin).

  • For Android, I copied all of my activity sources into the Android plugins directory, and then ordered them to be copied as follows:

<source-file src="src/android/java/com/acme" target-dir="src/com" /> will copy your complete package tree to the platforms/android/src/com/acme .

And for resources and assets you can do this:

<resource-file src="src/android/res" target="res" /> <resource-file src="src/android/assets" target="assets" />

  • For iOS

<source-file src="src/ios" target-dir="src"/> Copy all source files from the plugin/src/ios directory to the platforms/ios/Project-Name/Plugins/plugin-name directory

+2
source

You can do the same as with any file.

Just use:

 <source-file src="src/android/libs/YourDIR" target-dir="libs"/> 

Cordoba admits that in this way she will copy all YourDIR to target libraries, for example.

+1
source

Source: https://habr.com/ru/post/981262/


All Articles