Only skip files start with maven-metadata.xml 54/13654/3
authorThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 26 Nov 2018 03:05:51 +0000 (11:05 +0800)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 26 Nov 2018 04:02:36 +0000 (12:02 +0800)
Ensure we are only skipping files that start with maven-metadata.xml*
Having the word "maven-metadata" in our artifact is fine as long as it
is not a Maven 2 repo file which is exactly 'maven-metadata.xml' the
trialing * is to ensure it does not pick up the checksum files too.

Also reword the function docs to be more clear about what it does.

Issue: RELENG-1512
Change-Id: Icc20e4581a74625506ac9a0ff5d5e17b45034ccc
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
lftools/deploy.py

index 7b116e2..baeb850 100644 (file)
@@ -504,7 +504,13 @@ def upload_maven_file_to_nexus(nexus_url, nexus_repo_id,
 
 
 def deploy_nexus(nexus_repo_url, deploy_dir, snapshot=False):
-    """Deploy Maven artifacts to Nexus.
+    """Deploy a local directory to a Nexus repository.
+
+    This function intentially strips out the following files:
+
+        - _remote.repositories
+        - resolver-status.properties
+        - maven-metadata.xml*  (if not a snapshot repo)
 
     Parameters:
         nexus_repo_url: URL to Nexus server. (Ex: https://nexus.example.org)
@@ -533,12 +539,18 @@ def deploy_nexus(nexus_repo_url, deploy_dir, snapshot=False):
     files = glob2.glob('**/*')
     for file in files:
         if os.path.isfile(file):
-            if not file.endswith("_remote.repositories") and not file.endswith("resolver-status.properties"):
-                if snapshot:
-                    file_list.append(file)
-                else:
-                    if not "maven-metadata" in file:
-                        file_list.append(file)
+            base_name = os.path.basename(file)
+
+            # Skip blacklisted files
+            if (base_name == "_remote.repositories" or
+                    base_name == "resolver-status.properties"):
+                continue
+
+            if not snapshot:
+                if base_name.startswith("maven-metadata.xml"):
+                    continue
+
+            file_list.append(file)
 
     # Perform parallel upload
     upload_start = time.time()