Skip to content

Commit

Permalink
move spotbugs java_binary to userspace
Browse files Browse the repository at this point in the history
  • Loading branch information
nlou9 committed Dec 17, 2024
1 parent 8a64b7a commit 31e6054
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/spotbugs.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 26 additions & 3 deletions example/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
# Automatically apply --config=linux, --config=windows etc
common --enable_platform_specific_config

# Don't depend on a JAVA_HOME pointing at a system JDK
# Aspect recommended Bazel flags when using rules_java and rules_jvm_external

# Pin java versions to desired language level
# See https://bazel.build/docs/bazel-and-java#java-versions
# and https://en.wikipedia.org/wiki/Java_version_history

# What version of Java are the source files in this repo?
# See https://bazel.build/docs/user-manual#java-language-version
common --java_language_version=17

# The Java language version used to build tools that are executed during a build
# See https://bazel.build/docs/user-manual#tool-java-language-version
common --tool_java_language_version=17

# The version of JVM to use to execute the code and run the tests.
# NB: The default value is local_jdk which is non-hermetic.
# See https://bazel.build/docs/user-manual#java-runtime-version
common --java_runtime_version=remotejdk_17

# The version of JVM used to execute tools that are needed during a build.
# See https://bazel.build/docs/user-manual#tool-java-runtime-version
common --tool_java_runtime_version=remotejdk_17

# Repository rules, such as rules_jvm_external: put Bazel's JDK on the path.
# Avoids non-hermeticity from dependency on a JAVA_HOME pointing at a system JDK
# see https://github.com/bazelbuild/rules_jvm_external/issues/445
build --repo_env=JAVA_HOME=../bazel_tools/jdk
common --java_runtime_version=remotejdk_11
common --repo_env=JAVA_HOME=../bazel_tools/jdk

common --incompatible_enable_proto_toolchain_resolution
common --@aspect_rules_ts//ts:skipLibCheck=always
Expand Down
7 changes: 7 additions & 0 deletions example/tools/lint/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ java_binary(

java_binary(
name = "spotbugs",
jvm_flags = [
"--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
],
main_class = "edu.umd.cs.findbugs.LaunchAppropriateUI",
runtime_deps = [
"@spotbugs//:jar",
Expand Down
2 changes: 1 addition & 1 deletion example/tools/lint/linters.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ clang_tidy_global_config = lint_clang_tidy_aspect(
)

spotbugs = lint_spotbugs_aspect(
binary = "@@spotbugs//:bin",
binary = "@@//tools/lint:spotbugs",
exclude_filter = "@@//:spotbugs-exclude.xml",
)

Expand Down
17 changes: 1 addition & 16 deletions lint/spotbugs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Finally, declare an aspect for it, typically in `tools/lint/linters.bzl`:
load("@aspect_rules_lint//lint:spotbugs.bzl", "lint_spotbugs_aspect")
spotbugs = lint_spotbugs_aspect(
binary = "@@spotbugs//:bin",
binary = "@@//tools/lint:spotbugs",,
exclude_filter = "@@//:spotbugs-exclude.xml",
)
Expand Down Expand Up @@ -137,21 +137,6 @@ java_import(
"lib/spotbugs.jar",
],
visibility = ["//visibility:public"],
)
java_binary(
name = "bin",
runtime_deps = [
":jar",
],
main_class = "edu.umd.cs.findbugs.LaunchAppropriateUI",
jvm_flags = [
"--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
],
visibility = ["//visibility:public"],
)
""",
)

0 comments on commit 31e6054

Please sign in to comment.