Blob Blame Raw
From 27cab940e4116b5eb90f9bf098734b7754c3daa5 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 | 11 +++++++++--
 macros.d/macros.xmvn       |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/java-utils/mvn_artifact.py b/java-utils/mvn_artifact.py
index 9ace911..f1cdbd6 100644
--- a/java-utils/mvn_artifact.py
+++ b/java-utils/mvn_artifact.py
@@ -117,7 +117,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]:
@@ -132,6 +132,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)
 
@@ -258,6 +262,9 @@ if __name__ == "__main__":
                         epilog=epilog)
     parser.add_option("--skip-dependencies", action="store_true", default=False,
                       help="skip dependencies section in resulting metadata")
+    parser.add_option("-n", "--namespace", type="str",
+                      help="Namespace for generated artifacts", default="")
+
     for index, arg in enumerate(sys.argv):
         sys.argv[index] = arg.decode(sys.getfilesystemencoding())
 
@@ -321,7 +328,7 @@ if __name__ == "__main__":
     else:
         art.properties['xmvn.resolver.disableEffectivePom'] = 'true'
 
-    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 80158fe..a06d236 100644
--- a/macros.d/macros.xmvn
+++ b/macros.d/macros.xmvn
@@ -118,7 +118,7 @@
 #
 # Usage: %mvn_artifact <pom> [<artifact-file>]
 #
-%mvn_artifact python %{javadir}-utils/mvn_artifact.py
+%mvn_artifact python %{javadir}-utils/mvn_artifact.py -n "%{?scl}"
 
 
 # %mvn_build - build Maven project
-- 
1.9.3