Bazel: Allow to consume jgit from development tree

Now that Bazel build for JGit is fully implemented, we can document
the process of routing the JGit dependency to the development tree
instead of consuming it from Central or ~/.m2 local repository:

1. Activate local jgit repository in WORKSPACE file:

  local_repository(
      name = "jgit",
      path = "/home/<user>/projects/jgit",
  )

2. Uncomment alias to jgit repository in lib/jgit/**/BUILD files.
It shouldn't be needed and is tracked under this issue upstream: [1]:

  alias(
      name = "jgit-alias",
      actual = select({
          "@//lib:jgit-dev": "@jgit//org.eclipse.jgit:jgit",
          "//conditions:default": "@jgit_lib//jar",
      }),
      visibility = ["//visibility:public"],
  )

Test plan:

Update local JGit tree, run tests and verify that local JGit tree
modifications are relfected in gerrit build:

  $ bazel build --define jgit-dev=1 headless

To consume JGit from Central, do not pass jgit-dev=1:

  $ bazel test ...

[1] https://github.com/bazelbuild/bazel/issues/2707
Change-Id: I1b0fee7df802f6cbd54acbb0bc73157e2b8bc7cf
This commit is contained in:
David Ostrovsky
2016-11-06 18:07:10 +01:00
parent ab2fa7cc39
commit e51b745efa
9 changed files with 57 additions and 8 deletions

View File

@@ -2,6 +2,9 @@ java_library(
name = "jgit-servlet",
data = ["//lib:LICENSE-jgit"],
visibility = ["//visibility:public"],
exports = ["@jgit_servlet//jar"],
exports = select({
# "//lib/jgit:dev": ["@jgit//org.eclipse.jgit.http.server:jgit-servlet"],
"//conditions:default": ["@jgit_servlet//jar"],
}),
runtime_deps = ["//lib/jgit/org.eclipse.jgit:jgit"],
)