[java-sig-commits] [javapackages] Maven requires generator addition
Jaromír Cápík
jcapik at fedoraproject.org
Mon Jun 6 15:02:04 UTC 2011
commit 491e14d78cae39c418869a19080dd04abf8fb601
Author: Jaromír Cápík <jcapik at redhat.com>
Date: Mon Jun 6 17:00:46 2011 +0200
Maven requires generator addition
depgenerators/fileattrs/maven.attr | 1 +
depgenerators/maven.req | 55 ++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/depgenerators/fileattrs/maven.attr b/depgenerators/fileattrs/maven.attr
index 9964c69..8ee72ab 100644
--- a/depgenerators/fileattrs/maven.attr
+++ b/depgenerators/fileattrs/maven.attr
@@ -1,3 +1,4 @@
%__maven_provides %{_rpmconfigdir}/maven.prov
+#%__maven_requires %{_rpmconfigdir}/maven.req
%__maven_path ^%{_datadir}/maven2/.*\.pom
diff --git a/depgenerators/maven.req b/depgenerators/maven.req
new file mode 100644
index 0000000..f5c27a8
--- /dev/null
+++ b/depgenerators/maven.req
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+
+#
+# maven.req - Maven requires generator
+# Copyright (C) 2011 Jaromir Capik <jcapik at redhat.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+# List of scopes considered runtime
+runtime_scopes = [None, "runtime"]
+
+import sys
+import xml.dom.minidom
+
+# Returns a list of direct subtags matching the tagname
+def getTag(tag,tagname):
+ result = []
+ for node in tag.childNodes:
+ if node.nodeType == node.ELEMENT_NODE and node.tagName == tagname:
+ result.append(node)
+ return result
+
+# Returns a text contained in the last subtag matching the tagname
+def getText(tag,tagname):
+ result = None
+ for node in getTag(tag,tagname):
+ for text in node.childNodes:
+ if text.nodeType == node.TEXT_NODE:
+ result = text.data
+ return result
+
+# Main loop (project / dependencies / dependency / ...)
+for pomfile in sys.stdin:
+ dom = xml.dom.minidom.parse(pomfile.rstrip())
+ for project_tag in getTag(dom, "project"):
+ for dependencies_tag in getTag(project_tag, "dependencies"):
+ for dependency_tag in getTag(dependencies_tag, "dependency"):
+ scope = getText(dependency_tag,"scope")
+ if scope in runtime_scopes:
+ groupId = getText(dependency_tag,"groupId")
+ artifactId = getText(dependency_tag,"artifactId")
+ if groupId != None and artifactId != None:
+ print "mvn(%s:%s)" %(groupId, artifactId)
More information about the java-sig-commits
mailing list