bazel-contrib / bazel-contrib/rules_jvm

gazelle plugin creates `java_library` with name='PACKAGENAME', but tries to use an nonexisting `java_library` named `:PACKAGENAME-test-lib`

Open
#304 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
54
Forks
98
Avg merge
6d 2h
Merged PRs (30d)
7

Description

This is happening only in test folders.

Like the title says, gazelle creates a library with the package name, but tries to use what seems to be a library that would be created when using `java_test_suite`.
We do not use `java_test_suite`, so in our case gazelle doesn't do the right thing:

```py
java_binary(
name = "TextFormatCommand",
testonly = True,
main_class = "some.class.path.text.TextFormatCommand",
visibility = ["//visibility:public"],
runtime_deps = [":text-test-lib"],
)

java_library(
name = "text",
testonly = True,
srcs = ["TextFormatCommand.java"],
deps = [
"@jvm_deps//:com_google_guava_guava",
"@jvm_deps//:info_picocli_picocli",
"@jvm_deps//:junit_junit",
],
)
```

Any way we can configure this behaviour?
Or a known fix for this issue?

Other then that, gazelle for java works pretty well!

Thank you

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the generated BUILD content in a Java test folder and trace the Gazelle Java generation path for test targets. Check how the `java_library` name and `:PACKAGENAME-test-lib` dependency are selected. Done means generation either references an existing target or provides a documented configuration that matches projects not using `java_test_suite`.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.