Skip to content

Commit 8bd806d

Browse files
authored
Enable warnings for the (formerly) native java rules & symbols (#1313)
1 parent a0444eb commit 8bd806d

File tree

8 files changed

+354
-50
lines changed

8 files changed

+354
-50
lines changed

WARNINGS.md

Lines changed: 124 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,19 @@ Warning categories supported by buildifier's linter:
4141
* [`native-build`](#native-build)
4242
* [`native-cc`](#native-cc)
4343
* [`native-cc-proto`](#native-cc-proto)
44-
* [`native-java`](#native-java)
44+
* [`native-java-binary`](#native-java-binary)
45+
* [`native-java-common`](#native-java-common)
46+
* [`native-java-import`](#native-java-import)
47+
* [`native-java-info`](#native-java-info)
48+
* [`native-java-library`](#native-java-library)
4549
* [`native-java-lite-proto`](#native-java-lite-proto)
50+
* [`native-java-package-config`](#native-java-package-config)
51+
* [`native-java-plugin`](#native-java-plugin)
52+
* [`native-java-plugin-info`](#native-java-plugin-info)
4653
* [`native-java-proto`](#native-java-proto)
54+
* [`native-java-runtime`](#native-java-runtime)
55+
* [`native-java-test`](#native-java-test)
56+
* [`native-java-toolchain`](#native-java-toolchain)
4757
* [`native-package`](#native-package)
4858
* [`native-proto`](#native-proto)
4959
* [`native-proto-common`](#native-proto-common)
@@ -713,19 +723,58 @@ The cc_proto_library rule should be loaded from Starlark.
713723

714724
--------------------------------------------------------------------------------
715725

716-
## <a name="native-java"></a>All Java build rules should be loaded from Starlark
726+
## <a name="native-java-binary"></a>All Java build rules should be loaded from Starlark
717727

718-
* Category name: `native-java`
719-
* Flag in Bazel: [`--incompatible_load_java_rules_from_bzl`](https://github.com/bazelbuild/bazel/issues/8746)
728+
* Category name: `native-java-binary`
729+
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
720730
* Automatic fix: yes
721-
* [Disabled by default](buildifier/README.md#linter)
722-
* [Suppress the warning](#suppress): `# buildifier: disable=native-java`
731+
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-binary`
723732

724733
The Java build rules should be loaded from Starlark.
725734

726-
Update: the plans for disabling native rules
727-
[have been postponed](https://groups.google.com/g/bazel-discuss/c/XNvpWcge4AE/m/aJ-aQzszAwAJ),
728-
at the moment it's not required to load Starlark rules.
735+
--------------------------------------------------------------------------------
736+
737+
## <a name="native-java-common"></a>All Java build rules should be loaded from Starlark
738+
739+
* Category name: `native-java-common`
740+
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
741+
* Automatic fix: yes
742+
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-common`
743+
744+
The Java build rules should be loaded from Starlark.
745+
746+
--------------------------------------------------------------------------------
747+
748+
## <a name="native-java-import"></a>All Java build rules should be loaded from Starlark
749+
750+
* Category name: `native-java-import`
751+
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
752+
* Automatic fix: yes
753+
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-import`
754+
755+
The Java build rules should be loaded from Starlark.
756+
757+
--------------------------------------------------------------------------------
758+
759+
## <a name="native-java-info"></a>All Java build rules should be loaded from Starlark
760+
761+
* Category name: `native-java-info`
762+
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
763+
* Automatic fix: yes
764+
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-info`
765+
766+
The Java build rules should be loaded from Starlark.
767+
768+
--------------------------------------------------------------------------------
769+
770+
## <a name="native-java-library"></a>All Java build rules should be loaded from Starlark
771+
772+
* Category name: `native-java-library`
773+
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
774+
* Automatic fix: yes
775+
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-library`
776+
777+
The Java build rules should be loaded from Starlark.
729778

730779
--------------------------------------------------------------------------------
731780

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

741790
--------------------------------------------------------------------------------
742791

792+
## <a name="native-java-package-config"></a>All Java build rules should be loaded from Starlark
793+
794+
* Category name: `native-java-package-config`
795+
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
796+
* Automatic fix: yes
797+
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-package-config`
798+
799+
The Java build rules should be loaded from Starlark.
800+
801+
--------------------------------------------------------------------------------
802+
803+
## <a name="native-java-plugin"></a>All Java build rules should be loaded from Starlark
804+
805+
* Category name: `native-java-plugin`
806+
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
807+
* Automatic fix: yes
808+
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-plugin`
809+
810+
The Java build rules should be loaded from Starlark.
811+
812+
--------------------------------------------------------------------------------
813+
814+
## <a name="native-java-plugin-info"></a>All Java build rules should be loaded from Starlark
815+
816+
* Category name: `native-java-plugin-info`
817+
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
818+
* Automatic fix: yes
819+
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-plugin-info`
820+
821+
The Java build rules should be loaded from Starlark.
822+
823+
--------------------------------------------------------------------------------
824+
743825
## <a name="native-java-proto"></a>java_proto_library rule should be loaded from Starlark
744826

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

752834
--------------------------------------------------------------------------------
753835

836+
## <a name="native-java-runtime"></a>All Java build rules should be loaded from Starlark
837+
838+
* Category name: `native-java-runtime`
839+
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
840+
* Automatic fix: yes
841+
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-runtime`
842+
843+
The Java build rules should be loaded from Starlark.
844+
845+
--------------------------------------------------------------------------------
846+
847+
## <a name="native-java-test"></a>All Java build rules should be loaded from Starlark
848+
849+
* Category name: `native-java-test`
850+
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
851+
* Automatic fix: yes
852+
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-test`
853+
854+
The Java build rules should be loaded from Starlark.
855+
856+
--------------------------------------------------------------------------------
857+
858+
## <a name="native-java-toolchain"></a>All Java build rules should be loaded from Starlark
859+
860+
* Category name: `native-java-toolchain`
861+
* Flag in Bazel: [`--incompatible_autoload_externally`](https://github.com/bazelbuild/bazel/issues/23043)
862+
* Automatic fix: yes
863+
* [Suppress the warning](#suppress): `# buildifier: disable=native-java-toolchain`
864+
865+
The Java build rules should be loaded from Starlark.
866+
867+
--------------------------------------------------------------------------------
868+
754869
## <a name="native-package"></a>`native.package()` shouldn't be used in .bzl files
755870

756871
* Category name: `native-package`

buildifier/config/config_test.go

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,19 @@ func ExampleExample() {
8080
// "native-build",
8181
// "native-cc",
8282
// "native-cc-proto",
83-
// "native-java",
83+
// "native-java-binary",
84+
// "native-java-common",
85+
// "native-java-import",
86+
// "native-java-info",
87+
// "native-java-library",
8488
// "native-java-lite-proto",
89+
// "native-java-package-config",
90+
// "native-java-plugin",
91+
// "native-java-plugin-info",
8592
// "native-java-proto",
93+
// "native-java-runtime",
94+
// "native-java-test",
95+
// "native-java-toolchain",
8696
// "native-package",
8797
// "native-proto",
8898
// "native-proto-common",
@@ -268,9 +278,19 @@ func TestValidate(t *testing.T) {
268278
"native-build",
269279
"native-cc",
270280
"native-cc-proto",
271-
"native-java",
281+
"native-java-binary",
282+
"native-java-common",
283+
"native-java-import",
284+
"native-java-info",
285+
"native-java-library",
272286
"native-java-lite-proto",
287+
"native-java-package-config",
288+
"native-java-plugin",
289+
"native-java-plugin-info",
273290
"native-java-proto",
291+
"native-java-runtime",
292+
"native-java-test",
293+
"native-java-toolchain",
274294
"native-package",
275295
"native-proto",
276296
"native-proto-common",
@@ -337,9 +357,19 @@ func TestValidate(t *testing.T) {
337357
"native-build",
338358
// "native-cc",
339359
"native-cc-proto",
340-
// "native-java",
360+
"native-java-binary",
361+
"native-java-common",
362+
"native-java-import",
363+
"native-java-info",
364+
"native-java-library",
341365
"native-java-lite-proto",
366+
"native-java-package-config",
367+
"native-java-plugin",
368+
"native-java-plugin-info",
342369
"native-java-proto",
370+
"native-java-runtime",
371+
"native-java-test",
372+
"native-java-toolchain",
343373
"native-package",
344374
"native-proto",
345375
"native-proto-common",
@@ -405,9 +435,19 @@ func TestValidate(t *testing.T) {
405435
// "native-android",
406436
"native-build",
407437
"native-cc-proto",
408-
// "native-java",
438+
"native-java-binary",
439+
"native-java-common",
440+
"native-java-import",
441+
"native-java-info",
442+
"native-java-library",
409443
"native-java-lite-proto",
444+
"native-java-package-config",
445+
"native-java-plugin",
446+
"native-java-plugin-info",
410447
"native-java-proto",
448+
"native-java-runtime",
449+
"native-java-test",
450+
"native-java-toolchain",
411451
"native-package",
412452
"native-proto",
413453
"native-proto-common",

buildifier/integration_test.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,19 @@ cat > golden/.buildifier.example.json <<EOF
285285
"native-build",
286286
"native-cc",
287287
"native-cc-proto",
288-
"native-java",
288+
"native-java-binary",
289+
"native-java-common",
290+
"native-java-import",
291+
"native-java-info",
292+
"native-java-library",
289293
"native-java-lite-proto",
294+
"native-java-package-config",
295+
"native-java-plugin",
296+
"native-java-plugin-info",
290297
"native-java-proto",
298+
"native-java-runtime",
299+
"native-java-test",
300+
"native-java-toolchain",
291301
"native-package",
292302
"native-proto",
293303
"native-proto-common",

tables/tables.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -245,20 +245,8 @@ var CcNativeRules = []string{
245245
// CcLoadPath is the load path for the Starlark C++ Rules.
246246
var CcLoadPath = "@rules_cc//cc:defs.bzl"
247247

248-
// JavaNativeRules lists all Java rules that are being migrated from Native to Starlark.
249-
var JavaNativeRules = []string{
250-
"java_binary",
251-
"java_import",
252-
"java_library",
253-
"java_test",
254-
"java_package_configuration",
255-
"java_plugin",
256-
"java_runtime",
257-
"java_toolchain",
258-
}
259-
260-
// JavaLoadPath is the load path for the Starlark Java Rules.
261-
var JavaLoadPath = "@rules_java//java:defs.bzl"
248+
// JavaLoadPathPrefix is the load package for the Starlark Java Rules.
249+
var JavaLoadPathPrefix = "@rules_java//java"
262250

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

0 commit comments

Comments
 (0)