[
https://issues.apache.org/jira/browse/CB-11023?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15314766#comment-15314766
]
ASF GitHub Bot commented on CB-11023:
-------------------------------------
GitHub user ktop opened a pull request:
https://github.com/apache/cordova-lib/pull/449
CB-11023 Add edit-config functionality
New edit-config tag for plugin.xml will allow users to modify xml
attributes.
Ex. Assumes your AndroidManifest.xml has a second activity element with
attribute android:name="SecondActivity"
```xml
<!-- Will modify first activity -->
<edit-config file="AndroidManifest.xml"
target="/manifest/application/activity" mode="merge">
<activity android:enabled="true"
android:configChanges="orientation|keyboardHidden" />
</edit-config>
<!-- Will modify second activity -->
<edit-config file="AndroidManifest.xml"
target="/manifest/application/activity[@android:name='SecondActivity']"
mode="overwrite">
<activity android:enabled="true" android:name="SecondActivity"
/>
</edit-config>
```
file: specifies the file location
target: specifies an xpath to the element that you want to modify
modes:
- merge: add attributes in the target with the ones specified by
edit-config and will replace if the attribute names are the same
- overwrite: replace all of the attributes at the target with the one
specified by edit-config
children: will only modify one element per edit-config tag
There is conflict checking now....if a plugin wants to modify an attribute
another plugin has already modified, an error will be thrown and plugin install
will fail. The user must fix the conflict or they can use --force to force add
the plugin and overwrite the conflict.
Lastly, on plugin uninstall, the plugin should restore the attributes to
the state it was before installing.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ktop/cordova-lib editconfig
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/cordova-lib/pull/449.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #449
----
commit a3864929400f61fc31d03c3bab1d91a9467a3fbf
Author: unknown <[email protected]>
Date: 2016-05-26T21:36:23Z
CB-11023 Add edit-config functionality
----
> plugin.xml should be able to add attribute to an existing element in
> AndroidManifest.xml
> ----------------------------------------------------------------------------------------
>
> Key: CB-11023
> URL: https://issues.apache.org/jira/browse/CB-11023
> Project: Apache Cordova
> Issue Type: Improvement
> Components: CLI, Plugman
> Reporter: Carlos Santana
>
> We have a need for a plugin we develop to add the attribute android:name to
> the <application> element to be able to point to a Class that tracks app
> sessions for analytics.
> plugin.xml only support via <config-file> only to add elements to
> AndroidManfist.xml this request is to add an enhancement to also handle
> adding an attribute to an existing element.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]