Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable warnings for the (formerly) native java rules & symbols #1313

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 124 additions & 9 deletions WARNINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,19 @@ Warning categories supported by buildifier's linter:
* [`native-build`](#native-build)
* [`native-cc`](#native-cc)
* [`native-cc-proto`](#native-cc-proto)
* [`native-java`](#native-java)
* [`native-java-binary`](#native-java-binary)
* [`native-java-common`](#native-java-common)
* [`native-java-import`](#native-java-import)
* [`native-java-info`](#native-java-info)
* [`native-java-library`](#native-java-library)
* [`native-java-lite-proto`](#native-java-lite-proto)
* [`native-java-package-config`](#native-java-package-config)
* [`native-java-plugin`](#native-java-plugin)
* [`native-java-plugin-info`](#native-java-plugin-info)
* [`native-java-proto`](#native-java-proto)
* [`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-proto-common`](#native-proto-common)
Expand Down Expand Up @@ -713,19 +723,58 @@ The cc_proto_library rule should be loaded from Starlark.

--------------------------------------------------------------------------------

## <a name="native-java"></a>All Java build rules should be loaded from Starlark
## <a name="native-java-binary"></a>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`
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
* 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.
--------------------------------------------------------------------------------

## <a name="native-java-common"></a>All Java build rules should be loaded from Starlark

* Category name: `native-java-common`
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
* Automatic fix: yes
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-common`

The Java build rules should be loaded from Starlark.

--------------------------------------------------------------------------------

## <a name="native-java-import"></a>All Java build rules should be loaded from Starlark

* Category name: `native-java-import`
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
* Automatic fix: yes
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-import`

The Java build rules should be loaded from Starlark.

--------------------------------------------------------------------------------

## <a name="native-java-info"></a>All Java build rules should be loaded from Starlark

* Category name: `native-java-info`
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
* Automatic fix: yes
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-info`

The Java build rules should be loaded from Starlark.

--------------------------------------------------------------------------------

## <a name="native-java-library"></a>All Java build rules should be loaded from Starlark

* Category name: `native-java-library`
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
* Automatic fix: yes
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-library`

The Java build rules should be loaded from Starlark.

--------------------------------------------------------------------------------

Expand All @@ -740,6 +789,39 @@ The java_lite_proto_library rule should be loaded from Starlark.

--------------------------------------------------------------------------------

## <a name="native-java-package-config"></a>All Java build rules should be loaded from Starlark

* Category name: `native-java-package-config`
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
* Automatic fix: yes
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-package-config`

The Java build rules should be loaded from Starlark.

--------------------------------------------------------------------------------

## <a name="native-java-plugin"></a>All Java build rules should be loaded from Starlark

* Category name: `native-java-plugin`
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
* Automatic fix: yes
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-plugin`

The Java build rules should be loaded from Starlark.

--------------------------------------------------------------------------------

## <a name="native-java-plugin-info"></a>All Java build rules should be loaded from Starlark

* Category name: `native-java-plugin-info`
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
* Automatic fix: yes
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-plugin-info`

The Java build rules should be loaded from Starlark.

--------------------------------------------------------------------------------

## <a name="native-java-proto"></a>java_proto_library rule should be loaded from Starlark

* Category name: `native-java-proto`
Expand All @@ -751,6 +833,39 @@ The java_proto_library rule should be loaded from Starlark.

--------------------------------------------------------------------------------

## <a name="native-java-runtime"></a>All Java build rules should be loaded from Starlark

* Category name: `native-java-runtime`
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
* Automatic fix: yes
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-runtime`

The Java build rules should be loaded from Starlark.

--------------------------------------------------------------------------------

## <a name="native-java-test"></a>All Java build rules should be loaded from Starlark

* Category name: `native-java-test`
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
* Automatic fix: yes
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-test`

The Java build rules should be loaded from Starlark.

--------------------------------------------------------------------------------

## <a name="native-java-toolchain"></a>All Java build rules should be loaded from Starlark

* Category name: `native-java-toolchain`
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
* Automatic fix: yes
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-toolchain`

The Java build rules should be loaded from Starlark.

--------------------------------------------------------------------------------

## <a name="native-package"></a>`native.package()` shouldn't be used in .bzl files

* Category name: `native-package`
Expand Down
48 changes: 44 additions & 4 deletions buildifier/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,19 @@ func ExampleExample() {
// "native-build",
// "native-cc",
// "native-cc-proto",
// "native-java",
// "native-java-binary",
// "native-java-common",
// "native-java-import",
// "native-java-info",
// "native-java-library",
// "native-java-lite-proto",
// "native-java-package-config",
// "native-java-plugin",
// "native-java-plugin-info",
// "native-java-proto",
// "native-java-runtime",
// "native-java-test",
// "native-java-toolchain",
// "native-package",
// "native-proto",
// "native-proto-common",
Expand Down Expand Up @@ -268,9 +278,19 @@ func TestValidate(t *testing.T) {
"native-build",
"native-cc",
"native-cc-proto",
"native-java",
"native-java-binary",
"native-java-common",
"native-java-import",
"native-java-info",
"native-java-library",
"native-java-lite-proto",
"native-java-package-config",
"native-java-plugin",
"native-java-plugin-info",
"native-java-proto",
"native-java-runtime",
"native-java-test",
"native-java-toolchain",
"native-package",
"native-proto",
"native-proto-common",
Expand Down Expand Up @@ -337,9 +357,19 @@ func TestValidate(t *testing.T) {
"native-build",
// "native-cc",
"native-cc-proto",
// "native-java",
"native-java-binary",
"native-java-common",
"native-java-import",
"native-java-info",
"native-java-library",
"native-java-lite-proto",
"native-java-package-config",
"native-java-plugin",
"native-java-plugin-info",
"native-java-proto",
"native-java-runtime",
"native-java-test",
"native-java-toolchain",
"native-package",
"native-proto",
"native-proto-common",
Expand Down Expand Up @@ -405,9 +435,19 @@ func TestValidate(t *testing.T) {
// "native-android",
"native-build",
"native-cc-proto",
// "native-java",
"native-java-binary",
"native-java-common",
"native-java-import",
"native-java-info",
"native-java-library",
"native-java-lite-proto",
"native-java-package-config",
"native-java-plugin",
"native-java-plugin-info",
"native-java-proto",
"native-java-runtime",
"native-java-test",
"native-java-toolchain",
"native-package",
"native-proto",
"native-proto-common",
Expand Down
12 changes: 11 additions & 1 deletion buildifier/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,19 @@ cat > golden/.buildifier.example.json <<EOF
"native-build",
"native-cc",
"native-cc-proto",
"native-java",
"native-java-binary",
"native-java-common",
"native-java-import",
"native-java-info",
"native-java-library",
"native-java-lite-proto",
"native-java-package-config",
"native-java-plugin",
"native-java-plugin-info",
"native-java-proto",
"native-java-runtime",
"native-java-test",
"native-java-toolchain",
"native-package",
"native-proto",
"native-proto-common",
Expand Down
16 changes: 2 additions & 14 deletions tables/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,8 @@ var CcNativeRules = []string{
// CcLoadPath is the load path for the Starlark C++ Rules.
var CcLoadPath = "@rules_cc//cc:defs.bzl"

// JavaNativeRules lists all Java rules that are being migrated from Native to Starlark.
var JavaNativeRules = []string{
"java_binary",
"java_import",
"java_library",
"java_test",
"java_package_configuration",
"java_plugin",
"java_runtime",
"java_toolchain",
}

// JavaLoadPath is the load path for the Starlark Java Rules.
var JavaLoadPath = "@rules_java//java:defs.bzl"
// JavaLoadPathPrefix is the load package for the Starlark Java Rules.
var JavaLoadPathPrefix = "@rules_java//java"

// PyNativeRules lists all Python rules that are being migrated from Native to Starlark.
var PyNativeRules = []string{
Expand Down
Loading