[javapackages] [man] quotes in manpage misinterpreted by asciidoc
by Michael Šimáček
commit f8bf5da62ed88e2eced9bf272f9b5657a3d13acb
Author: Michael Simacek <msimacek(a)redhat.com>
Date: Thu Jul 3 14:41:51 2014 +0200
[man] quotes in manpage misinterpreted by asciidoc
man/pom_xpath_disable.txt | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/man/pom_xpath_disable.txt b/man/pom_xpath_disable.txt
index 644aaa7..f0f5dff 100644
--- a/man/pom_xpath_disable.txt
+++ b/man/pom_xpath_disable.txt
@@ -34,7 +34,7 @@ file locations which will be processed.
EXAMPLES
--------
-*%pom_xpath_disable "/pom:project/pom:classifier = 'test'"* - this call
+*%pom_xpath_disable "/pom:project/pom:classifier = \'test'"* - this call
disables all modules with classifier *test*
*%pom_xpath_disable /pom:project/pom:packaging* - this call disables all
9 years, 10 months
[javapackages] [man] install pom_xpath_disable manpage
by Michael Šimáček
commit 80375447c82ac49f4ff6771564e3f499b2f2dcfe
Author: Michael Simacek <msimacek(a)redhat.com>
Date: Thu Jul 3 14:35:08 2014 +0200
[man] install pom_xpath_disable manpage
build | 1 +
install | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/build b/build
index eda0717..4af7804 100755
--- a/build
+++ b/build
@@ -104,6 +104,7 @@ manpage pom_add_dep
manpage pom_add_parent
manpage pom_add_plugin
manpage pom_disable_module
+manpage pom_xpath_disable
manpage pom_remove_dep
manpage pom_remove_parent
manpage pom_remove_plugin
diff --git a/install b/install
index 16216a7..a672a0c 100755
--- a/install
+++ b/install
@@ -139,6 +139,7 @@ inst_data target/pom_add_dep.7 "${mandir}/man7"
inst_data target/pom_add_parent.7 "${mandir}/man7"
inst_data target/pom_add_plugin.7 "${mandir}/man7"
inst_data target/pom_disable_module.7 "${mandir}/man7"
+inst_data target/pom_xpath_disable.7 "${mandir}/man7"
inst_data target/pom_remove_dep.7 "${mandir}/man7"
inst_data target/pom_remove_parent.7 "${mandir}/man7"
inst_data target/pom_remove_plugin.7 "${mandir}/man7"
9 years, 10 months
[javapackages] [man] manpage for pam_xpath_disable
by Michael Šimáček
commit 649cfe603c5a91a70d17d8c0f396e5d4281c0727
Author: Michael Simacek <msimacek(a)redhat.com>
Date: Thu Jul 3 14:34:23 2014 +0200
[man] manpage for pam_xpath_disable
man/pom_xpath_disable.txt | 66 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/man/pom_xpath_disable.txt b/man/pom_xpath_disable.txt
new file mode 100644
index 0000000..644aaa7
--- /dev/null
+++ b/man/pom_xpath_disable.txt
@@ -0,0 +1,66 @@
+pom_xpath_disable(7)
+=====================
+:doctype: manpage
+:man source: JAVAPACKAGES
+:man manual: Java Packages Tools
+
+NAME
+----
+pom_xpath_disable - Disable all modules whose POM files satisfy given
+XPath condition
+
+SYNOPSIS
+--------
+*%pom_xpath_disable* XPath-expression [POM-location]...
+
+DESCRIPTION
+-----------
+This macro recursively walks all enabled submodules of given POM and
+evaluates given XPath expression on them. If the expression returns
+a true value, matching submodule is disabled. Values considered true are
+defined by XPath specification as either true boolean value (i.e.
+returned by comparisons), non-empty node set, non-empty string or
+non-zero number.
+
+If the main module (specified by POM-location or `pom.xml` by default)
+also satisfies the condition, processing is aborted prior to making any
+changes and an error is raised. When none of the modules satisfy it, an
+error is also raised.
+
+POM location can be either a full path to the POM file, or a path to
+the directory containing *pom.xml*. If POM location is not given then
+*pom.xml* from current working directory is used. You can specify more
+file locations which will be processed.
+
+EXAMPLES
+--------
+*%pom_xpath_disable "/pom:project/pom:classifier = 'test'"* - this call
+disables all modules with classifier *test*
+
+*%pom_xpath_disable /pom:project/pom:packaging* - this call disables all
+sumbodules that explicitly specify packaging
+
+AUTHOR
+------
+Written by Michael Simacek.
+
+REPORTING BUGS
+--------------
+Bugs should be reported through Red Hat Bugzilla at
+http://bugzilla.redhat.com/.
+
+SEE ALSO
+--------
+*pom_add_dep*(7),
+*pom_add_parent*(7),
+*pom_add_plugin*(7),
+*pom_remove_dep*(7),
+*pom_remove_parent*(7),
+*pom_remove_plugin*(7),
+*pom_change_dep*(7),
+*pom_set_parent*(7),
+*pom_xpath_inject*(7),
+*pom_xpath_remove*(7),
+*pom_xpath_replace*(7),
+*pom_xpath_set*(7).
+*pom_disable_module*(7).
9 years, 10 months
[javapackages] [pom_xpath_disable] Remove macro options, they don't make sense for it
by Michael Šimáček
commit 6cb3194c36c811eee84754f1a6fbb975c09dcfd6
Author: Michael Simacek <msimacek(a)redhat.com>
Date: Thu Jul 3 14:32:59 2014 +0200
[pom_xpath_disable] Remove macro options, they don't make sense for it
macros.d/macros.fjava | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/macros.d/macros.fjava b/macros.d/macros.fjava
index 567a65e..be5b9d6 100644
--- a/macros.d/macros.fjava
+++ b/macros.d/macros.fjava
@@ -178,7 +178,7 @@ sort -u -o ${_filelist} ${_filelist} \
%pom_xpath_remove(rf) %{expand: %{__pom_call}xpath_remove %**
}
-%pom_xpath_disable(rf) %{expand: %{__pom_call}xpath_disable %**
+%pom_xpath_disable() %{expand: %{__pom_call}xpath_disable %**
}
# %pom_xpath_inject - inject XML code into POM file
9 years, 10 months
[javapackages] [pom_xpath_disable] handle boolean expressions differently
by Michael Šimáček
commit c3acad628eaba6201599ead33d63f105edac17d8
Author: Michael Simacek <msimacek(a)redhat.com>
Date: Thu Jul 3 14:31:46 2014 +0200
[pom_xpath_disable] handle boolean expressions differently
java-utils/pom_editor.py | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/java-utils/pom_editor.py b/java-utils/pom_editor.py
index 76d6262..65d3cfc 100644
--- a/java-utils/pom_editor.py
+++ b/java-utils/pom_editor.py
@@ -280,9 +280,11 @@ class XmlFile(object):
.format(query))
return query_result[0]
- def xpath_query(self, query, check_result=True):
+ def xpath_query(self, query, boolean=False):
if not query.startswith('/'):
query = '//' + query
+ if boolean:
+ query = 'boolean({0})'.format(query)
try:
nsmap = dict(self.NSMAP)
nsmap.update(self.root.nsmap)
@@ -293,7 +295,7 @@ class XmlFile(object):
except etree.XPathEvalError as error:
raise PomQueryInvalid("XPath query '{0}': {1}.".format(query,
error.message))
- if check_result and len(query_result) == 0:
+ if not boolean and len(query_result) == 0:
raise PomQueryNoMatch(dedent("""\
XPath query '{0}' didn't match any node.
(Did you forget to specify 'pom:' namespace?)""").format(query))
@@ -472,7 +474,7 @@ def pom_xpath_disable(when, pom=None):
"""<XPath> [POM location]"""
to_disable = []
def disable_recursive(pom):
- if pom.xpath_query(when, check_result=False):
+ if pom.xpath_query(when, boolean=True):
return True
for submodule, submod_path in zip(*submodule_info(pom.root, pom.xmlpath)):
realpath = find_xml(submod_path)
9 years, 10 months
[javapackages] [pom_xpath_disable] fail when there's no match in any module
by Michael Šimáček
commit bd6b96cecae94e224998379356e2ef1f82987a6e
Author: Michael Simacek <msimacek(a)redhat.com>
Date: Thu Jul 3 14:04:59 2014 +0200
[pom_xpath_disable] fail when there's no match in any module
java-utils/pom_editor.py | 2 ++
test/pom_editor_modules_test.py | 8 +++++---
2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/java-utils/pom_editor.py b/java-utils/pom_editor.py
index 95d6b96..76d6262 100644
--- a/java-utils/pom_editor.py
+++ b/java-utils/pom_editor.py
@@ -482,6 +482,8 @@ def pom_xpath_disable(when, pom=None):
if disable_recursive(pom):
raise PomException("Main POM satisfies the condition")
+ if not to_disable:
+ raise PomQueryNoMatch("Condition didn't match any module")
for pom, module in to_disable:
pom.patch(disable_module, {'pom': pom, 'module': module})
diff --git a/test/pom_editor_modules_test.py b/test/pom_editor_modules_test.py
index 30d2413..2c73dc2 100644
--- a/test/pom_editor_modules_test.py
+++ b/test/pom_editor_modules_test.py
@@ -4,10 +4,12 @@ import unittest
class TestPomXpathDisable(WorkdirTestCase):
def test_no_match(self):
- return_value, stderr, report = exec_pom_macro('%pom_xpath_disable nothing submodule', {
+ return_value, stderr, _ = exec_pom_macro(
+ '''%pom_xpath_disable "/pom:project/pom:groupId='not-there'" submodule''', {
'submodule': 'minimal_pom.xml'})
- self.assertEqual(0, return_value, stderr)
- self.assertEqual('', report, report)
+ assertIn(self, "Error", stderr)
+ assertIn(self, "didn't match", stderr)
+ self.assertNotEqual(0, return_value)
def test_nonexistent(self):
return_value, stderr, _ = exec_pom_macro('%pom_xpath_disable nothing', {})
9 years, 10 months
[javapackages] More tests for pom_xpath_disable
by Michael Šimáček
commit 101996636f915a9e365bc6e609d2c6990be26b22
Author: Michael Simacek <msimacek(a)redhat.com>
Date: Thu Jul 3 13:59:43 2014 +0200
More tests for pom_xpath_disable
test/data/pom_editor/intermediate_skip.xml | 26 +++++++++++++++++++
.../want/intermediate_disabled_schemas.xml | 23 +++++++++++++++++
test/pom_editor_modules_test.py | 27 ++++++++++++++++++++
3 files changed, 76 insertions(+), 0 deletions(-)
---
diff --git a/test/data/pom_editor/intermediate_skip.xml b/test/data/pom_editor/intermediate_skip.xml
new file mode 100644
index 0000000..b39b3c6
--- /dev/null
+++ b/test/data/pom_editor/intermediate_skip.xml
@@ -0,0 +1,26 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>com.example</groupId>
+ <artifactId>parent</artifactId>
+ <version>17</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.example</groupId>
+ <artifactId>intermediate</artifactId>
+ <version>2.6</version>
+ <name>Intermediate</name>
+ <modules>
+ <module>
+ src/schemas
+ </module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.2</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/test/data/pom_editor/want/intermediate_disabled_schemas.xml b/test/data/pom_editor/want/intermediate_disabled_schemas.xml
new file mode 100644
index 0000000..0c5d2ed
--- /dev/null
+++ b/test/data/pom_editor/want/intermediate_disabled_schemas.xml
@@ -0,0 +1,23 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>com.example</groupId>
+ <artifactId>parent</artifactId>
+ <version>17</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.example</groupId>
+ <artifactId>intermediate</artifactId>
+ <version>2.6</version>
+ <name>Intermediate</name>
+ <modules>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.2</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/test/pom_editor_modules_test.py b/test/pom_editor_modules_test.py
index bb72631..30d2413 100644
--- a/test/pom_editor_modules_test.py
+++ b/test/pom_editor_modules_test.py
@@ -22,5 +22,32 @@ class TestPomXpathDisable(WorkdirTestCase):
self.assertEqual(0, return_value, stderr)
self.assertEqual('', report, report)
+ def test_two_levels(self):
+ return_value, stderr, report = exec_pom_macro(
+ """%pom_xpath_disable "pom:parent[pom:artifactId='intermediate']" """,
+ poms_tree=example_tree,
+ want_tree={'intermediate': 'intermediate_disabled_schemas.xml'})
+ self.assertEqual(0, return_value, stderr)
+ self.assertEqual('', report, report)
+
+ def test_skip_level(self):
+ poms_tree = dict(example_tree)
+ del poms_tree['intermediate/schemas']
+ poms_tree['intermediate'] = 'intermediate_skip.xml'
+ poms_tree['intermediate/src/schemas'] = 'example_schemas.xml'
+ return_value, stderr, report = exec_pom_macro(
+ """%pom_xpath_disable "pom:project.build.sourceEncoding='UTF-8'" """,
+ poms_tree=poms_tree,
+ want_tree={'intermediate': 'intermediate_disabled_schemas.xml'})
+ self.assertEqual(0, return_value, stderr)
+ self.assertEqual('', report, report)
+
+ def test_fail_on_main(self):
+ return_value, stderr, _ = exec_pom_macro(
+ """%pom_xpath_disable "pom:groupId='com.example'" """,
+ poms_tree=example_tree)
+ assertIn(self, "Main POM satisfies the condition", stderr)
+ self.assertNotEqual(0, return_value)
+
if __name__ == '__main__':
unittest.main()
9 years, 10 months
[javapackages] Fix in pom_xpath_disable
by Michael Šimáček
commit 309493a7121e4e303d23e6295e6f597196cbc758
Author: Michael Simacek <msimacek(a)redhat.com>
Date: Thu Jul 3 13:47:28 2014 +0200
Fix in pom_xpath_disable
java-utils/pom_editor.py | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/java-utils/pom_editor.py b/java-utils/pom_editor.py
index b717052..95d6b96 100644
--- a/java-utils/pom_editor.py
+++ b/java-utils/pom_editor.py
@@ -434,6 +434,11 @@ def macro(types=(XmlFile,)):
return decorated
return decorator
+def disable_module(pom, module):
+ xpath = "//pom:module[normalize-space(text())='{0}']".format(module)
+ elements = pom.xpath_query(xpath)
+ for element in elements:
+ pom.replace_xml(element, etree.Comment(" module removed by maintainer: {0} ".format(module)))
@macro()
def pom_xpath_inject(where, xml_string, pom=None):
@@ -473,12 +478,12 @@ def pom_xpath_disable(when, pom=None):
realpath = find_xml(submod_path)
subpom = Pom(realpath)
if disable_recursive(subpom):
- to_disable.append((pom.xmlpath, submodule))
+ to_disable.append((pom, submodule))
if disable_recursive(pom):
raise PomException("Main POM satisfies the condition")
- for pompath, module in to_disable:
- pom_disable_module(module, pompath)
+ for pom, module in to_disable:
+ pom.patch(disable_module, {'pom': pom, 'module': module})
@macro(types=(Pom, Ivy))
def pom_remove_dep(dep, pom=None):
@@ -508,10 +513,7 @@ def pom_remove_plugin(plugin, pom=None):
def pom_disable_module(module, pom=None):
"""<module name> [POM location]"""
try:
- xpath = "//pom:module[normalize-space(text())='{0}']".format(module)
- elements = pom.xpath_query(xpath)
- for element in elements:
- pom.replace_xml(element, etree.Comment(" module removed by maintainer: {0} ".format(module)))
+ disable_module(pom, module)
except PomQueryNoMatch:
raise PomQueryNoMatch("Module '{0}' not found.".format(module))
9 years, 10 months