1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
package(
default_visibility = ["//visibility:legacy_public"],
)
licenses(["notice"])
filegroup(
name = "bazel-srcs",
testonly = 0,
srcs = glob(
["**"],
exclude = ["BUILD"],
),
visibility = ["//third_party/bazel:__subpackages__"],
)
filegroup(
name = "srcs",
srcs = glob(["**"]),
)
filegroup(
name = "embedded_tools",
srcs = [
"JacocoCoverage_jarjar_deploy.jar",
],
)
filegroup(
name = "jacoco_coverage_runtime",
srcs = ["JacocoCoverage_deploy.jar"],
)
# Bazel custom Jacoco runner used to provide proper initialization and lcov
# report generation when using offline Jacoco instrumentation.
# This target should not be used as a dependency (except when writing tests for
# it).
#
# An implicit dependency of all "java_binary" rules.
java_binary(
name = "JacocoCoverage",
srcs = [
"BranchCoverageDetail.java",
"BranchDetailAnalyzer.java",
"BranchExp.java",
"ClassProbesMapper.java",
"CovExp.java",
"JacocoCoverageRunner.java",
"JacocoLCOVFormatter.java",
"MethodProbesMapper.java",
"ProbeExp.java",
],
deps = [
":bitfield",
"//third_party/java/jacoco:blaze-agent",
"//third_party/java/jacoco:core",
"//third_party/java/jacoco:report",
],
)
java_library(
name = "bitfield",
srcs = [
"BitField.java",
"IllegalStringException.java",
],
deps = [
"//third_party:apache_commons_lang",
],
)
genrule(
name = "Jacoco_jarjar",
srcs = [
":JacocoCoverage_deploy.jar",
":JacocoCoverage.jarjar",
],
outs = ["JacocoCoverage_jarjar_deploy.jar"],
cmd = "\n".join([
# Bazel 0.4.3 contains two bugs: a quoting bug in the Java cmd.exe
# wrapper script that makes it unable to handle $ signs in paths (#2306)
# and one that makes it occasionally put $ signs in the output base
# (#2342).
#
# These two collude to make it impossible to run built Java binaries on
# Windows if the output base happens to contain a $ sign.
#
# Thus, don't call jarjar when on Windows. This makes Java coverage not
# work if the code under test uses libraries the test runner also does
# (e.g. ASM).
#
# TODO(lberki): Remove this once a Bazel version with a fix to either of
# these bugs is out.
#
# Additionally, there is a hard-coded path to /bin/bash which is wrong on
# freebsd; so disable there as well until a fixed version is in there as
# well.
# TODO(aehlig): fix and remove once a version with the fix is out.
#
# We don't invoke jarjar_bin directly because this command is invoked
# during bootstrapping when we don't have build-runfiles, thus no
# runfiles trees. The Java launcher script looks in the runfiles tree
# for the jars (and rightfully so), thus, invoking the binary directly
# won't work.
"if [[ $$(uname -a) =~ MSYS ]] || [[ $$(uname -a) =~ CYGWIN ]] || [[ $$(uname -a) =~ freebsd ]]; then",
" cp \"$(location :JacocoCoverage_deploy.jar)\" \"$@\";",
"else",
" \"$(JAVA)\" -jar \"$(location //third_party/java/jarjar:jarjar_bin_deploy.jar)\" process \"$(location :JacocoCoverage.jarjar)\" \"$(location :JacocoCoverage_deploy.jar)\" \"$@\"",
"fi",
]),
tools = [
"//third_party/java/jarjar:jarjar_bin_deploy.jar",
"//tools/defaults:jdk",
],
)
|