From ad9748888b1dd286b6c805c6d4bce87760e9d2c9 Mon Sep 17 00:00:00 2001 From: Kasun Gajasinghe Date: Sat, 6 Aug 2011 17:09:52 +0000 Subject: brought the parent element rewriting code to a separate function. Added another argument, --rewritesubmoduleppom, to control whether to rewrite_parent the submodules of the project or not. svn path=/projects/javatoolkit/branches/kasun/; revision=8672 --- src/py/javatoolkit/maven/MavenPom.py | 12 +++++++++--- src/py/maven-helper.py | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/py/javatoolkit/maven/MavenPom.py b/src/py/javatoolkit/maven/MavenPom.py index 9aa926c..7ccc341 100644 --- a/src/py/javatoolkit/maven/MavenPom.py +++ b/src/py/javatoolkit/maven/MavenPom.py @@ -105,9 +105,10 @@ class MavenPom: return self.buffer.getvalue() - def rewrite(self,xmldoc,**kwargs): - #rewrite the with the values in self.cli_options.{p_parentgroup,p_parentartifact,p_parentversion} - #This rewriting is optional. Packager may only rewrite version if he wishes. + def parent_rewrite(self,xmldoc,**kwargs): + #rewrite the element in the poms with the values in self.cli_options.{p_parentgroup,p_parentartifact,p_parentversion} + #This rewriting is optional. Packager may only rewrite version of the parent element as well if he wishes. + #This does not touch the parent pom. parent_element = ( xmldoc.getElementsByTagName("parent") or [] ) if parent_element: if self.cli_options.p_parentgroup: @@ -128,6 +129,11 @@ class MavenPom: # else: # create parent element and map the parent to gentoo maven super pom. That contains all the plugin versions etc. + def rewrite(self,xmldoc,**kwargs): + + if self.cli_options.p_rewrite_parent: + parent_rewrite(self.mydoc,**kwargs) + # desactivate all dependencies dependencies_root = ( xmldoc.getElementsByTagName("dependencies") or [] ) for node in dependencies_root: diff --git a/src/py/maven-helper.py b/src/py/maven-helper.py index c0775a1..8abde58 100755 --- a/src/py/maven-helper.py +++ b/src/py/maven-helper.py @@ -36,7 +36,7 @@ if __name__ == '__main__': usage += " %s [-a] [-v] [-g] [-d] [-f fic.xml]\n" % sys.argv[0] usage += "Or:\n" usage += " %s --rewrite [--classpath some.jar:class.jar:path.jar] [--source JVM_VER ] |--target JVM_VER]\n" % sys.argv[0] - usage += " JVM_VER ::= 1.4 || 1.5 " + usage += " JVM_VER ::= 1.4 || 1.5 || 1.6" usage += "\n" usage += "If the -f parameter is not utilized, the script will read and\n" usage += "write to stdin and stdout respectively. The use of quotes on\n" @@ -104,6 +104,8 @@ if __name__ == '__main__': make_option ("-r", "--rewrite", action="store_true", dest="p_rewrite", help="rewrite poms to use our classpath"), make_option ("-p", "--ischild", action="store_true", dest="p_ischild", help="return true if this is a child pom"), make_option ("-v", "--version" , action="store_true", dest="p_version", help="get artifact version."), + + make_option ("-w", "--rewritesubmoduleppom" , action="store_true", dest="p_rewrite_parent", help="rewrite the element of poms of all sub-modules"), make_option ("-x", "--pgroup" , action="append", dest="p_parentgroup", help="set groupId"), make_option ("-y", "--partifact" , action="append", dest="p_parentartifact", help="set artifactId"), make_option ("-z", "--pversion" , action="append", dest="p_parentversion", help="set version"), -- cgit v1.2.3-65-gdbad