Automated rollback of commit befbd4f6b4bb258c07eddf8009b2fcf93ca5e943. *** Reason for rollback *** postsubmit breakage: [] *** Original change description *** Restructure rules_java BEGIN_PUBLIC Restructure rules_java Design doc: https://docs.google.com/document/d/1L1JFgjpZ7SrBinb24DC_5nTIELeYDacikcme-YcA7xs/edit END_PUBLIC *** PiperOrigin-RevId: 605288071 Change-Id: Iab7970bff70443afd2ba41c50650800a2a37c037
diff --git a/java/BUILD b/java/BUILD index cd71ea9..dec049e 100644 --- a/java/BUILD +++ b/java/BUILD
@@ -7,25 +7,15 @@ filegroup( name = "srcs", srcs = glob(["**"]) + [ - "//java/modules:srcs", "//java/private:srcs", "//java/proto:srcs", - "//java/toolchains:srcs", ], visibility = ["//:__pkg__"], ) bzl_library( name = "rules", - srcs = [ - "defs.bzl", - "java_binary.bzl", - "java_import.bzl", - "java_library.bzl", - "java_plugin.bzl", - "java_single_jar.bzl", - "java_test.bzl", - ], + srcs = ["defs.bzl"], visibility = ["//visibility:public"], deps = ["//java/private"], )
diff --git a/java/defs.bzl b/java/defs.bzl index 51a235b..31cd01d 100644 --- a/java/defs.bzl +++ b/java/defs.bzl
@@ -13,43 +13,142 @@ # limitations under the License. """Starlark rules for building Java projects.""" -load("//java:java_binary.bzl", _java_binary = "java_binary") -load("//java:java_import.bzl", _java_import = "java_import") -load("//java:java_library.bzl", _java_library = "java_library") -load("//java:java_plugin.bzl", _java_plugin = "java_plugin") -load("//java:java_test.bzl", _java_test = "java_test") -load("//java/modules:java_common.bzl", _java_common = "java_common") -load("//java/modules:java_info.bzl", _JavaInfo = "JavaInfo") -load("//java/modules:java_plugin_info.bzl", _JavaPluginInfo = "JavaPluginInfo") -load("//java/proto:java_lite_proto_library.bzl", _java_lite_proto_library = "java_lite_proto_library") -load("//java/proto:java_proto_library.bzl", _java_proto_library = "java_proto_library") -load("//java/toolchains:java_package_configuration.bzl", _java_package_configuration = "java_package_configuration") -load("//java/toolchains:java_runtime.bzl", _java_runtime = "java_runtime") -load("//java/toolchains:java_toolchain.bzl", _java_toolchain = "java_toolchain") +load("//java/private:native.bzl", "NativeJavaInfo", "NativeJavaPluginInfo", "native_java_common") +# Do not touch: This line marks the end of loads; needed for PR importing. + +_MIGRATION_TAG = "__JAVA_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__" version = "7.4.0" -# Language rules +def _add_tags(attrs): + if "tags" in attrs and attrs["tags"] != None: + attrs["tags"] = attrs["tags"] + [_MIGRATION_TAG] + else: + attrs["tags"] = [_MIGRATION_TAG] + return attrs -java_binary = _java_binary -java_test = _java_test -java_library = _java_library -java_plugin = _java_plugin -java_import = _java_import +def java_binary(**attrs): + """Bazel java_binary rule. -# Toolchain rules + https://docs.bazel.build/versions/master/be/java.html#java_binary -java_runtime = _java_runtime -java_toolchain = _java_toolchain -java_package_configuration = _java_package_configuration + Args: + **attrs: Rule attributes + """ -# Proto rules + # buildifier: disable=native-java + native.java_binary(**_add_tags(attrs)) -java_proto_library = _java_proto_library -java_lite_proto_library = _java_lite_proto_library +def java_import(**attrs): + """Bazel java_import rule. -# Modules and providers + https://docs.bazel.build/versions/master/be/java.html#java_import -JavaInfo = _JavaInfo -JavaPluginInfo = _JavaPluginInfo -java_common = _java_common + Args: + **attrs: Rule attributes + """ + + # buildifier: disable=native-java + native.java_import(**_add_tags(attrs)) + +def java_library(**attrs): + """Bazel java_library rule. + + https://docs.bazel.build/versions/master/be/java.html#java_library + + Args: + **attrs: Rule attributes + """ + + # buildifier: disable=native-java + native.java_library(**_add_tags(attrs)) + +def java_lite_proto_library(**attrs): + """Bazel java_lite_proto_library rule. + + https://docs.bazel.build/versions/master/be/java.html#java_lite_proto_library + + Args: + **attrs: Rule attributes + """ + + # buildifier: disable=native-java + native.java_lite_proto_library(**_add_tags(attrs)) + +def java_proto_library(**attrs): + """Bazel java_proto_library rule. + + https://docs.bazel.build/versions/master/be/java.html#java_proto_library + + Args: + **attrs: Rule attributes + """ + + # buildifier: disable=native-java + native.java_proto_library(**_add_tags(attrs)) + +def java_test(**attrs): + """Bazel java_test rule. + + https://docs.bazel.build/versions/master/be/java.html#java_test + + Args: + **attrs: Rule attributes + """ + + # buildifier: disable=native-java + native.java_test(**_add_tags(attrs)) + +def java_package_configuration(**attrs): + """Bazel java_package_configuration rule. + + https://docs.bazel.build/versions/master/be/java.html#java_package_configuration + + Args: + **attrs: Rule attributes + """ + + # buildifier: disable=native-java + native.java_package_configuration(**_add_tags(attrs)) + +def java_plugin(**attrs): + """Bazel java_plugin rule. + + https://docs.bazel.build/versions/master/be/java.html#java_plugin + + Args: + **attrs: Rule attributes + """ + + # buildifier: disable=native-java + native.java_plugin(**_add_tags(attrs)) + +def java_runtime(**attrs): + """Bazel java_runtime rule. + + https://docs.bazel.build/versions/master/be/java.html#java_runtime + + Args: + **attrs: Rule attributes + """ + + # buildifier: disable=native-java + native.java_runtime(**_add_tags(attrs)) + +def java_toolchain(**attrs): + """Bazel java_toolchain rule. + + https://docs.bazel.build/versions/master/be/java.html#java_toolchain + + Args: + **attrs: Rule attributes + """ + + # buildifier: disable=native-java + native.java_toolchain(**_add_tags(attrs)) + +java_common = native_java_common + +JavaInfo = NativeJavaInfo + +JavaPluginInfo = NativeJavaPluginInfo
diff --git a/java/java_binary.bzl b/java/java_binary.bzl deleted file mode 100644 index 18f5b86..0000000 --- a/java/java_binary.bzl +++ /dev/null
@@ -1,30 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""java_binary rule""" - -load("//java/private:add_tags.bzl", "add_tags") - -# Do not touch: This line marks the end of loads; needed for PR importing. - -def java_binary(**attrs): - """Bazel java_binary rule. - - https://docs.bazel.build/versions/master/be/java.html#java_binary - - Args: - **attrs: Rule attributes - """ - - # buildifier: disable=native-java - native.java_binary(**add_tags(attrs))
diff --git a/java/java_import.bzl b/java/java_import.bzl deleted file mode 100644 index dd23653..0000000 --- a/java/java_import.bzl +++ /dev/null
@@ -1,28 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""java_import rule""" - -load("//java/private:add_tags.bzl", "add_tags") - -def java_import(**attrs): - """Bazel java_import rule. - - https://docs.bazel.build/versions/master/be/java.html#java_import - - Args: - **attrs: Rule attributes - """ - - # buildifier: disable=native-java - native.java_import(**add_tags(attrs))
diff --git a/java/java_library.bzl b/java/java_library.bzl deleted file mode 100644 index 3bc0a53..0000000 --- a/java/java_library.bzl +++ /dev/null
@@ -1,30 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""java_library rule""" - -load("//java/private:add_tags.bzl", "add_tags") - -# Do not touch: This line marks the end of loads; needed for PR importing. - -def java_library(**attrs): - """Bazel java_library rule. - - https://docs.bazel.build/versions/master/be/java.html#java_library - - Args: - **attrs: Rule attributes - """ - - # buildifier: disable=native-java - native.java_library(**add_tags(attrs))
diff --git a/java/java_plugin.bzl b/java/java_plugin.bzl deleted file mode 100644 index a95fc44..0000000 --- a/java/java_plugin.bzl +++ /dev/null
@@ -1,28 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""java_plugin rule""" - -load("//java/private:add_tags.bzl", "add_tags") - -def java_plugin(**attrs): - """Bazel java_plugin rule. - - https://docs.bazel.build/versions/master/be/java.html#java_plugin - - Args: - **attrs: Rule attributes - """ - - # buildifier: disable=native-java - native.java_plugin(**add_tags(attrs))
diff --git a/java/java_test.bzl b/java/java_test.bzl deleted file mode 100644 index 76a63a1..0000000 --- a/java/java_test.bzl +++ /dev/null
@@ -1,30 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""java_test rule""" - -load("//java/private:add_tags.bzl", "add_tags") - -# Do not touch: This line marks the end of loads; needed for PR importing. - -def java_test(**attrs): - """Bazel java_test rule. - - https://docs.bazel.build/versions/master/be/java.html#java_test - - Args: - **attrs: Rule attributes - """ - - # buildifier: disable=native-java - native.java_test(**add_tags(attrs))
diff --git a/java/modules/BUILD b/java/modules/BUILD deleted file mode 100644 index d9ed6e6..0000000 --- a/java/modules/BUILD +++ /dev/null
@@ -1,18 +0,0 @@ -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -filegroup( - name = "srcs", - srcs = glob(["**"]), - visibility = ["//java:__pkg__"], -) - -bzl_library( - name = "modules", - srcs = glob(["*.bzl"]), - visibility = ["//visibility:public"], - deps = ["//java/private"], -)
diff --git a/java/modules/java_common.bzl b/java/modules/java_common.bzl deleted file mode 100644 index 201beba..0000000 --- a/java/modules/java_common.bzl +++ /dev/null
@@ -1,18 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""java_common module""" - -load("//java/private:native.bzl", "native_java_common") - -java_common = native_java_common
diff --git a/java/modules/java_info.bzl b/java/modules/java_info.bzl deleted file mode 100644 index e22fb3d..0000000 --- a/java/modules/java_info.bzl +++ /dev/null
@@ -1,18 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""JavaInfo provider""" - -load("//java/private:native.bzl", "NativeJavaInfo") - -JavaInfo = NativeJavaInfo
diff --git a/java/modules/java_plugin_info.bzl b/java/modules/java_plugin_info.bzl deleted file mode 100644 index 36d84f9..0000000 --- a/java/modules/java_plugin_info.bzl +++ /dev/null
@@ -1,18 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""JavaPluginInfo provider""" - -load("//java/private:native.bzl", "NativeJavaPluginInfo") - -JavaPluginInfo = NativeJavaPluginInfo
diff --git a/java/private/BUILD b/java/private/BUILD index bfd41c2..9f50995 100644 --- a/java/private/BUILD +++ b/java/private/BUILD
@@ -5,7 +5,7 @@ bzl_library( name = "private", srcs = ["native.bzl"], - visibility = ["//java:__subpackages__"], + visibility = ["//java:__pkg__"], ) filegroup(
diff --git a/java/private/add_tags.bzl b/java/private/add_tags.bzl deleted file mode 100644 index 6f2e35b..0000000 --- a/java/private/add_tags.bzl +++ /dev/null
@@ -1,23 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""add_tags migration helper""" - -_MIGRATION_TAG = "__JAVA_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__" - -def add_tags(attrs): - if "tags" in attrs and attrs["tags"] != None: - attrs["tags"] = attrs["tags"] + [_MIGRATION_TAG] - else: - attrs["tags"] = [_MIGRATION_TAG] - return attrs
diff --git a/java/proto/BUILD b/java/proto/BUILD index 5876189..209a5f5 100644 --- a/java/proto/BUILD +++ b/java/proto/BUILD
@@ -1,5 +1,3 @@ -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") - package(default_visibility = ["//visibility:public"]) # Toolchain type provided by proto_lang_toolchain rule and used by java_proto_library @@ -8,13 +6,6 @@ # Toolchain type provided by proto_lang_toolchain rule and used by java_lite_proto_library toolchain_type(name = "lite_toolchain_type") -bzl_library( - name = "proto_rules", - srcs = glob(["*.bzl"]), - visibility = ["//visibility:public"], - deps = ["//java/private"], -) - filegroup( name = "srcs", srcs = glob(["**"]),
diff --git a/java/proto/java_lite_proto_library.bzl b/java/proto/java_lite_proto_library.bzl deleted file mode 100644 index c800237..0000000 --- a/java/proto/java_lite_proto_library.bzl +++ /dev/null
@@ -1,28 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""java_lite_proto_library rule""" - -load("//java/private:add_tags.bzl", "add_tags") - -def java_lite_proto_library(**attrs): - """Bazel java_lite_proto_library rule. - - https://docs.bazel.build/versions/master/be/java.html#java_lite_proto_library - - Args: - **attrs: Rule attributes - """ - - # buildifier: disable=native-java - native.java_lite_proto_library(**add_tags(attrs))
diff --git a/java/proto/java_proto_library.bzl b/java/proto/java_proto_library.bzl deleted file mode 100644 index cb3d3f5..0000000 --- a/java/proto/java_proto_library.bzl +++ /dev/null
@@ -1,28 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""java_proto_library rule""" - -load("//java/private:add_tags.bzl", "add_tags") - -def java_proto_library(**attrs): - """Bazel java_proto_library rule. - - https://docs.bazel.build/versions/master/be/java.html#java_proto_library - - Args: - **attrs: Rule attributes - """ - - # buildifier: disable=native-java - native.java_proto_library(**add_tags(attrs))
diff --git a/java/toolchains/BUILD b/java/toolchains/BUILD deleted file mode 100644 index 0cc6644..0000000 --- a/java/toolchains/BUILD +++ /dev/null
@@ -1,18 +0,0 @@ -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -filegroup( - name = "srcs", - srcs = glob(["**"]), - visibility = ["//java:__pkg__"], -) - -bzl_library( - name = "toolchain_rules", - srcs = glob(["*.bzl"]), - visibility = ["//visibility:public"], - deps = ["//java/private"], -)
diff --git a/java/toolchains/java_package_configuration.bzl b/java/toolchains/java_package_configuration.bzl deleted file mode 100644 index b68b5fc..0000000 --- a/java/toolchains/java_package_configuration.bzl +++ /dev/null
@@ -1,28 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""java_package_configuration rule""" - -load("//java/private:add_tags.bzl", "add_tags") - -def java_package_configuration(**attrs): - """Bazel java_package_configuration rule. - - https://docs.bazel.build/versions/master/be/java.html#java_package_configuration - - Args: - **attrs: Rule attributes - """ - - # buildifier: disable=native-java - native.java_package_configuration(**add_tags(attrs))
diff --git a/java/toolchains/java_runtime.bzl b/java/toolchains/java_runtime.bzl deleted file mode 100644 index 0f2eb8b..0000000 --- a/java/toolchains/java_runtime.bzl +++ /dev/null
@@ -1,28 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""java_runtime rule""" - -load("//java/private:add_tags.bzl", "add_tags") - -def java_runtime(**attrs): - """Bazel java_runtime rule. - - https://docs.bazel.build/versions/master/be/java.html#java_runtime - - Args: - **attrs: Rule attributes - """ - - # buildifier: disable=native-java - native.java_runtime(**add_tags(attrs))
diff --git a/java/toolchains/java_toolchain.bzl b/java/toolchains/java_toolchain.bzl deleted file mode 100644 index a5f1cda..0000000 --- a/java/toolchains/java_toolchain.bzl +++ /dev/null
@@ -1,28 +0,0 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""java_toolchain rule""" - -load("//java/private:add_tags.bzl", "add_tags") - -def java_toolchain(**attrs): - """Bazel java_toolchain rule. - - https://docs.bazel.build/versions/master/be/java.html#java_toolchain - - Args: - **attrs: Rule attributes - """ - - # buildifier: disable=native-java - native.java_toolchain(**add_tags(attrs))