Bazel: Publish to local Maven repository and Google storage bucket TEST PLAN: $ VERBOSE=1 tools/maven/mvn.sh install $ VERBOSE=1 tools/maven/mvn.sh deploy Change-Id: I0b60f9e2137d8755f6e4ca32ff35ec5a5364f4a6
diff --git a/BUILD b/BUILD new file mode 100644 index 0000000..d2e59f3 --- /dev/null +++ b/BUILD
@@ -0,0 +1 @@ +# This file is intended to be empty
diff --git a/VERSION b/VERSION index f4510ea..61d6a75 100644 --- a/VERSION +++ b/VERSION
@@ -1,7 +1 @@ -# Maven style API version (e.g. '2.x-SNAPSHOT'). -# -# Used by :install and :deploy when talking to the destination repository. As -# we currently have no stable releases, we use the "build number" scheme -# described at: -# http://mojo.codehaus.org/versions-maven-plugin/version-rules.html -GITILES_VERSION = '0.1-11' +include_defs('//version.bzl')
diff --git a/WORKSPACE b/WORKSPACE index 24eb0f0..d0b2b5a 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -1,7 +1,7 @@ workspace(name = "gitiles") load("//tools:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e10ae3f85781aa15054be802b2a9f9465b1bf1e0", + commit = "0f87babe07a555425d829c6e7951e296e9e24579", # local_path = "/home/<user>/projects/bazlets" ) load("@com_googlesource_gerrit_bazlets//tools:maven_jar.bzl",
diff --git a/gitiles-servlet/BUILD b/gitiles-servlet/BUILD index d3a7ff3..6b9fdef 100644 --- a/gitiles-servlet/BUILD +++ b/gitiles-servlet/BUILD
@@ -84,4 +84,5 @@ ], pkgs = ["com.google.gitiles"], title = "Gitiles API Documentation", + visibility = ["//visibility:public"], )
diff --git a/tools/maven/BUILD b/tools/maven/BUILD new file mode 100644 index 0000000..07ae8b0 --- /dev/null +++ b/tools/maven/BUILD
@@ -0,0 +1,21 @@ +load("//:version.bzl", "GITILES_VERSION") +load("@com_googlesource_gerrit_bazlets//tools/maven:package.bzl", "maven_package") + +maven_package( + version = GITILES_VERSION, + group = "com.google.gitiles", + repository = "gerrit-maven-repository", + url = "gs://gerrit-maven", + jar = { + "blame-cache": "//blame-cache:lib", + "gitiles-servlet": "//gitiles-servlet:servlet", + }, + src = { + "blame-cache": "//blame-cache:liblib-src.jar", + "gitiles-servlet": "//gitiles-servlet:libservlet-src.jar", + }, + doc = { + "blame-cache": "//blame-cache:javadoc", + "gitiles-servlet": "//gitiles-servlet:javadoc", + }, +)
diff --git a/tools/maven/mvn.sh b/tools/maven/mvn.sh new file mode 100755 index 0000000..93bef01 --- /dev/null +++ b/tools/maven/mvn.sh
@@ -0,0 +1,56 @@ +#!/bin/bash -e + +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if [[ "$#" != "1" ]] ; then + cat <<EOF +Usage: run "$0 COMMAND" from the top of your workspace, +where COMMAND is one of + + install + deploy + +Set VERBOSE in the environment to get more information. + +EOF + + exit 1 +fi + +set -o errexit +set -o nounset + +case "$1" in +install) + command="api_install" + ;; +deploy) + command="api_deploy" + ;; +*) + echo "unknown command $1" + exit 1 + ;; +esac + +if [[ "${VERBOSE:-x}" != "x" ]]; then + set -o xtrace +fi + +bazel build //tools/maven:gen_${command} || \ + { echo "bazel failed to build gen_${command}. Use VERBOSE=1 for more info" ; exit 1 ; } + +export OUTPUT_BASE=`bazel info output_base` +./bazel-genfiles/tools/maven/${command}.sh
diff --git a/version.bzl b/version.bzl new file mode 100644 index 0000000..f4510ea --- /dev/null +++ b/version.bzl
@@ -0,0 +1,7 @@ +# Maven style API version (e.g. '2.x-SNAPSHOT'). +# +# Used by :install and :deploy when talking to the destination repository. As +# we currently have no stable releases, we use the "build number" scheme +# described at: +# http://mojo.codehaus.org/versions-maven-plugin/version-rules.html +GITILES_VERSION = '0.1-11'