60 questions
0
votes
0
answers
30
views
How to get individual time for test methods when the test class times out (only class-level timeout info shown, need to identify slow test methods)
I am working with junit tests and I have a timeout on them (300s). But when the test timeout I get the information on class level. But I want information on individual test method on how much time it ...
0
votes
0
answers
19
views
Trying to run a kt_jvm_binary with remotejdk11 but it does not appear in the runfiles at runtime
my .bazelversion is 8.3.1
Given this kind of a build file:
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library", "kt_jvm_binary")
kt_jvm_binary(
name = "...
2
votes
0
answers
98
views
Why can't bazel find @local_jdk repo
I have been trying to follow tutorials online for how to add the Java JNI header to a cc_library but I keep getting an error of
no such package '@@[unknown repo 'local_jdk' requested from @@]//': The ...
0
votes
0
answers
76
views
configurable attribute "actual" in @google_protobuf3//:google-protos doesn't match this configuration
Facing below issue on bazel build on M1 Pro (MacOS - 13.6.5)
bazel build :all --config=mac64
WARNING: Option '...
0
votes
1
answer
86
views
Use sqlite JDBC with Bazel
I have the following structure:
BUILD.bazel
MODULE.bazel
com/test/TestMain.java
com/test/assets/
BUILD.bazel
load("@rules_java//java:defs.bzl", "java_binary")
package(...
0
votes
1
answer
197
views
Is it possible to specify input files in bazel with $ in the filename?
I would like to specify input files to bazel with names like ContextFinder$5.class.
Consider the following bazel BUILD file:
package(<redacted>)
filegroup(
name = "class_overrides"...
0
votes
1
answer
129
views
bazel run @maven//:pin results in error: FileNotFoundException
➜ simpleproject git:(main) ✗ bazel run @maven//:pin --verbose_failures
ERROR: /private/var/tmp/_bazel_pk/2535445c9817f31453336c07943a57d6/external/rules_jvm_external~/private/extensions/maven.bzl:450:...
0
votes
1
answer
203
views
Cannot locate runfiles directory in bazel java
I have a genrule which takes in a java binary as a src and uses $(location ) as the cmd. When the genrule is executed, I get Cannot locate runfiles directory. (Set $JAVA_RUNFILES to inhibit searching.)...
0
votes
1
answer
189
views
Bazel dependency analysis
I think a build error is being caused by dependency conflict. I've found the older version of a library using bazel query. These 2.14.0 versions of jackson are conflicting with new versions. I'll try ...
0
votes
1
answer
109
views
GRPC circular dependencies in Bazel
I have several dependencies that pull in grpc and the circular dependency errors in Bazel are making it impossible to make progress at a reasonable pace. Most recently I started getting this error:
...
0
votes
1
answer
225
views
Accessing files listed in a data block
I have seen a few questions about data dependencies in bazel but nothing I have tried seems to work.
My project has this structure:
|-- BUILD.bazel
|-- resources
| |-- gold
| `-- inputs
| `--...
1
vote
0
answers
306
views
Unable to configure custom java toolchain with bazel
I'm trying to use custom zulu jdk java toolchain with bazel but haven't been successful. I must admit I'm not very familiar with Java and hence not really sure what's missing.
Here's the ...
2
votes
0
answers
211
views
IntelliJ IDEA Bazel Test: How to stop optimizing out variables while at a breakpoint in the debugger?
When debugging our Kotlin code while running a test, hitting a breakpoint shows some values get optimized out if they are not called further down in the scope. While ideal for complied code, this is a ...
0
votes
1
answer
223
views
How do I pass arguments to Bazel java wrapper?
I’m using Bazel to build JanusGraph. For Janusgraph to find all the config files it needs to have them on the classpath. It finds the files via File class but that can’t read from a jar. Basel docs ...
0
votes
0
answers
37
views
How can I stop java_test using cached test code rather than rebuilding the test code
I'm having problems with the java_test rule.
Given a very simple scenario of a class called Code, and a test case called Test, after running the test and either failing or succeeding, if I change the ...
0
votes
0
answers
167
views
Bazel kotlin build target cannot resolve classes from intellij SDK
I am developing an intellij plugin, and I use bazel to build my project.
When I run the build, I see a lot of errors related to class in intellij SDK. Such as:
error: unresolved reference: VirtualFile
...
0
votes
1
answer
416
views
How to query Bazel for the (absolute) `JAVE_HOME` like path to the remote JDK of whatever Java Toolchain the workspace is configured to use?
How can one query Bazel to obtain the absolute path to the JDK which its Java Rules use? I'm aware that there can be several, and would like to obtain "the one it uses to run tests under".
...
1
vote
0
answers
338
views
Permissions issues with @bazel_tools and @remote_java_tools_linux
I'm using Bazel to build my project, and I notice that on some incremental builds I see the following error:
Analyzing: target <target I'm building>
INFO: Repository remote_java_tools_linux ...
1
vote
1
answer
864
views
How to create Java library in Bazel from generated Java files
I have a custom Bazel rule which generates a bunch of Java files. The rule is something like this:
def _generator_java_impl(ctx):
tree = ctx.actions.declare_directory(ctx.attr.name + "_srcs&...
1
vote
1
answer
184
views
How to find a bazel dependency name for a maven target?
I'm adding handlebars to a Java project using bazel. The WORKSPACE installs the maven dependency:
...
"com.github.jknack:handlebars.java:4.3.1",
...
Within the BUILD file, how do I ...
0
votes
0
answers
183
views
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 = ["@...
0
votes
1
answer
1k
views
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:...
0
votes
0
answers
5k
views
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 ...
1
vote
0
answers
608
views
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 ...
4
votes
0
answers
626
views
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,...
0
votes
0
answers
256
views
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):
...
0
votes
1
answer
795
views
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:
...
1
vote
0
answers
217
views
Using `rules_scala` + Bazel, how to bundle transitive JARs that are exported as part of a `scala_library` target, without going full `_deploy.jar`?
Let's say I have a library such as:
scala_library(
name = "my_favorite_scala_library",
srcs = glob(["*.scala"]),
exports = [
"A",
"B"...
0
votes
2
answers
2k
views
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"])...
1
vote
1
answer
2k
views
bazel running out of memory and crashing when running coverage [duplicate]
When running Bazel coverage on service code, it is crashing on Jenkins pods and also local mac. I want to know does Bazel provide any run efficiency flags to be used in these cases where time does not ...
1
vote
1
answer
1k
views
Bazel: How to pass relative path of a file as an "args" to java_binary?
I have a file hello.txt that lives in src/main/resources folder.
I am using a java_binary rule and need to pass this hello.txt file as an argument.
java_binary(
name = "Hello",
srcs =...
-1
votes
1
answer
1k
views
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([...
1
vote
1
answer
978
views
How to use protobuf from remote Artifactory?
There is a protobuf that my project needs. The protobuf itself is in another repo altogether owned by a completely different team. However they do publish their artifacts on my company's internal ...
0
votes
1
answer
610
views
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 ...
1
vote
1
answer
907
views
Why I am getting java.lang.UnsupportedClassVersionError while trying to run bazel java target?
I am trying to compile and run the example java project. Instead of using the default JDK I have chosen JDK 15 by providing the setting --java_language_version="15". The complete command ...
2
votes
1
answer
2k
views
How to define a local Java Toolchain in Bazel
I want to use a specific Azul Zulu JDK for my Java builds. Therefore I have stored it in my repository locally e.g. under tools/zulu19.30.11-ca-jdk19.0.1-macosx_x64. Now I want to configure a java ...
2
votes
0
answers
1k
views
Reading the content of directory declared with `actions.declare_directory`
Imagine I have a java_binary target triggered by a custom rule that generates source code and places the generated sources under a directory, let's call it "root".
So after the code ...
-1
votes
1
answer
134
views
Executing java program and writing files inside the files structure of Bazel
I’m using a “ctx.action.run” command to execute a java.jar program.
The java program uses as imputs “bazel-bin/src/files”, which are a preprocessing step of a special C precompilation. This java edit ...
0
votes
1
answer
764
views
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:...
0
votes
1
answer
316
views
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: /home/ess/.cache/bazel/_bazel_ess/...
1
vote
0
answers
209
views
Setting threshold for Coverage in Bazel Java Project
I am using following command for running coverage for complete Java project module.
bazel coverage ... --compilation_mode=dbg --subcommands --announce_rc --verbose_failures --jobs=auto --...
1
vote
1
answer
504
views
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$...
1
vote
2
answers
3k
views
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 --...
0
votes
2
answers
2k
views
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 --...
2
votes
0
answers
331
views
Does Bazel sh_binary allow calling of scripts that depends on some pip packages?
I have the following sh_binary
sh_binary(
name="worker",
srcs=["worker.sh"],
)
and the worker.sh looks like
#!/bin/bash
celery -A twoopstracker worker -l INFO &> /...
2
votes
2
answers
7k
views
java-language-server vscode extension - Starting client failed
I'm trying to use the java-language-server vscode extension, but I am getting an error that the extension is not starting up:
[Error - 11:07:14 AM] Starting client failed
Error: spawn UNKNOWN
at ...
2
votes
1
answer
489
views
What is RULES_JVM_EXTERNAL_TAG and RULES_JVM_EXTERNAL_SHA in bazel WORKSPACE file?
I'm trying to move to bazel from maven. I saw the tutorial in bazel documentation and it has a sample WORKSPACE file. link
load("@bazel_tools//tools/build_defs/repo:http.bzl", "...
0
votes
1
answer
826
views
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: /private/var/tmp/...
0
votes
1
answer
2k
views
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: ...
0
votes
1
answer
2k
views
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 ...