Cordova Plugin alternate to <source-file> tag to copy entire directory contents

别来无恙 提交于 2021-02-06 22:36:08

问题


Is there any way to specify in plugin.xml to copy every file in plugin source folder to the target platform directory either with one dir copy statement or automatically copy every file in src directory.

Using to be copied as part of big plugin is the nightmare, as we are seeing manual changes needed during the massive refactoring.


回答1:


I can't vote yet :( but Rafita is correct. To expand on that answer, I do the same thing because I have a large set of files that comprise an Android Activity that include many java source files, assets, layouts, and resources that all need to be installed into the platforms (and merged with any existing ones generated by the core android plugin).

  • For Android, I copied my whole activity's sources into the android plugin directory and then arrange for copying them all like this:

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

And for the 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"/> Will copy all source files from your plugin/src/ios directory to platforms/ios/Project-Name/Plugins/plugin-name directory




回答2:


You can do the same thing as you do with any file.

Simply use:

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

Cordova will recognize that, thereby will copy the entire YourDIR into a destination libs, for example.



来源:https://stackoverflow.com/questions/28042385/cordova-plugin-alternate-to-source-file-tag-to-copy-entire-directory-contents

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!