[java-sig-commits] [javapackages] xmvn_config: add support for custom xml options

Stanislav Ochotnicky sochotni at fedoraproject.org
Tue Sep 24 16:22:40 UTC 2013


commit 2b69a12c27a1dd4874d20d487124a0de9b486d50
Author: Stanislav Ochotnicky <sochotnicky at redhat.com>
Date:   Tue Sep 24 18:19:39 2013 +0200

    xmvn_config: add support for custom xml options

 TODO                               |    1 +
 python/javapackages/xmvn_config.py |   10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/TODO b/TODO
index 652ed2b..0fcbb12 100644
--- a/TODO
+++ b/TODO
@@ -26,6 +26,7 @@
 
 ** add tests for mvn_file wrt prefix usage and relative paths
 
+** add tests for xmvn_config.add_custom_option with xml content
 
 * FEATURES
 
diff --git a/python/javapackages/xmvn_config.py b/python/javapackages/xmvn_config.py
index 34e3f2c..7ff9095 100644
--- a/python/javapackages/xmvn_config.py
+++ b/python/javapackages/xmvn_config.py
@@ -37,6 +37,7 @@ import re
 from StringIO import StringIO
 import xml.dom.minidom
 
+import lxml
 import lxml.etree as ET
 from lxml.etree import ElementTree, Element, SubElement
 
@@ -258,7 +259,7 @@ class XMvnConfig(object):
                      option location with '/' used as delimiter
 
                      example: buildSettings/compilerSource
-        content -- text to which the option will be set (no XML allowed)
+        content -- text to which the option will be set
         """
         node_names = optionstr.split("/")
         confpath = self.__get_current_config()
@@ -267,5 +268,10 @@ class XMvnConfig(object):
         for node in node_names:
             par = SubElement(par, node)
 
-        par.text = content
+        try:
+            contentElement = ET.fromstring(content)
+            par.append(contentElement)
+        except lxml.etree.XMLSyntaxError:
+            # doesn't look like XML, just set it as content
+            par.text = content
         self.__write_xml(confpath, root)


More information about the java-sig-commits mailing list