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
2
votes
1 answer

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 toolchain target such that I can pass it via…
rumbleD5
  • 37
  • 5
2
votes
1 answer

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", "http_archive") RULES_JVM_EXTERNAL_TAG = "2.8" RULES_JVM_EXTERNAL_SHA =…
1
vote
1 answer

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 determine the dep name? In this case I'm doing: deps =…
gph
  • 1,045
  • 8
  • 25
1
vote
0 answers

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", ], deps = [ "A", "B", "C", "D", …
Frank P.
  • 503
  • 5
  • 21
1
vote
1 answer

bazel running out of memory and crashing when running coverage

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 matter and tests can run in series instead of…
AhmFM
  • 1,552
  • 3
  • 23
  • 53
1
vote
1 answer

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 = glob(["src/main/java/**"]), args =…
90abyss
  • 7,037
  • 19
  • 63
  • 94
1
vote
1 answer

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 Artifactory. How can I use that (non Bazel) protobuf…
90abyss
  • 7,037
  • 19
  • 63
  • 94
1
vote
1 answer

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 looks like this: bazel run --java_language_version="15"…
rumbleD5
  • 37
  • 5
1
vote
0 answers

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 generation we will have something like this: //…
VCODE
  • 535
  • 5
  • 19
1
vote
0 answers

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 --sandbox_debug --build_runfile_links --combined_report=lcov…
rishi007bansod
  • 1,283
  • 2
  • 19
  • 45
1
vote
0 answers

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 &> /app/logs/celery.log & the celery has been installed using pip_install and…
E_K
  • 2,159
  • 23
  • 39
1
vote
1 answer

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 ChildProcess.spawn…
tim117
  • 244
  • 2
  • 14
1
vote
1 answer

Is it possible to use bazel query to output the full syntax for an implicit (or any) rule?

My goal is to write a new explicit rule that is equivalent to an internal rule but with a small modification (embed certain dependencies but not others). Suppose I have a rule like the following: java_binary( name = "cipher_jar", srcs =…
merlin2011
  • 71,677
  • 44
  • 195
  • 329
1
vote
1 answer

What is the difference between maven install and pinned maven install in bazel?

I am trying to understand a bit of internals of bazel jvm external. The bazel documentation was not clear enough for me to understand. What is the difference between the following steps. Step 1 maven_install( # artifacts, repositories, ... …
JavaDeveloper
  • 5,320
  • 16
  • 79
  • 132
1
vote
1 answer

Standalone Shell script working fine but when used is srcs of sh_binary its not working

I have project structure as follows- PROJECT_STRUCTURE Now my_shbin.sh is as below - #!/bin/bash find ../../ \( -name "*.java" -o -name "*.xml" -o -name "*.html" -o -name "*.js" -o -name "*.css" \) | grep -vE "/node_modules/|/target/|/dist/" >>…
1
2 3 4