Blob Blame Raw
From 3f1b4b9e3427c0c633039c346475b9f47aa0f35e Mon Sep 17 00:00:00 2001
From: Michal Srb <msrb@redhat.com>
Date: Mon, 24 Nov 2014 10:28:42 +0100
Subject: [PATCH] [mvn_artifact] Add namespace support

---
 java-utils/mvn_artifact.py | 10 ++++++++--
 macros.d/macros.xmvn       |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/java-utils/mvn_artifact.py b/java-utils/mvn_artifact.py
index 78074f0..185eb9d 100644
--- a/java-utils/mvn_artifact.py
+++ b/java-utils/mvn_artifact.py
@@ -118,7 +118,7 @@ def is_it_ivy_file(fpath):
     return doc.tag == "ivy-module"
 
 
-def add_artifact_elements(root, art, ppath=None, jpath=None):
+def add_artifact_elements(root, art, namespace="", ppath=None, jpath=None):
     artifacts = []
     ext_backup = art.extension
     for path in [ppath, jpath]:
@@ -133,6 +133,10 @@ def add_artifact_elements(root, art, ppath=None, jpath=None):
                 art.extension = ext_backup
 
             art.path = os.path.abspath(path)
+
+            if namespace:
+                art.namespace = namespace
+
             a = art.to_metadata()
             artifacts.append(a)
 
@@ -246,6 +250,8 @@ if __name__ == "__main__":
                       help="skip dependencies section in resulting metadata")
     parser.add_option("-D", action="append", type="str",
                       help="add artifact property", metavar="property=value")
+    parser.add_option("-n", "--namespace", type="str",
+                      help="Namespace for generated artifacts", default="")
 
     sys.argv = args_to_unicode(sys.argv)
 
@@ -311,7 +317,7 @@ if __name__ == "__main__":
             key, value = d_opt.split('=')
             art.properties[key] = value
 
-    add_artifact_elements(metadata, art, pom_path, jar_path)
+    add_artifact_elements(metadata, art, options.namespace, pom_path, jar_path)
 
     with open(config, 'w') as f:
         dom = metadata.toDOM(None)
diff --git a/macros.d/macros.xmvn b/macros.d/macros.xmvn
index e7a6dda..fc2e724 100644
--- a/macros.d/macros.xmvn
+++ b/macros.d/macros.xmvn
@@ -118,7 +118,7 @@
 #
 # Usage: %mvn_artifact <pom> [<artifact-file>]
 #
-%mvn_artifact %{pyinterpreter} %{javadir}-utils/mvn_artifact.py
+%mvn_artifact %{pyinterpreter} %{javadir}-utils/mvn_artifact.py -n "%{?scl}"
 
 
 # %mvn_build - build Maven project
-- 
1.9.3