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
		
	
		
			
				
	
	
		
			68 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
load("//tools/bzl:genrule2.bzl", "genrule2")
 | 
						|
load("//tools/bzl:gwt.bzl", "gwt_module")
 | 
						|
 | 
						|
SRC = "src/main/java/org/eclipse/jgit/"
 | 
						|
 | 
						|
gwt_module(
 | 
						|
    name = "client",
 | 
						|
    srcs = [
 | 
						|
        SRC + "diff/Edit_JsonSerializer.java",
 | 
						|
        SRC + "diff/ReplaceEdit.java",
 | 
						|
    ],
 | 
						|
    gwt_xml = SRC + "JGit.gwt.xml",
 | 
						|
    visibility = ["//visibility:public"],
 | 
						|
    deps = [
 | 
						|
        ":Edit",
 | 
						|
        "//lib:gwtjsonrpc",
 | 
						|
        "//lib/gwt:user",
 | 
						|
    ],
 | 
						|
)
 | 
						|
 | 
						|
gwt_module(
 | 
						|
    name = "Edit",
 | 
						|
    srcs = [":jgit_edit_src"],
 | 
						|
    visibility = ["//visibility:public"],
 | 
						|
)
 | 
						|
 | 
						|
genrule2(
 | 
						|
    name = "jgit_edit_src",
 | 
						|
    outs = ["edit.srcjar"],
 | 
						|
    cmd = " && ".join([
 | 
						|
        "unzip -qd $$TMP $(location //lib/jgit/org.eclipse.jgit:jgit-source) " +
 | 
						|
        "org/eclipse/jgit/diff/Edit.java",
 | 
						|
        "cd $$TMP",
 | 
						|
        "zip -Dq $$ROOT/$@ org/eclipse/jgit/diff/Edit.java",
 | 
						|
    ]),
 | 
						|
    tools = ["//lib/jgit/org.eclipse.jgit:jgit-source"],
 | 
						|
)
 | 
						|
 | 
						|
java_library(
 | 
						|
    name = "server",
 | 
						|
    srcs = [
 | 
						|
        SRC + x
 | 
						|
        for x in [
 | 
						|
            "diff/EditDeserializer.java",
 | 
						|
            "diff/ReplaceEdit.java",
 | 
						|
            "internal/storage/file/WindowCacheStatAccessor.java",
 | 
						|
            "lib/ObjectIdSerialization.java",
 | 
						|
        ]
 | 
						|
    ],
 | 
						|
    visibility = ["//visibility:public"],
 | 
						|
    deps = [
 | 
						|
        "//lib:gson",
 | 
						|
        "//lib/jgit/org.eclipse.jgit:jgit",
 | 
						|
    ],
 | 
						|
)
 | 
						|
 | 
						|
java_test(
 | 
						|
    name = "jgit_patch_tests",
 | 
						|
    srcs = glob(["src/test/java/**/*.java"]),
 | 
						|
    test_class = "org.eclipse.jgit.diff.EditDeserializerTest",
 | 
						|
    visibility = ["//visibility:public"],
 | 
						|
    deps = [
 | 
						|
        ":server",
 | 
						|
        "//lib:junit",
 | 
						|
        "//lib/jgit/org.eclipse.jgit:jgit",
 | 
						|
    ],
 | 
						|
)
 |