Add bazel build for ui and junit.http, and the test packages.
A number of different test labels are supported:
api
attributes
dfs
diff
http
lfs
lfs-server
nls
notes
pack
patch
pgm
reftree
revplot
revwalk
storage
submodule
symlinks
transport
treewalk
util
To run all tests:
bazel test //...
To run specific tests, using labels:
bazel test --test_tag_filters=api,dfs,revplot,treewalk //...
Change-Id: Ic41b05a79d855212e67b1b4707e9c6b4dc9ea70d
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
Signed-off-by: Jonathan Nieder <jrn@google.com>
testonly = 1,
srcs = [
"//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.pgm:pgm",
+ "//org.eclipse.jgit.ui:ui",
"//org.eclipse.jgit.archive:jgit-archive",
"//org.eclipse.jgit.http.apache:http-apache",
"//org.eclipse.jgit.http.server:jgit-servlet",
sha1 = "f91b7a4aadc5cf486df6e4634748d7dd7a73f06d",
)
+maven_jar(
+ name = "commons_codec",
+ artifact = "commons-codec:commons-codec:1.4",
+ sha1 = "4216af16d38465bbab0f3dff8efa14204f7a399a",
+)
+
maven_jar(
name = "commons_logging",
artifact = "commons-logging:commons-logging:1.1.3",
artifact = "com.google.code.gson:gson:2.2.4",
sha1 = "a60a5e993c98c864010053cb901b7eab25306568",
)
+
+JETTY_VER = "9.4.1.v20170120"
+
+maven_jar(
+ name = "jetty_servlet",
+ artifact = "org.eclipse.jetty:jetty-servlet:" + JETTY_VER,
+ sha1 = "406a6edc22311629b41e98ab26901574d243d408",
+ src_sha1 = "57cf143c4110e0d43635406a1052013bbf29a4da",
+)
+
+maven_jar(
+ name = "jetty_security",
+ artifact = "org.eclipse.jetty:jetty-security:" + JETTY_VER,
+ sha1 = "677aa94298f42d322e2f19045693a233613537b6",
+ src_sha1 = "933928163506a8d366652fb895e770fcf3f9e8fe",
+)
+
+maven_jar(
+ name = "jetty_server",
+ artifact = "org.eclipse.jetty:jetty-server:" + JETTY_VER,
+ sha1 = "4cf4bea26592de98b9126ac60bc91fb669176a63",
+ src_sha1 = "2035ab117da534f9a525adfaa9f3a5634d202707",
+)
+
+maven_jar(
+ name = "jetty_http",
+ artifact = "org.eclipse.jetty:jetty-http:" + JETTY_VER,
+ sha1 = "c9c9d5b15b3bb41ae9ae588b7aede301b42186f6",
+ src_sha1 = "f1cbf0e1329ed722bf8eba74e4c4b94619dfe8a8",
+)
+
+maven_jar(
+ name = "jetty_io",
+ artifact = "org.eclipse.jetty:jetty-io:" + JETTY_VER,
+ sha1 = "6d2d7c82a4b5306ec7bf2d6eb4b67460fce77240",
+ src_sha1 = "404b560a0d289c904b72d02e2dbb3b9ad73db219",
+)
+
+maven_jar(
+ name = "jetty_util",
+ artifact = "org.eclipse.jetty:jetty-util:" + JETTY_VER,
+ sha1 = "810c4e4275e399feaf6e8bc51aa72645bdc06205",
+ src_sha1 = "b0dea459e5646e9ccf250a236718d720fba7717c",
+)
+java_library(
+ name = "args4j",
+ visibility = [
+ "//org.eclipse.jgit.pgm:__pkg__",
+ "//org.eclipse.jgit.pgm.test:__pkg__",
+ ],
+ exports = ["@args4j//jar"],
+)
+
java_library(
name = "commons-compress",
- visibility = ["//org.eclipse.jgit.archive:__pkg__"],
+ visibility = [
+ "//org.eclipse.jgit.archive:__pkg__",
+ "//org.eclipse.jgit.pgm.test:__pkg__",
+ ],
exports = ["@commons_compress//jar"],
)
+java_library(
+ name = "commons-codec",
+ exports = ["@commons_codec//jar"],
+)
+
+java_library(
+ name = "commons-logging",
+ testonly = 1,
+ visibility = ["//visibility:public"],
+ exports = ["@commons_logging//jar"],
+)
+
java_library(
name = "gson",
visibility = ["//org.eclipse.jgit.lfs.server:__pkg__"],
exports = ["@gson//jar"],
)
+java_library(
+ name = "hamcrest-core",
+ testonly = 1,
+ exports = ["@hamcrest_core//jar"],
+)
+
+java_library(
+ name = "hamcrest-library",
+ testonly = 1,
+ exports = ["@hamcrest_library//jar"],
+)
+
java_library(
name = "httpclient",
- visibility = ["//org.eclipse.jgit.http.apache:__pkg__"],
+ visibility = [
+ "//org.eclipse.jgit.http.apache:__pkg__",
+ "//org.eclipse.jgit.lfs.server.test:__pkg__",
+ "//org.eclipse.jgit.pgm:__pkg__",
+ ],
exports = ["@httpclient//jar"],
)
visibility = [
"//org.eclipse.jgit.http.apache:__pkg__",
"//org.eclipse.jgit.lfs.server:__pkg__",
+ "//org.eclipse.jgit.lfs.server.test:__pkg__",
+ "//org.eclipse.jgit.pgm:__pkg__",
],
exports = ["@httpcore//jar"],
)
exports = ["@javaewah//jar"],
)
+java_library(
+ name = "jetty-http",
+ # TODO: This should be testonly but org.eclipse.jgit.pgm depends on it.
+ visibility = ["//visibility:public"],
+ exports = ["@jetty_http//jar"],
+ runtime_deps = [":commons-codec"],
+)
+
+java_library(
+ name = "jetty-io",
+ # TODO: This should be testonly but org.eclipse.jgit.pgm depends on it.
+ visibility = ["//visibility:public"],
+ exports = ["@jetty_io//jar"],
+)
+
+java_library(
+ name = "jetty-security",
+ # TODO: This should be testonly but org.eclipse.jgit.pgm depends on it.
+ visibility = ["//visibility:public"],
+ exports = ["@jetty_security//jar"],
+)
+
+java_library(
+ name = "jetty-server",
+ # TODO: This should be testonly but org.eclipse.jgit.pgm depends on it.
+ visibility = ["//visibility:public"],
+ exports = ["@jetty_server//jar"],
+)
+
+java_library(
+ name = "jetty-servlet",
+ # TODO: This should be testonly but org.eclipse.jgit.pgm depends on it.
+ visibility = ["//visibility:public"],
+ exports = ["@jetty_servlet//jar"],
+)
+
+java_library(
+ name = "jetty-util",
+ # TODO: This should be testonly but org.eclipse.jgit.pgm depends on it.
+ visibility = ["//visibility:public"],
+ exports = ["@jetty_util//jar"],
+)
+
java_library(
name = "jsch",
visibility = ["//org.eclipse.jgit:__pkg__"],
testonly = 1,
visibility = ["//visibility:public"],
exports = ["@junit//jar"],
+ runtime_deps = [
+ ":hamcrest-core",
+ ":hamcrest-library",
+ ],
)
java_library(
visibility = [
"//org.eclipse.jgit.http.apache:__pkg__",
"//org.eclipse.jgit.http.server:__pkg__",
+ "//org.eclipse.jgit.http.test:__pkg__",
+ "//org.eclipse.jgit.junit.http:__pkg__",
"//org.eclipse.jgit.lfs.server:__pkg__",
+ "//org.eclipse.jgit.lfs.server.test:__pkg__",
+ "//org.eclipse.jgit.pgm:__pkg__",
],
exports = ["@servlet_api_3_1//jar"],
)
visibility = ["//visibility:public"],
exports = ["@log_api//jar"],
)
+
+java_library(
+ name = "slf4j-simple",
+ testonly = 1,
+ visibility = ["//visibility:public"],
+ exports = ["@slf4j_simple//jar"],
+)
+
+java_library(
+ name = "xz",
+ testonly = 1,
+ visibility = ["//visibility:public"],
+ exports = ["@tukaani_xz//jar"],
+)
--- /dev/null
+load(
+ "@com_googlesource_gerrit_bazlets//tools:junit.bzl",
+ "junit_tests",
+)
+
+junit_tests(
+ name = "http",
+ srcs = glob(["tst/**/*.java"]),
+ tags = ["http"],
+ deps = [
+ ":helpers",
+ "//lib:commons-logging",
+ "//lib:jetty-http",
+ "//lib:jetty-io",
+ "//lib:jetty-security",
+ "//lib:jetty-server",
+ "//lib:jetty-servlet",
+ "//lib:jetty-util",
+ "//lib:junit",
+ "//lib:servlet-api",
+ "//lib:slf4j-api",
+ "//lib:slf4j-simple",
+ "//org.eclipse.jgit.http.apache:http-apache",
+ "//org.eclipse.jgit.http.server:jgit-servlet",
+ "//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.junit.http:junit-http",
+ "//org.eclipse.jgit.junit:junit",
+ ],
+)
+
+java_library(
+ name = "helpers",
+ testonly = 1,
+ srcs = glob(["src/**/*.java"]),
+ deps = [
+ "//lib:junit",
+ "//org.eclipse.jgit.http.server:jgit-servlet",
+ "//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.junit.http:junit-http",
+ "//org.eclipse.jgit.junit:junit",
+ ],
+)
--- /dev/null
+package(default_visibility = ["//visibility:public"])
+
+java_library(
+ name = "junit-http",
+ testonly = 1,
+ srcs = glob(["src/**"]),
+ resources = glob(["resources/**"]),
+ # TODO(davido): we want here provided deps
+ deps = [
+ "//lib:jetty-http",
+ "//lib:jetty-security",
+ "//lib:jetty-server",
+ "//lib:jetty-servlet",
+ "//lib:jetty-util",
+ "//lib:junit",
+ "//lib:servlet-api",
+ "//lib:slf4j-api",
+ "//org.eclipse.jgit.http.server:jgit-servlet",
+ "//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.junit:junit",
+ ],
+)
--- /dev/null
+load(
+ "@com_googlesource_gerrit_bazlets//tools:junit.bzl",
+ "junit_tests",
+)
+
+TEST_BASE = ["tst/org/eclipse/jgit/lfs/server/fs/LfsServerTest.java"]
+
+DEPS = [
+ "//org.eclipse.jgit.lfs.test:helpers",
+ "//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.junit:junit",
+ "//org.eclipse.jgit.junit.http:junit-http",
+ "//org.eclipse.jgit.lfs:jgit-lfs",
+ "//org.eclipse.jgit.lfs.server:jgit-lfs-server",
+ "//lib:commons-logging",
+ "//lib:httpcore",
+ "//lib:httpclient",
+ "//lib:junit",
+ "//lib:jetty-http",
+ "//lib:jetty-io",
+ "//lib:jetty-server",
+ "//lib:jetty-servlet",
+ "//lib:jetty-security",
+ "//lib:jetty-util",
+ "//lib:servlet-api",
+]
+
+junit_tests(
+ name = "lfs_server",
+ srcs = glob(
+ ["tst/**/*.java"],
+ exclude = TEST_BASE,
+ ),
+ jvm_flags = [
+ "-Xmx256m",
+ "-Dfile.encoding=UTF-8",
+ ],
+ tags = ["lfs-server"],
+ deps = DEPS + [
+ ":helpers",
+ ],
+)
+
+java_library(
+ name = "helpers",
+ testonly = 1,
+ srcs = TEST_BASE,
+ deps = DEPS,
+)
--- /dev/null
+package(default_visibility = ["//visibility:public"])
+
+load(
+ "@com_googlesource_gerrit_bazlets//tools:junit.bzl",
+ "junit_tests",
+)
+
+junit_tests(
+ name = "lfs",
+ srcs = glob(["tst/**/*.java"]),
+ tags = ["lfs"],
+ deps = [
+ ":helpers",
+ "//lib:junit",
+ "//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.junit:junit",
+ "//org.eclipse.jgit.lfs:jgit-lfs",
+ ],
+)
+
+java_library(
+ name = "helpers",
+ testonly = 1,
+ srcs = glob(["src/**/*.java"]),
+ deps = [
+ "//lib:junit",
+ "//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.junit:junit",
+ "//org.eclipse.jgit.lfs:jgit-lfs",
+ ],
+)
--- /dev/null
+load(
+ "@com_googlesource_gerrit_bazlets//tools:junit.bzl",
+ "junit_tests",
+)
+
+junit_tests(
+ name = "pgm",
+ srcs = glob(["tst/**/*.java"]),
+ jvm_flags = [
+ "-Xmx256m",
+ "-Dfile.encoding=UTF-8",
+ ],
+ tags = ["pgm"],
+ deps = [
+ ":helpers",
+ "//lib:commons-compress",
+ "//lib:javaewah",
+ "//lib:junit",
+ "//lib:slf4j-api",
+ "//lib:slf4j-simple",
+ "//lib:xz",
+ "//org.eclipse.jgit.archive:jgit-archive",
+ "//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.junit:junit",
+ "//org.eclipse.jgit.pgm:pgm",
+ ],
+)
+
+java_library(
+ name = "helpers",
+ testonly = 1,
+ srcs = glob(["src/**/*.java"]),
+ deps = [
+ "//lib:args4j",
+ "//lib:junit",
+ "//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.junit:junit",
+ "//org.eclipse.jgit.pgm:pgm",
+ ],
+)
--- /dev/null
+java_library(
+ name = "pgm",
+ srcs = glob(["src/**"]),
+ resource_strip_prefix = "org.eclipse.jgit.pgm/resources",
+ resources = glob(["resources/**"]),
+ visibility = ["//visibility:public"],
+ deps = [
+ ":services",
+ "//lib:args4j",
+ "//lib:httpclient",
+ "//lib:httpcore",
+ "//lib:jetty-http",
+ "//lib:jetty-io",
+ "//lib:jetty-security",
+ "//lib:jetty-server",
+ "//lib:jetty-servlet",
+ "//lib:jetty-util",
+ "//lib:servlet-api",
+ "//org.eclipse.jgit.archive:jgit-archive",
+ "//org.eclipse.jgit.http.apache:http-apache",
+ "//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.lfs:jgit-lfs",
+ "//org.eclipse.jgit.lfs.server:jgit-lfs-server",
+ "//org.eclipse.jgit.ui:ui",
+ ],
+)
+
+java_import(
+ name = "services",
+ jars = [":services_jar"],
+)
+
+genrule(
+ name = "services_jar",
+ srcs = glob(["META-INF/services/*"]),
+ outs = ["services_jar.jar"],
+ cmd = "r=$$PWD && cd org.eclipse.jgit.pgm && zip -qr $$r/$@ .",
+)
--- /dev/null
+load(":tests.bzl", "tests")
+load(
+ "@com_googlesource_gerrit_bazlets//tools:genrule2.bzl",
+ "genrule2",
+)
+
+PKG = "tst/org/eclipse/jgit/"
+
+HELPERS = glob(["src/**/*.java"]) + [PKG + c for c in [
+ "api/AbstractRemoteCommandTest.java",
+ "diff/AbstractDiffTestCase.java",
+ "internal/storage/file/GcTestCase.java",
+ "internal/storage/file/PackIndexTestCase.java",
+ "internal/storage/file/XInputStream.java",
+ "nls/GermanTranslatedBundle.java",
+ "nls/MissingPropertyBundle.java",
+ "nls/NoPropertiesBundle.java",
+ "nls/NonTranslatedBundle.java",
+ "revwalk/RevQueueTestCase.java",
+ "revwalk/RevWalkTestCase.java",
+ "transport/SpiTransport.java",
+ "treewalk/FileTreeIteratorWithTimeControl.java",
+ "treewalk/filter/AlwaysCloneTreeFilter.java",
+ "test/resources/SampleDataRepositoryTestCase.java",
+ "util/CPUTimeStopWatch.java",
+ "util/io/Strings.java",
+]]
+
+DATA = [
+ PKG + "lib/empty.gitindex.dat",
+ PKG + "lib/sorttest.gitindex.dat",
+]
+
+tests(glob(
+ ["tst/**/*.java"],
+ exclude = HELPERS + DATA
+))
+
+java_library(
+ name = "helpers",
+ testonly = 1,
+ srcs = HELPERS,
+ resources = DATA,
+ deps = [
+ "//lib:junit",
+ "//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.junit:junit",
+ ],
+)
+
+java_import(
+ name = "tst_rsrc",
+ jars = [":tst_rsrc_jar"],
+)
+
+genrule2(
+ name = 'tst_rsrc_jar',
+ cmd = 'o=$$PWD/$@ && tar cf - $(SRCS) | tar -C $$TMP --strip-components=2 -xf - && cd $$TMP && zip -qr $$o .',
+ srcs = glob(['tst-rsrc/**']),
+ outs = ['tst_rsrc.jar',],
+)
--- /dev/null
+load(
+ "@com_googlesource_gerrit_bazlets//tools:junit.bzl",
+ "junit_tests",
+)
+
+def tests(tests):
+ for src in tests:
+ name = src[len('tst/'):len(src)-len('.java')].replace('/', '_')
+ labels = []
+ if name.startswith('org_eclipse_jgit_'):
+ l = name[len('org.eclipse.jgit_'):]
+ if l.startswith('internal_storage_'):
+ l = l[len('internal.storage_'):]
+ i = l.find('_')
+ if i > 0:
+ labels.append(l[:i])
+ else:
+ labels.append(i)
+ if 'lib' not in labels:
+ labels.append('lib')
+
+ additional_deps = []
+ if src.endswith("RootLocaleTest.java"):
+ additional_deps = [
+ '//org.eclipse.jgit.pgm:pgm',
+ '//org.eclipse.jgit.ui:ui',
+ ]
+ if src.endswith("WalkEncryptionTest.java"):
+ additional_deps = [
+ '//org.eclipse.jgit:insecure_cipher_factory',
+ ]
+
+ junit_tests(
+ name = name,
+ tags = labels,
+ srcs = [src],
+ deps = additional_deps + [
+ ':helpers',
+ ':tst_rsrc',
+ '//org.eclipse.jgit:jgit',
+ '//org.eclipse.jgit.junit:junit',
+ '//org.eclipse.jgit.lfs:jgit-lfs',
+ '@hamcrest_core//jar',
+ '@hamcrest_library//jar',
+ '@javaewah//jar',
+ '@junit//jar',
+ '@log_api//jar',
+ '@slf4j_simple//jar',
+ ],
+ jvm_flags = ["-Xmx256m", "-Dfile.encoding=UTF-8"],
+ )
--- /dev/null
+package(default_visibility = ["//visibility:public"])
+
+java_library(
+ name = "ui",
+ srcs = glob(["src/**"]),
+ resource_strip_prefix = "org.eclipse.jgit.ui/resources",
+ resources = glob(["resources/**"]),
+ deps = ["//org.eclipse.jgit:jgit"],
+)