Bug fixes to bazel publishing
Change-Id: I3c235a1ba009b998035e6d0db85818308cf0ecde
diff --git a/tools/build/bazel/osgi_java_library.bzl b/tools/build/bazel/osgi_java_library.bzl
index 523224c..d1b86d3 100644
--- a/tools/build/bazel/osgi_java_library.bzl
+++ b/tools/build/bazel/osgi_java_library.bzl
@@ -474,7 +474,7 @@
# rule for building javadocs
if not suppress_javadocs:
- javadoc(name = name + "-javadocs", deps = deps, srcs = srcs, visibility = visibility)
+ javadoc(name = name + "-javadoc", deps = deps, srcs = srcs, visibility = visibility)
if test_srcs != []:
native.java_library(
diff --git a/tools/build/bazel/publish_catalog.bzl b/tools/build/bazel/publish_catalog.bzl
index 7f0db76..b36559f 100644
--- a/tools/build/bazel/publish_catalog.bzl
+++ b/tools/build/bazel/publish_catalog.bzl
@@ -26,7 +26,7 @@
c = artifact_id.split("-")
- if len(c) > 1 and c[len(c)-1] in ("javadocs", "sources", "tests", "pom"):
+ if len(c) > 1 and c[len(c)-1] in ("javadoc", "sources", "tests", "pom"):
classifier = c[len(c)-1]
artifact_id = "-".join(c[:len(c)-1])
if classifier == "pom":
diff --git a/tools/build/onos-publish-catalog b/tools/build/onos-publish-catalog
index c095bdb..410e022 100755
--- a/tools/build/onos-publish-catalog
+++ b/tools/build/onos-publish-catalog
@@ -3,6 +3,8 @@
# Generates a catalog for publishing ONOS artifacts to a Maven repository.
# -----------------------------------------------------------------------------
+set -e -o pipefail
+
CATALOG=${1:-/tmp/onos.catalog}
rm -f $CATALOG
diff --git a/tools/build/onos-upload-artifacts.py b/tools/build/onos-upload-artifacts.py
index 54c3c33..0cd6c3e 100755
--- a/tools/build/onos-upload-artifacts.py
+++ b/tools/build/onos-upload-artifacts.py
@@ -53,10 +53,10 @@
output.close()
-def generate_metadata_files(input_file):
+def generate_metadata_files(input_file, dest):
# create a temporary directory to hold the metadata files
global tempdir
- base_metadata_filename = tempdir + "/" + os.path.basename(input_file)
+ base_metadata_filename = tempdir + "/" + os.path.basename(dest)
files = []
@@ -77,6 +77,11 @@
hashlib_compute(sha1, input_file, sha1_filename)
files.append(sha1_filename)
+ # generate the base artifact
+ base_artifact_filename = base_metadata_filename
+ shutil.copyfile(input_file, base_artifact_filename)
+ files.append(base_artifact_filename)
+
return files
@@ -102,20 +107,25 @@
def stage_file(file, repo_id, dest):
+ filename_in_repo = os.path.dirname(dest) + "/" + os.path.basename(file)
if destination_repo_url is not None:
# deploy to Nexus repo
upload_base = "https://" + destination_repo_url + "/service/local/staging/deployByRepositoryId"
- url = upload_base + "/" + repo_id + "/" + dest
+ url = upload_base + "/" + repo_id + "/" + filename_in_repo
headers = {'Content-Type': 'application/xml'}
with open(file, 'rb') as f:
- r = requests.post(url, files={file: f}, headers=headers, auth=(SONATYPE_USER, SONATYPE_PASSWORD))
+ r = requests.post(url, data=f.read(), headers=headers, auth=(SONATYPE_USER, SONATYPE_PASSWORD))
+ if r.status_code != 201:
+ print (r.status_code)
+ print (r.text)
+ sys.exit(1)
else:
# deploy to local repo
- dest_local_repo = os.path.expanduser(local_maven_repo + "/" + dest)
- dest_local_repo_dir = os.path.dirname(dest_local_repo)
- if not os.path.isdir(dest_local_repo_dir):
- os.makedirs(dest_local_repo_dir)
- shutil.copyfile(src, dest_local_repo)
+ file_in_local_repo = os.path.expanduser(local_maven_repo + "/" + filename_in_repo)
+ dir_in_local_repo = os.path.dirname(file_in_local_repo)
+ if not os.path.isdir(dir_in_local_repo):
+ os.makedirs(dir_in_local_repo)
+ shutil.copyfile(src, file_in_local_repo)
def stage_files(files, dest):
@@ -124,8 +134,8 @@
def upload_file(src, dest):
- files = generate_metadata_files(src)
- files.append(src)
+ print ("publishing: " + dest.replace("org/onosproject", ""))
+ files = generate_metadata_files(src, dest)
stage_files(files, dest)