1# Copyright 2019 The Bazel Authors. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Starlark rules for building Java projects.""" 15 16load("//java/private:native.bzl", "NativeJavaInfo", "NativeJavaPluginInfo", "native_java_common") 17 18# Do not touch: This line marks the end of loads; needed for PR importing. 19 20_MIGRATION_TAG = "__JAVA_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__" 21version = "6.1.1" 22 23def _add_tags(attrs): 24 if "tags" in attrs and attrs["tags"] != None: 25 attrs["tags"] = attrs["tags"] + [_MIGRATION_TAG] 26 else: 27 attrs["tags"] = [_MIGRATION_TAG] 28 return attrs 29 30def java_binary(**attrs): 31 """Bazel java_binary rule. 32 33 https://docs.bazel.build/versions/master/be/java.html#java_binary 34 35 Args: 36 **attrs: Rule attributes 37 """ 38 39 # buildifier: disable=native-java 40 native.java_binary(**_add_tags(attrs)) 41 42def java_import(**attrs): 43 """Bazel java_import rule. 44 45 https://docs.bazel.build/versions/master/be/java.html#java_import 46 47 Args: 48 **attrs: Rule attributes 49 """ 50 51 # buildifier: disable=native-java 52 native.java_import(**_add_tags(attrs)) 53 54def java_library(**attrs): 55 """Bazel java_library rule. 56 57 https://docs.bazel.build/versions/master/be/java.html#java_library 58 59 Args: 60 **attrs: Rule attributes 61 """ 62 63 # buildifier: disable=native-java 64 native.java_library(**_add_tags(attrs)) 65 66def java_lite_proto_library(**attrs): 67 """Bazel java_lite_proto_library rule. 68 69 https://docs.bazel.build/versions/master/be/java.html#java_lite_proto_library 70 71 Args: 72 **attrs: Rule attributes 73 """ 74 75 # buildifier: disable=native-java 76 native.java_lite_proto_library(**_add_tags(attrs)) 77 78def java_proto_library(**attrs): 79 """Bazel java_proto_library rule. 80 81 https://docs.bazel.build/versions/master/be/java.html#java_proto_library 82 83 Args: 84 **attrs: Rule attributes 85 """ 86 87 # buildifier: disable=native-java 88 native.java_proto_library(**_add_tags(attrs)) 89 90def java_test(**attrs): 91 """Bazel java_test rule. 92 93 https://docs.bazel.build/versions/master/be/java.html#java_test 94 95 Args: 96 **attrs: Rule attributes 97 """ 98 99 # buildifier: disable=native-java 100 native.java_test(**_add_tags(attrs)) 101 102def java_package_configuration(**attrs): 103 """Bazel java_package_configuration rule. 104 105 https://docs.bazel.build/versions/master/be/java.html#java_package_configuration 106 107 Args: 108 **attrs: Rule attributes 109 """ 110 111 # buildifier: disable=native-java 112 native.java_package_configuration(**_add_tags(attrs)) 113 114def java_plugin(**attrs): 115 """Bazel java_plugin rule. 116 117 https://docs.bazel.build/versions/master/be/java.html#java_plugin 118 119 Args: 120 **attrs: Rule attributes 121 """ 122 123 # buildifier: disable=native-java 124 native.java_plugin(**_add_tags(attrs)) 125 126def java_runtime(**attrs): 127 """Bazel java_runtime rule. 128 129 https://docs.bazel.build/versions/master/be/java.html#java_runtime 130 131 Args: 132 **attrs: Rule attributes 133 """ 134 135 # buildifier: disable=native-java 136 native.java_runtime(**_add_tags(attrs)) 137 138def java_toolchain(**attrs): 139 """Bazel java_toolchain rule. 140 141 https://docs.bazel.build/versions/master/be/java.html#java_toolchain 142 143 Args: 144 **attrs: Rule attributes 145 """ 146 147 # buildifier: disable=native-java 148 native.java_toolchain(**_add_tags(attrs)) 149 150java_common = native_java_common 151 152JavaInfo = NativeJavaInfo 153 154JavaPluginInfo = NativeJavaPluginInfo 155