Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge files while adding Cordova Plugins

I develop android plugins for Cordova project and i've stucked with a problem: merging files. In particular resource files. Most plugins have the same resource files like strings.xml, and i want to merge them. I searched Google for several days and couldn't find the answer.

What should I write in plugin.xml of my plugin? Source-file tag just add file. Config-file tag allow me to add some lines to the file, but it's uncomfortably, if I have very much lines. Is there any command to merge files?

like image 452
Nisazh Avatar asked May 26 '15 15:05

Nisazh


1 Answers

I faced the same problem as you and found no way to merge resources using plugman (maybe this has changed in the last couple of years).

What I did is that I made a plugin containing all the common files with a basic content like this :

<?xml version="1.0" encoding="UTF-8"?>
<resources>
</resources>

Then in each plugin where I need to set resources, I use plugman syntax in plugin.xml :

<config-file target="res/values/ids.xml" parent="/resources">
    <item type="id" name="id1"/>
    <item type="id" name="id2"/>
    <item type="id" name="id3"/>
</config-file>
<config-file target="res/values/strings.xml" parent="/resources">
    <string name="message1">Hello</string>
    <string name="message2">world!</string>
</config-file>

And finally in your plugin you can set a demendency on the "basic resources" plugin.

The limit of this system is if you want to publish your plugins and people use it at the same time as other plugins overwriting the same resources files as you do...

I had posted a SO question back in the time and had no luck getting an aswer. I guess we could ask this directly to the plugman people on their jira.

like image 159
QuickFix Avatar answered Oct 03 '22 19:10

QuickFix