Questions tagged [bazel-java]

Questions related to java_* rules in Bazel.

Questions about bazel_library(), bazel_binary() rules and other questions related to building or testing Java code in Bazel.

46 questions
0
votes
1 answer

Java Bazel Build Error : java/toolchains/bootclasspath_classes/DumpPlatformClassPath.class [for host] failed: not all outputs were created or valid

Getting following error while building java bazel project --> $ bazel build :all INFO: Invocation ID: f3087fe5-67a5-4b0f-a3a8-a61b3bbfa869 WARNING:…
rishi007bansod
  • 1,283
  • 2
  • 19
  • 45
0
votes
1 answer

How to specify java META-INF directory and services in bazel?

I am trying to provide my own implementation of the System.LoggerFinder and as far as I know I have to specify the class in some resource file /resources/META-INF/services/java.lang.System$LoggerFinder. Now my implementation is located in its own…
Jo Bo
  • 136
  • 7
0
votes
2 answers

Bazel pass flaky test if 1 out of 3 retries pass

I have a Java based test suite running Bazel 4.2.2, and my goal is to collect code coverage regardless of test flakiness. I tried to add these options: bazel coverage ... --runs_per_test=3 --cache_test_results=no ... but it looks like if 1/3 of…
Dragan R.
  • 598
  • 4
  • 18
0
votes
2 answers

Bazel: How to exclude path from code coverage for Scala / Java?

I am using Bazel with rules_scala. My problem now is how to exclude files from code coverage. So far this is how I am running coverage: rm -rf coverage bazel coverage --combined_report=lcov…
Omer Levi Hevroni
  • 1,935
  • 1
  • 15
  • 33
0
votes
1 answer

Bazel build failing on Apple Mac M1

Facing below issue when running bazel run //api/deployment:mynamespace.apply Please let me know if anyone also faced same issue. Bazel Version:- 4.2.1 Processor:- Apple Mac M1 ERROR:…
akki_java
  • 605
  • 7
  • 17
0
votes
1 answer

What is causing duplicate builds of same target in Bazel?

We are seeing duplicate builds of the same target in Bazel and wondering what could cause this. Here is a sample output: [52,715 / 55,135] 12 action running Bazel package: some-pkg - Target: a_target - Generating files at…
Gunnar
  • 2,264
  • 17
  • 31
0
votes
1 answer

how to find path to Java source code files from JUnit tests execution via Bazel

I'd like to check a text file in our monorepo codebase via JUnit tests. JUnit tests are executed via bazel test command. How can I configure Bazel to pass the source code directory path (not cached compiled JAR file path) to my unit tests? it could…
Poulad
  • 1,149
  • 1
  • 12
  • 22
0
votes
1 answer

bazel - JUnit4Runner inside bazel could be use with junit `Category`?

Bazel has their JUnit4Runner in com.google.testing.junit package which seems to be based on junit4. I tried to use Bazel JUnit4Runner with Categroy Annotation. But not worked for me. And 1 seems to support testIncludeFilterRegexp but not junit's…
ruseel
  • 1,578
  • 2
  • 21
  • 41
0
votes
1 answer

bazel `java_test` rule - test.xml only exits on failed shard?

Trying to run bazel test ... with remote execution and java_test rule. My test sometimes succeeded, sometimes failed. This is another story. But I want to get test.xml for all cases to check elapsed time for each test. test.xml exists on…
ruseel
  • 1,578
  • 2
  • 21
  • 41
0
votes
1 answer

Bazel local JDK permission issue on Jenkins (Linux, CentOS)

I'm seeing a weird permission issue on Jenkins with Bazel. The build is using a CentOS based docker image that I am preparing. 21:56:37 + bazel build //src/main/java:HelloWorld 21:56:42 2021/11/10 20:56:42 Downloading…
Gunnar
  • 2,264
  • 17
  • 31
0
votes
2 answers

java_toolchain: how can I use the Eclipse compiler in a Bazel build

I want to migrate an ant build to Bazel 4.2.1. The ant build uses an Eclipse compiler (ecj-3.27.0). The way to declare a Java compiler in Bazel is java_toolchain. So I had a look at the output of bazel query @bazel_tools//tools/jdk:all and tried to…
hagello
  • 2,843
  • 2
  • 27
  • 37
0
votes
1 answer

While adding the maven dependency in bazel project,unable to running the bazel run @maven//:pin,getting maven_install.json as empty.facing below issue

bazel run @maven//:pin Starting local Bazel server and connecting to it... INFO: Analyzed target @maven//:pin (7 packages loaded, 26 targets configured). INFO: Found 1 target... Target @maven//:pin…
0
votes
1 answer

How to extract resources from jar in bazel

I have different modules in my project which are generating config files as a JSON which are part of java_libarary. I need to copy this generated JSON files to a new module using bazel build. I am thinking algorithm to do that as : Read all…
Prakash Panjwani
  • 2,540
  • 5
  • 23
  • 34
0
votes
1 answer

How to enable doclint in Bazel

It seems to me that doclint is not enabled by default. For instance, this code should fail. /** * List of errors: *
  • Unclosed list */ static final class FooBar{} How to turn on doclint in Bazel?
rds
  • 26,253
  • 19
  • 107
  • 134
-1
votes
1 answer

Getting a "Using type x from an indirect dependency" in java_test_suite even when x is declared under dependency

My CustomTest.java has this import: com.google.protobuf.Timestamp I'm using java_test_suite to run tests in my BUILD file like so: java_test_suite( name = "all-tests", srcs = glob(["src/test/java/**/*.java"]), runner = "junit5", …
90abyss
  • 7,037
  • 19
  • 63
  • 94