Implement Bazel build Change-Id: I02b0bc98407f232265210dff01aeefa9331ed4b7
diff --git a/.gitignore b/.gitignore index 79eee44..0966366 100644 --- a/.gitignore +++ b/.gitignore
@@ -6,3 +6,8 @@ /.classpath /.settings /.project +/bazel-bin +/bazel-genfiles +/bazel-wip +/bazel-out +/bazel-testlogs
diff --git a/BUILD b/BUILD new file mode 100644 index 0000000..4223c00 --- /dev/null +++ b/BUILD
@@ -0,0 +1,12 @@ +load("//:tools/bzl/plugin.bzl", "gerrit_plugin") + +gerrit_plugin( + name = "wip", + srcs = glob(["src/main/java/**/*.java"]), + resources = glob(["src/main/resources/**/*"]), + manifest_entries = [ + "Gerrit-PluginName: wip", + "Gerrit-Module: com.googlesource.gerrit.plugins.wip.Module", + "Gerrit-HttpModule: com.googlesource.gerrit.plugins.wip.HttpModule", + ], +)
diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..ec6b8fb --- /dev/null +++ b/WORKSPACE
@@ -0,0 +1,44 @@ +workspace(name = "wip") + +load("//:bazlets.bzl", "load_bazlets") + +load_bazlets( + commit = "8a4cbdc993f41fcfe7290e7d1007cfedf8d87c18", + # local_path = "/home/<user>/projects/bazlets", +) + +# Snapshot Plugin API +load( + "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl", + "gerrit_api_maven_local", +) + +# Release Plugin API +#load( +# "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", +# "gerrit_api", +#) + +load( + "@com_googlesource_gerrit_bazlets//:gerrit_gwt.bzl", + "gerrit_gwt", +) + +# Load release Plugin API +#gerrit_api() + +# Load snapshot Plugin API +gerrit_api_maven_local() + +gerrit_gwt() + +load( + "@com_googlesource_gerrit_bazlets//tools:maven_jar.bzl", + "maven_jar", +) + +maven_jar( + name = "commons_dbcp", + artifact = "commons-dbcp:commons-dbcp:1.4", + sha1 = "30be73c965cc990b153a100aaaaafcf239f82d39", +)
diff --git a/bazlets.bzl b/bazlets.bzl new file mode 100644 index 0000000..e14e488 --- /dev/null +++ b/bazlets.bzl
@@ -0,0 +1,17 @@ +NAME = "com_googlesource_gerrit_bazlets" + +def load_bazlets( + commit, + local_path = None + ): + if not local_path: + native.git_repository( + name = NAME, + remote = "https://gerrit.googlesource.com/bazlets", + commit = commit, + ) + else: + native.local_repository( + name = NAME, + path = local_path, + )
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md index 979f2f8..0d77649 100644 --- a/src/main/resources/Documentation/build.md +++ b/src/main/resources/Documentation/build.md
@@ -1,7 +1,47 @@ Build ===== -This plugin can be built with Buck or Maven. +This plugin can be built with Bazel, Buck or Maven. + +Bazel +----- + +### Build standalone + +To build the plugin, issue the following command: + +``` + bazel build @PLUGIN@ +``` + +The output is created in + +``` + bazel-genfiles/@PLUGIN@.jar +``` + +### Build in Gerrit tree + +Clone or link this plugin to the plugins directory of Gerrit's source +tree, and issue the command: + +``` + bazel build plugins/@PLUGIN@ +``` + +The output is created in + +``` + bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.jar0 +``` + +This project can be imported into the Eclipse IDE. +Add the plugin name to the `CUSTOM_PLUGINS` set in +Gerrit core in `tools/bzl/plugins.bzl`, and execute: + +``` + ./tools/eclipse/project.py +``` Buck ----
diff --git a/tools/bazel.rc b/tools/bazel.rc new file mode 100644 index 0000000..4ed16cf --- /dev/null +++ b/tools/bazel.rc
@@ -0,0 +1,2 @@ +build --workspace_status_command=./tools/workspace-status.sh +test --build_tests_only
diff --git a/tools/bzl/BUILD b/tools/bzl/BUILD new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tools/bzl/BUILD
@@ -0,0 +1 @@ +
diff --git a/tools/bzl/plugin.bzl b/tools/bzl/plugin.bzl new file mode 100644 index 0000000..2b1df8c --- /dev/null +++ b/tools/bzl/plugin.bzl
@@ -0,0 +1,4 @@ +load( + "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl", + "gerrit_plugin", +)
diff --git a/tools/workspace-status.sh b/tools/workspace-status.sh new file mode 100755 index 0000000..67b2fd1 --- /dev/null +++ b/tools/workspace-status.sh
@@ -0,0 +1,17 @@ +#!/bin/bash + +# This script will be run by bazel when the build process starts to +# generate key-value information that represents the status of the +# workspace. The output should be like +# +# KEY1 VALUE1 +# KEY2 VALUE2 +# +# If the script exits with non-zero code, it's considered as a failure +# and the output will be discarded. + +function rev() { + cd $1; git describe --always --match "v[0-9].*" --dirty +} + +echo "STABLE_BUILD_WIP_LABEL" $(rev .)