summaryrefslogtreecommitdiff
path: root/plugins_to_xml.py
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-06-23 10:15:35 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2013-06-23 11:13:00 +0200
commit67a217151450c6d41ca03c434458e8cf5ea4b578 (patch)
tree53b2dc0ea21d0488a289fca2c6138eb293a6dfca /plugins_to_xml.py
downloadtrygvis-parent-67a217151450c6d41ca03c434458e8cf5ea4b578.tar.gz
trygvis-parent-67a217151450c6d41ca03c434458e8cf5ea4b578.tar.bz2
trygvis-parent-67a217151450c6d41ca03c434458e8cf5ea4b578.tar.xz
trygvis-parent-67a217151450c6d41ca03c434458e8cf5ea4b578.zip
o Creating a parent pom for my code.
Diffstat (limited to 'plugins_to_xml.py')
-rw-r--r--plugins_to_xml.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins_to_xml.py b/plugins_to_xml.py
new file mode 100644
index 0000000..0173e81
--- /dev/null
+++ b/plugins_to_xml.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+
+import json
+import sys
+# pip install --user semantic_version
+from semantic_version import Version
+import collections
+
+data = json.load(sys.stdin)
+
+docs = data["response"]["docs"]
+
+#print json.dumps(docs, indent=2)
+def info(msg):
+ print >> sys.stderr, msg
+
+info('Found ' + str(len(docs)) + ' artifacts')
+
+# Some magic hacks to get semantic_version to like the versions more
+def v(doc):
+ return doc["v"]. \
+ replace("alpha1", "0.alpha-1"). \
+ replace("alpha2", "0.alpha-2")
+
+found = {}
+for doc in docs:
+ key = doc["g"] + ":" + doc["a"]
+ prev = found.get(key)
+ if prev == None:
+ found[key] = doc
+# print "First version of " + key + " => " + str(Version.coerce(doc["v"]))
+ continue
+
+ oldV = Version.coerce(v(prev))
+# print "oldV=" + str(oldV)
+ newV = Version.coerce(v(doc))
+# print "newV=" + str(newV)
+
+ if newV > oldV:
+# print "newer version of " + key + " => " + str(newV)
+ found[key] = doc
+# else:
+# print "old version of " + key + " => " + str(newV)
+
+found = collections.OrderedDict(sorted(found.items()))
+
+print "<pluginManagement>"
+print "<plugins>"
+for key, p in found.iteritems():
+ print """ <plugin>
+ <groupId>%(g)s</groupId>
+ <artifactId>%(a)s</artifactId>
+ <version>%(v)s</version>
+ </plugin>""" % p
+print " </plugins>"
+print "</pluginManagement>"