1# Copyright 2021 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 15""" 16Definition of java_import rule. 17""" 18 19load("//java/common:java_semantics.bzl", "semantics") 20load("//java/common/rules:java_import.bzl", "JAVA_IMPORT_ATTRS") 21load("//java/common/rules/impl:bazel_java_import_impl.bzl", "bazel_java_import_rule") 22load("//java/private:java_info.bzl", "JavaInfo") 23 24def _proxy(ctx): 25 return bazel_java_import_rule( 26 ctx, 27 ctx.attr.jars, 28 ctx.file.srcjar, 29 ctx.attr.deps, 30 ctx.attr.runtime_deps, 31 ctx.attr.exports, 32 ctx.attr.neverlink, 33 ctx.files.proguard_specs, 34 ctx.attr.add_exports, 35 ctx.attr.add_opens, 36 ).values() 37 38java_import = rule( 39 _proxy, 40 doc = """ 41<p> 42 This rule allows the use of precompiled <code>.jar</code> files as 43 libraries for <code><a href="#java_library">java_library</a></code> and 44 <code>java_binary</code> rules. 45</p> 46 47<h4 id="java_import_examples">Examples</h4> 48 49<pre class="code"> 50<code class="lang-starlark"> 51 java_import( 52 name = "maven_model", 53 jars = [ 54 "maven_model/maven-aether-provider-3.2.3.jar", 55 "maven_model/maven-model-3.2.3.jar", 56 "maven_model/maven-model-builder-3.2.3.jar", 57 ], 58 ) 59</code> 60</pre> 61 """, 62 attrs = JAVA_IMPORT_ATTRS, 63 provides = [JavaInfo], 64 fragments = ["java", "cpp"], 65 toolchains = [semantics.JAVA_TOOLCHAIN], 66) 67