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
0 answers

Running a binary from custom rule implementation depending on JRE/JDK doesn't find it through the PATH

Suppose I am having a simple sh_binary that is invoking a Java binary that depends on JRE/JDK: sh_binary( name = "tool_wrapper", srcs = ["tool_wrapper.sh"], data = ["@external//tools:binary"], args = ["$(location…
rumbleD5
  • 37
  • 5
0
votes
0 answers

bazel coverage is failing while bazel test is working fine

I have the pytest file called sample_unit_test.py and BUILD.bazel mentioning the target and other details. When I run bazel test //folder_path:sample_unit_test, it is passing the test but when I run bazel coverage with the same target failing with…
0
votes
1 answer

How to access a file from resources folder in test in springboot

My file "products.yml" is located in src/test/resources/configs folder. I have defined config import in my application.yml in springboot spring: config: import: - optional:configtree:src/test/resources/configs/ I am trying to get this…
0
votes
0 answers

Passing absolute path to a directory from genrule in a Bazel BUILD file

I'm trying to set an environment variable for my mocha_test rule in a Bazel BUILD file to provide the absolute path to a directory that's created using a genrule. The genrule is responsible for creating the directory and processing some…
rakib
  • 131
  • 3
  • 10
0
votes
0 answers

How to have multiple versions of external maven dependencies with Bazel?

I am currently using rules_jvm_external in order to use external maven dependencies with Bazel. My use-case is to do a major upgrade of a dependency to do a PoC project. What is the best way to get the dependency just for my PoC project. From the…
0
votes
0 answers

java.lang.RuntimeException while running Quarkus with Bazel

We have a monorepo where we have recently added the MAVEN_REPOS to be used with Bazel. We are using Quarkus 2.9.2.Final. So I am planning to create a CLI Application using Quarkus. But whenever I am running them I am getting a runtime exception.…
Debopam Mitra
  • 1,842
  • 4
  • 27
  • 51
0
votes
0 answers

bazel build hanging on "Fetching repository @local_jdk"

I'm new to Bazel. I installed it using "brew install baselisk", as recommended by the official Bazel docs. bazel --version gives bazel 6.1.2. I then followed the official bazel Java tutorial, but when I did "bazel build", it said the following for…
xdavidliu
  • 2,411
  • 14
  • 33
0
votes
0 answers

Bazel ctx.actions.run(..) running windows java executable

I want to run a .exe file in bazel build which requires java to run. This executable creates a directory and some files if run successfully. My ExampleGenerator.bzl def _example_generator_impl(ctx): outputs = [] if ctx.outputs.outDir: …
RAHUL S K
  • 13
  • 4
0
votes
1 answer

Query for Java toolchain details in Bazel

I'd like to use bazel query to get more details about the Java toolchain. Specifically Java source level to be used. From the java_library target I was able to query for the Java toolchain: rule_input:…
Gunnar
  • 2,264
  • 17
  • 31
0
votes
1 answer

How do I query only for the dependencies declared under deps in the BUILD file?

How do I query only for the dependencies declared under deps? For example, given the given target java_library( name = "my-library", srcs = glob(["src/main/java/**/*.java"]), deps = [ ":some-target", …
ugabade
  • 23
  • 4
0
votes
0 answers

Bazel with Java Cucumber

Is there someone who could share some sample project of Java Cucumber tests build in Bazel? I have a working set of tests build using maven but need to transfer them to Bazel and I can't really understand the structure of BUILD files needed in order…
Dosiu
  • 3
  • 2
0
votes
1 answer

Make Bazel maven dependencies not linked, but available in tests

I have a code, which depends on the maven package. I don't want this dependency to be packaged to a resulting JAR. In fact, I want to have only the source code in the resulting package, without all dependencies (the reason for it is that all…
frsv
  • 55
  • 1
  • 10
0
votes
0 answers

Using a custom Java toolchain in shell binary target

I am having a simple shell script that executes a prebuilt binary. The build file looks like this: filegroup( name = "generator_srcs", srcs = glob([ "configuration/**", "features/**", "plugins/**" ]) + [ …
rumbleD5
  • 37
  • 5
0
votes
0 answers

Bazel/java_binary: how to pass a properties file to the java compiler?

I'm using a Bazel toolchain based on ecj. When compiling my sources, I want to use the properties that are saved in a specific file. Therefor I try: java_binary( name = "foo", javacopts = [ "-properties", "$(location…
hagello
  • 2,843
  • 2
  • 27
  • 37
0
votes
1 answer

Why doesn't java_binary propagate runtime dependencies to java_test

I wrote a small application and used java_binary as follows: java_binary( name = "MyCommand", srcs = [ "MyCommand.java", ], visibility = ["//visibility:public"], deps = [ "//src/main/java/com/example/two", …
Setheron
  • 3,520
  • 3
  • 34
  • 52