From e3a4a46ff62b8c7e28539ae690d8d5f2097f8368 Mon Sep 17 00:00:00 2001 From: hvd Date: Mon, 4 Mar 2024 15:14:25 +0100 Subject: [PATCH] Update warnings for java rules This is in preparation for the native java rules being moved out of Bazel. --- WARNINGS.md | 95 +++++++++++++++++++++++++++++--- buildifier/config/config_test.go | 18 +++++- buildifier/integration_test.sh | 9 ++- tables/tables.go | 18 +----- warn/docs/warnings.textproto | 59 +++++++++++++++++--- warn/warn.go | 18 +++++- warn/warn_bazel_api.go | 38 ++++++++++++- warn/warn_bazel_api_test.go | 50 ++++++++--------- 8 files changed, 240 insertions(+), 65 deletions(-) diff --git a/WARNINGS.md b/WARNINGS.md index 0d6270449..6e64d0315 100644 --- a/WARNINGS.md +++ b/WARNINGS.md @@ -40,7 +40,14 @@ Warning categories supported by buildifier's linter: * [`native-android`](#native-android) * [`native-build`](#native-build) * [`native-cc`](#native-cc) - * [`native-java`](#native-java) + * [`native-java-binary`](#native-java-binary) + * [`native-java-import`](#native-java-import) + * [`native-java-library`](#native-java-library) + * [`native-java-package-config`](#native-java-package-config) + * [`native-java-plugin`](#native-java-plugin) + * [`native-java-runtime`](#native-java-runtime) + * [`native-java-test`](#native-java-test) + * [`native-java-toolchain`](#native-java-toolchain) * [`native-package`](#native-package) * [`native-proto`](#native-proto) * [`native-py`](#native-py) @@ -692,19 +699,91 @@ at the moment it's not required to load Starlark rules. -------------------------------------------------------------------------------- -## All Java build rules should be loaded from Starlark +## All Java build rules should be loaded from Starlark - * Category name: `native-java` - * Flag in Bazel: [`--incompatible_load_java_rules_from_bzl`](https://github.com/bazelbuild/bazel/issues/8746) + * Category name: `native-java-binary` * Automatic fix: yes * [Disabled by default](buildifier/README.md#linter) - * [Suppress the warning](#suppress): `# buildifier: disable=native-java` + * [Suppress the warning](#suppress): `# buildifier: disable=native-java-binary` The Java build rules should be loaded from Starlark. -Update: the plans for disabling native rules -[have been postponed](https://groups.google.com/g/bazel-discuss/c/XNvpWcge4AE/m/aJ-aQzszAwAJ), -at the moment it's not required to load Starlark rules. +-------------------------------------------------------------------------------- + +## All Java build rules should be loaded from Starlark + + * Category name: `native-java-import` + * Automatic fix: yes + * [Disabled by default](buildifier/README.md#linter) + * [Suppress the warning](#suppress): `# buildifier: disable=native-java-import` + +The Java build rules should be loaded from Starlark. + +-------------------------------------------------------------------------------- + +## All Java build rules should be loaded from Starlark + + * Category name: `native-java-library` + * Automatic fix: yes + * [Disabled by default](buildifier/README.md#linter) + * [Suppress the warning](#suppress): `# buildifier: disable=native-java-library` + +The Java build rules should be loaded from Starlark. + +-------------------------------------------------------------------------------- + +## All Java build rules should be loaded from Starlark + + * Category name: `native-java-package-config` + * Automatic fix: yes + * [Disabled by default](buildifier/README.md#linter) + * [Suppress the warning](#suppress): `# buildifier: disable=native-java-package-config` + +The Java build rules should be loaded from Starlark. + +-------------------------------------------------------------------------------- + +## All Java build rules should be loaded from Starlark + + * Category name: `native-java-plugin` + * Automatic fix: yes + * [Disabled by default](buildifier/README.md#linter) + * [Suppress the warning](#suppress): `# buildifier: disable=native-java-plugin` + +The Java build rules should be loaded from Starlark. + +-------------------------------------------------------------------------------- + +## All Java build rules should be loaded from Starlark + + * Category name: `native-java-runtime` + * Automatic fix: yes + * [Disabled by default](buildifier/README.md#linter) + * [Suppress the warning](#suppress): `# buildifier: disable=native-java-runtime` + +The Java build rules should be loaded from Starlark. + +-------------------------------------------------------------------------------- + +## All Java build rules should be loaded from Starlark + + * Category name: `native-java-test` + * Automatic fix: yes + * [Disabled by default](buildifier/README.md#linter) + * [Suppress the warning](#suppress): `# buildifier: disable=native-java-test` + +The Java build rules should be loaded from Starlark. + +-------------------------------------------------------------------------------- + +## All Java build rules should be loaded from Starlark + + * Category name: `native-java-toolchain` + * Automatic fix: yes + * [Disabled by default](buildifier/README.md#linter) + * [Suppress the warning](#suppress): `# buildifier: disable=native-java-toolchain` + +The Java build rules should be loaded from Starlark. -------------------------------------------------------------------------------- diff --git a/buildifier/config/config_test.go b/buildifier/config/config_test.go index 741dc05ec..b26c8c4f2 100644 --- a/buildifier/config/config_test.go +++ b/buildifier/config/config_test.go @@ -81,7 +81,14 @@ func ExampleExample() { // "native-android", // "native-build", // "native-cc", - // "native-java", + // "native-java-binary", + // "native-java-import", + // "native-java-library", + // "native-java-package-config", + // "native-java-plugin", + // "native-java-runtime", + // "native-java-test", + // "native-java-toolchain", // "native-package", // "native-proto", // "native-py", @@ -265,7 +272,14 @@ func TestValidate(t *testing.T) { "native-android", "native-build", "native-cc", - "native-java", + "native-java-binary", + "native-java-import", + "native-java-library", + "native-java-package-config", + "native-java-plugin", + "native-java-runtime", + "native-java-test", + "native-java-toolchain", "native-package", "native-proto", "native-py", diff --git a/buildifier/integration_test.sh b/buildifier/integration_test.sh index 87cf9caf5..5b352adff 100755 --- a/buildifier/integration_test.sh +++ b/buildifier/integration_test.sh @@ -285,7 +285,14 @@ cat > golden/.buildifier.example.json <