1<!-- Generated with Stardoc: http://skydoc.bazel.build --> 2 3Java rules 4 5 6## Rules 7 8- [java_binary](#java_binary) 9- [java_import](#java_import) 10- [java_library](#java_library) 11- [java_package_configuration](#java_package_configuration) 12- [java_plugin](#java_plugin) 13- [java_runtime](#java_runtime) 14- [java_test](#java_test) 15- [java_toolchain](#java_toolchain) 16 17 18<a id="java_binary"></a> 19 20## java_binary 21 22<pre> 23java_binary(<a href="#java_binary-name">name</a>, <a href="#java_binary-deps">deps</a>, <a href="#java_binary-srcs">srcs</a>, <a href="#java_binary-data">data</a>, <a href="#java_binary-resources">resources</a>, <a href="#java_binary-add_exports">add_exports</a>, <a href="#java_binary-add_opens">add_opens</a>, <a href="#java_binary-bootclasspath">bootclasspath</a>, 24 <a href="#java_binary-classpath_resources">classpath_resources</a>, <a href="#java_binary-create_executable">create_executable</a>, <a href="#java_binary-deploy_env">deploy_env</a>, <a href="#java_binary-deploy_manifest_lines">deploy_manifest_lines</a>, <a href="#java_binary-env">env</a>, <a href="#java_binary-javacopts">javacopts</a>, 25 <a href="#java_binary-jvm_flags">jvm_flags</a>, <a href="#java_binary-launcher">launcher</a>, <a href="#java_binary-licenses">licenses</a>, <a href="#java_binary-main_class">main_class</a>, <a href="#java_binary-neverlink">neverlink</a>, <a href="#java_binary-plugins">plugins</a>, <a href="#java_binary-resource_strip_prefix">resource_strip_prefix</a>, 26 <a href="#java_binary-runtime_deps">runtime_deps</a>, <a href="#java_binary-stamp">stamp</a>, <a href="#java_binary-use_launcher">use_launcher</a>, <a href="#java_binary-use_testrunner">use_testrunner</a>) 27</pre> 28 29<p> 30 Builds a Java archive ("jar file"), plus a wrapper shell script with the same name as the rule. 31 The wrapper shell script uses a classpath that includes, among other things, a jar file for each 32 library on which the binary depends. When running the wrapper shell script, any nonempty 33 <code>JAVABIN</code> environment variable will take precedence over the version specified via 34 Bazel's <code>--java_runtime_version</code> flag. 35</p> 36<p> 37 The wrapper script accepts several unique flags. Refer to 38 <code>//src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt</code> 39 for a list of configurable flags and environment variables accepted by the wrapper. 40</p> 41 42<h4 id="java_binary_implicit_outputs">Implicit output targets</h4> 43<ul> 44 <li><code><var>name</var>.jar</code>: A Java archive, containing the class files and other 45 resources corresponding to the binary's direct dependencies.</li> 46 <li><code><var>name</var>-src.jar</code>: An archive containing the sources ("source 47 jar").</li> 48 <li><code><var>name</var>_deploy.jar</code>: A Java archive suitable for deployment (only 49 built if explicitly requested). 50 <p> 51 Building the <code><<var>name</var>>_deploy.jar</code> target for your rule 52 creates a self-contained jar file with a manifest that allows it to be run with the 53 <code>java -jar</code> command or with the wrapper script's <code>--singlejar</code> 54 option. Using the wrapper script is preferred to <code>java -jar</code> because it 55 also passes the <a href="#java_binary-jvm_flags">JVM flags</a> and the options 56 to load native libraries. 57 </p> 58 <p> 59 The deploy jar contains all the classes that would be found by a classloader that 60 searched the classpath from the binary's wrapper script from beginning to end. It also 61 contains the native libraries needed for dependencies. These are automatically loaded 62 into the JVM at runtime. 63 </p> 64 <p>If your target specifies a <a href="#java_binary.launcher">launcher</a> 65 attribute, then instead of being a normal JAR file, the _deploy.jar will be a 66 native binary. This will contain the launcher plus any native (C++) dependencies of 67 your rule, all linked into a static binary. The actual jar file's bytes will be 68 appended to that native binary, creating a single binary blob containing both the 69 executable and the Java code. You can execute the resulting jar file directly 70 like you would execute any native binary.</p> 71 </li> 72 <li><code><var>name</var>_deploy-src.jar</code>: An archive containing the sources 73 collected from the transitive closure of the target. These will match the classes in the 74 <code>deploy.jar</code> except where jars have no matching source jar.</li> 75</ul> 76 77<p> 78It is good practice to use the name of the source file that is the main entry point of the 79application (minus the extension). For example, if your entry point is called 80<code>Main.java</code>, then your name could be <code>Main</code>. 81</p> 82 83<p> 84 A <code>deps</code> attribute is not allowed in a <code>java_binary</code> rule without 85 <a href="#java_binary-srcs"><code>srcs</code></a>; such a rule requires a 86 <a href="#java_binary-main_class"><code>main_class</code></a> provided by 87 <a href="#java_binary-runtime_deps"><code>runtime_deps</code></a>. 88</p> 89 90<p>The following code snippet illustrates a common mistake:</p> 91 92<pre class="code"> 93<code class="lang-starlark"> 94java_binary( 95 name = "DontDoThis", 96 srcs = [ 97 <var>...</var>, 98 <code class="deprecated">"GeneratedJavaFile.java"</code>, # a generated .java file 99 ], 100 deps = [<code class="deprecated">":generating_rule",</code>], # rule that generates that file 101) 102</code> 103</pre> 104 105<p>Do this instead:</p> 106 107<pre class="code"> 108<code class="lang-starlark"> 109java_binary( 110 name = "DoThisInstead", 111 srcs = [ 112 <var>...</var>, 113 ":generating_rule", 114 ], 115) 116</code> 117</pre> 118 119**ATTRIBUTES** 120 121 122| Name | Description | Type | Mandatory | Default | 123| :------------- | :------------- | :------------- | :------------- | :------------- | 124| <a id="java_binary-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | 125| <a id="java_binary-deps"></a>deps | The list of other libraries to be linked in to the target. See general comments about <code>deps</code> at <a href="common-definitions.html#typical-attributes">Typical attributes defined by most build rules</a>. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 126| <a id="java_binary-srcs"></a>srcs | The list of source files that are processed to create the target. This attribute is almost always required; see exceptions below. <p> Source files of type <code>.java</code> are compiled. In case of generated <code>.java</code> files it is generally advisable to put the generating rule's name here instead of the name of the file itself. This not only improves readability but makes the rule more resilient to future changes: if the generating rule generates different files in the future, you only need to fix one place: the <code>outs</code> of the generating rule. You should not list the generating rule in <code>deps</code> because it is a no-op. </p> <p> Source files of type <code>.srcjar</code> are unpacked and compiled. (This is useful if you need to generate a set of <code>.java</code> files with a genrule.) </p> <p> Rules: if the rule (typically <code>genrule</code> or <code>filegroup</code>) generates any of the files listed above, they will be used the same way as described for source files. </p><br><br><p> This argument is almost always required, except if a <a href="#java_binary.main_class"><code>main_class</code></a> attribute specifies a class on the runtime classpath or you specify the <code>runtime_deps</code> argument. </p> | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 127| <a id="java_binary-data"></a>data | The list of files needed by this library at runtime. See general comments about <code>data</code> at <a href="${link common-definitions#typical-attributes}">Typical attributes defined by most build rules</a>. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 128| <a id="java_binary-resources"></a>resources | A list of data files to include in a Java jar.<br><br><p> Resources may be source files or generated files. </p><br><br><p> If resources are specified, they will be bundled in the jar along with the usual <code>.class</code> files produced by compilation. The location of the resources inside of the jar file is determined by the project structure. Bazel first looks for Maven's <a href="https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html">standard directory layout</a>, (a "src" directory followed by a "resources" directory grandchild). If that is not found, Bazel then looks for the topmost directory named "java" or "javatests" (so, for example, if a resource is at <code><workspace root>/x/java/y/java/z</code>, the path of the resource will be <code>y/java/z</code>. This heuristic cannot be overridden, however, the <code>resource_strip_prefix</code> attribute can be used to specify a specific alternative directory for resource files. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 129| <a id="java_binary-add_exports"></a>add_exports | Allow this library to access the given <code>module</code> or <code>package</code>. <p> This corresponds to the javac and JVM --add-exports= flags. | List of strings | optional | `[]` | 130| <a id="java_binary-add_opens"></a>add_opens | Allow this library to reflectively access the given <code>module</code> or <code>package</code>. <p> This corresponds to the javac and JVM --add-opens= flags. | List of strings | optional | `[]` | 131| <a id="java_binary-bootclasspath"></a>bootclasspath | Restricted API, do not use! | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 132| <a id="java_binary-classpath_resources"></a>classpath_resources | <em class="harmful">DO NOT USE THIS OPTION UNLESS THERE IS NO OTHER WAY)</em> <p> A list of resources that must be located at the root of the java tree. This attribute's only purpose is to support third-party libraries that require that their resources be found on the classpath as exactly <code>"myconfig.xml"</code>. It is only allowed on binaries and not libraries, due to the danger of namespace conflicts. </p> | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 133| <a id="java_binary-create_executable"></a>create_executable | Deprecated, use <code>java_single_jar</code> instead. | Boolean | optional | `True` | 134| <a id="java_binary-deploy_env"></a>deploy_env | A list of other <code>java_binary</code> targets which represent the deployment environment for this binary. Set this attribute when building a plugin which will be loaded by another <code>java_binary</code>.<br/> Setting this attribute excludes all dependencies from the runtime classpath (and the deploy jar) of this binary that are shared between this binary and the targets specified in <code>deploy_env</code>. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 135| <a id="java_binary-deploy_manifest_lines"></a>deploy_manifest_lines | A list of lines to add to the <code>META-INF/manifest.mf</code> file generated for the <code>*_deploy.jar</code> target. The contents of this attribute are <em>not</em> subject to <a href="make-variables.html">"Make variable"</a> substitution. | List of strings | optional | `[]` | 136| <a id="java_binary-env"></a>env | - | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` | 137| <a id="java_binary-javacopts"></a>javacopts | Extra compiler options for this binary. Subject to <a href="make-variables.html">"Make variable"</a> substitution and <a href="common-definitions.html#sh-tokenization">Bourne shell tokenization</a>. <p>These compiler options are passed to javac after the global compiler options.</p> | List of strings | optional | `[]` | 138| <a id="java_binary-jvm_flags"></a>jvm_flags | A list of flags to embed in the wrapper script generated for running this binary. Subject to <a href="${link make-variables#location}">$(location)</a> and <a href="make-variables.html">"Make variable"</a> substitution, and <a href="common-definitions.html#sh-tokenization">Bourne shell tokenization</a>.<br><br><p>The wrapper script for a Java binary includes a CLASSPATH definition (to find all the dependent jars) and invokes the right Java interpreter. The command line generated by the wrapper script includes the name of the main class followed by a <code>"$@"</code> so you can pass along other arguments after the classname. However, arguments intended for parsing by the JVM must be specified <i>before</i> the classname on the command line. The contents of <code>jvm_flags</code> are added to the wrapper script before the classname is listed.</p><br><br><p>Note that this attribute has <em>no effect</em> on <code>*_deploy.jar</code> outputs.</p> | List of strings | optional | `[]` | 139| <a id="java_binary-launcher"></a>launcher | Specify a binary that will be used to run your Java program instead of the normal <code>bin/java</code> program included with the JDK. The target must be a <code>cc_binary</code>. Any <code>cc_binary</code> that implements the <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html"> Java Invocation API</a> can be specified as a value for this attribute.<br><br><p>By default, Bazel will use the normal JDK launcher (bin/java or java.exe).</p><br><br><p>The related <a href="${link user-manual#flag--java_launcher}"><code> --java_launcher</code></a> Bazel flag affects only those <code>java_binary</code> and <code>java_test</code> targets that have <i>not</i> specified a <code>launcher</code> attribute.</p><br><br><p>Note that your native (C++, SWIG, JNI) dependencies will be built differently depending on whether you are using the JDK launcher or another launcher:</p><br><br><ul> <li>If you are using the normal JDK launcher (the default), native dependencies are built as a shared library named <code>{name}_nativedeps.so</code>, where <code>{name}</code> is the <code>name</code> attribute of this java_binary rule. Unused code is <em>not</em> removed by the linker in this configuration.</li><br><br><li>If you are using any other launcher, native (C++) dependencies are statically linked into a binary named <code>{name}_nativedeps</code>, where <code>{name}</code> is the <code>name</code> attribute of this java_binary rule. In this case, the linker will remove any code it thinks is unused from the resulting binary, which means any C++ code accessed only via JNI may not be linked in unless that <code>cc_library</code> target specifies <code>alwayslink = True</code>.</li> </ul><br><br><p>When using any launcher other than the default JDK launcher, the format of the <code>*_deploy.jar</code> output changes. See the main <a href="#java_binary">java_binary</a> docs for details.</p> | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 140| <a id="java_binary-licenses"></a>licenses | - | List of strings | optional | `[]` | 141| <a id="java_binary-main_class"></a>main_class | Name of class with <code>main()</code> method to use as entry point. If a rule uses this option, it does not need a <code>srcs=[...]</code> list. Thus, with this attribute one can make an executable from a Java library that already contains one or more <code>main()</code> methods. <p> The value of this attribute is a class name, not a source file. The class must be available at runtime: it may be compiled by this rule (from <code>srcs</code>) or provided by direct or transitive dependencies (through <code>runtime_deps</code> or <code>deps</code>). If the class is unavailable, the binary will fail at runtime; there is no build-time check. </p> | String | optional | `""` | 142| <a id="java_binary-neverlink"></a>neverlink | - | Boolean | optional | `False` | 143| <a id="java_binary-plugins"></a>plugins | Java compiler plugins to run at compile-time. Every <code>java_plugin</code> specified in this attribute will be run whenever this rule is built. A library may also inherit plugins from dependencies that use <code><a href="#java_library.exported_plugins">exported_plugins</a></code>. Resources generated by the plugin will be included in the resulting jar of this rule. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 144| <a id="java_binary-resource_strip_prefix"></a>resource_strip_prefix | The path prefix to strip from Java resources. <p> If specified, this path prefix is stripped from every file in the <code>resources</code> attribute. It is an error for a resource file not to be under this directory. If not specified (the default), the path of resource file is determined according to the same logic as the Java package of source files. For example, a source file at <code>stuff/java/foo/bar/a.txt</code> will be located at <code>foo/bar/a.txt</code>. </p> | String | optional | `""` | 145| <a id="java_binary-runtime_deps"></a>runtime_deps | Libraries to make available to the final binary or test at runtime only. Like ordinary <code>deps</code>, these will appear on the runtime classpath, but unlike them, not on the compile-time classpath. Dependencies needed only at runtime should be listed here. Dependency-analysis tools should ignore targets that appear in both <code>runtime_deps</code> and <code>deps</code>. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 146| <a id="java_binary-stamp"></a>stamp | Whether to encode build information into the binary. Possible values: <ul> <li> <code>stamp = 1</code>: Always stamp the build information into the binary, even in <a href="${link user-manual#flag--stamp}"><code>--nostamp</code></a> builds. <b>This setting should be avoided</b>, since it potentially kills remote caching for the binary and any downstream actions that depend on it. </li> <li> <code>stamp = 0</code>: Always replace build information by constant values. This gives good build result caching. </li> <li> <code>stamp = -1</code>: Embedding of build information is controlled by the <a href="${link user-manual#flag--stamp}"><code>--[no]stamp</code></a> flag. </li> </ul> <p>Stamped binaries are <em>not</em> rebuilt unless their dependencies change.</p> | Integer | optional | `-1` | 147| <a id="java_binary-use_launcher"></a>use_launcher | Whether the binary should use a custom launcher.<br><br><p>If this attribute is set to false, the <a href="${link java_binary.launcher}">launcher</a> attribute and the related <a href="${link user-manual#flag--java_launcher}"><code>--java_launcher</code></a> flag will be ignored for this target. | Boolean | optional | `True` | 148| <a id="java_binary-use_testrunner"></a>use_testrunner | Use the test runner (by default <code>com.google.testing.junit.runner.BazelTestRunner</code>) class as the main entry point for a Java program, and provide the test class to the test runner as a value of <code>bazel.test_suite</code> system property.<br><br><br/> You can use this to override the default behavior, which is to use test runner for <code>java_test</code> rules, and not use it for <code>java_binary</code> rules. It is unlikely you will want to do this. One use is for <code>AllTest</code> rules that are invoked by another rule (to set up a database before running the tests, for example). The <code>AllTest</code> rule must be declared as a <code>java_binary</code>, but should still use the test runner as its main entry point.<br><br>The name of a test runner class can be overridden with <code>main_class</code> attribute. | Boolean | optional | `False` | 149 150 151<a id="java_import"></a> 152 153## java_import 154 155<pre> 156java_import(<a href="#java_import-name">name</a>, <a href="#java_import-deps">deps</a>, <a href="#java_import-data">data</a>, <a href="#java_import-add_exports">add_exports</a>, <a href="#java_import-add_opens">add_opens</a>, <a href="#java_import-constraints">constraints</a>, <a href="#java_import-exports">exports</a>, <a href="#java_import-jars">jars</a>, <a href="#java_import-licenses">licenses</a>, 157 <a href="#java_import-neverlink">neverlink</a>, <a href="#java_import-proguard_specs">proguard_specs</a>, <a href="#java_import-runtime_deps">runtime_deps</a>, <a href="#java_import-srcjar">srcjar</a>) 158</pre> 159 160<p> 161 This rule allows the use of precompiled <code>.jar</code> files as 162 libraries for <code><a href="#java_library">java_library</a></code> and 163 <code>java_binary</code> rules. 164</p> 165 166<h4 id="java_import_examples">Examples</h4> 167 168<pre class="code"> 169<code class="lang-starlark"> 170 java_import( 171 name = "maven_model", 172 jars = [ 173 "maven_model/maven-aether-provider-3.2.3.jar", 174 "maven_model/maven-model-3.2.3.jar", 175 "maven_model/maven-model-builder-3.2.3.jar", 176 ], 177 ) 178</code> 179</pre> 180 181**ATTRIBUTES** 182 183 184| Name | Description | Type | Mandatory | Default | 185| :------------- | :------------- | :------------- | :------------- | :------------- | 186| <a id="java_import-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | 187| <a id="java_import-deps"></a>deps | The list of other libraries to be linked in to the target. See <a href="${link java_library.deps}">java_library.deps</a>. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 188| <a id="java_import-data"></a>data | The list of files needed by this rule at runtime. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 189| <a id="java_import-add_exports"></a>add_exports | Allow this library to access the given <code>module</code> or <code>package</code>. <p> This corresponds to the javac and JVM --add-exports= flags. | List of strings | optional | `[]` | 190| <a id="java_import-add_opens"></a>add_opens | Allow this library to reflectively access the given <code>module</code> or <code>package</code>. <p> This corresponds to the javac and JVM --add-opens= flags. | List of strings | optional | `[]` | 191| <a id="java_import-constraints"></a>constraints | Extra constraints imposed on this rule as a Java library. | List of strings | optional | `[]` | 192| <a id="java_import-exports"></a>exports | Targets to make available to users of this rule. See <a href="${link java_library.exports}">java_library.exports</a>. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 193| <a id="java_import-jars"></a>jars | The list of JAR files provided to Java targets that depend on this target. | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | | 194| <a id="java_import-licenses"></a>licenses | - | List of strings | optional | `[]` | 195| <a id="java_import-neverlink"></a>neverlink | Only use this library for compilation and not at runtime. Useful if the library will be provided by the runtime environment during execution. Examples of libraries like this are IDE APIs for IDE plug-ins or <code>tools.jar</code> for anything running on a standard JDK. | Boolean | optional | `False` | 196| <a id="java_import-proguard_specs"></a>proguard_specs | Files to be used as Proguard specification. These will describe the set of specifications to be used by Proguard. If specified, they will be added to any <code>android_binary</code> target depending on this library.<br><br>The files included here must only have idempotent rules, namely -dontnote, -dontwarn, assumenosideeffects, and rules that start with -keep. Other options can only appear in <code>android_binary</code>'s proguard_specs, to ensure non-tautological merges. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 197| <a id="java_import-runtime_deps"></a>runtime_deps | Libraries to make available to the final binary or test at runtime only. See <a href="${link java_library.runtime_deps}">java_library.runtime_deps</a>. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 198| <a id="java_import-srcjar"></a>srcjar | A JAR file that contains source code for the compiled JAR files. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 199 200 201<a id="java_library"></a> 202 203## java_library 204 205<pre> 206java_library(<a href="#java_library-name">name</a>, <a href="#java_library-deps">deps</a>, <a href="#java_library-srcs">srcs</a>, <a href="#java_library-data">data</a>, <a href="#java_library-resources">resources</a>, <a href="#java_library-add_exports">add_exports</a>, <a href="#java_library-add_opens">add_opens</a>, <a href="#java_library-bootclasspath">bootclasspath</a>, 207 <a href="#java_library-exported_plugins">exported_plugins</a>, <a href="#java_library-exports">exports</a>, <a href="#java_library-javabuilder_jvm_flags">javabuilder_jvm_flags</a>, <a href="#java_library-javacopts">javacopts</a>, <a href="#java_library-licenses">licenses</a>, <a href="#java_library-neverlink">neverlink</a>, 208 <a href="#java_library-plugins">plugins</a>, <a href="#java_library-proguard_specs">proguard_specs</a>, <a href="#java_library-resource_strip_prefix">resource_strip_prefix</a>, <a href="#java_library-runtime_deps">runtime_deps</a>) 209</pre> 210 211<p>This rule compiles and links sources into a <code>.jar</code> file.</p> 212 213<h4>Implicit outputs</h4> 214<ul> 215 <li><code>lib<var>name</var>.jar</code>: A Java archive containing the class files.</li> 216 <li><code>lib<var>name</var>-src.jar</code>: An archive containing the sources ("source 217 jar").</li> 218</ul> 219 220**ATTRIBUTES** 221 222 223| Name | Description | Type | Mandatory | Default | 224| :------------- | :------------- | :------------- | :------------- | :------------- | 225| <a id="java_library-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | 226| <a id="java_library-deps"></a>deps | The list of libraries to link into this library. See general comments about <code>deps</code> at <a href="${link common-definitions#typical-attributes}">Typical attributes defined by most build rules</a>. <p> The jars built by <code>java_library</code> rules listed in <code>deps</code> will be on the compile-time classpath of this rule. Furthermore the transitive closure of their <code>deps</code>, <code>runtime_deps</code> and <code>exports</code> will be on the runtime classpath. </p> <p> By contrast, targets in the <code>data</code> attribute are included in the runfiles but on neither the compile-time nor runtime classpath. </p> | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 227| <a id="java_library-srcs"></a>srcs | The list of source files that are processed to create the target. This attribute is almost always required; see exceptions below. <p> Source files of type <code>.java</code> are compiled. In case of generated <code>.java</code> files it is generally advisable to put the generating rule's name here instead of the name of the file itself. This not only improves readability but makes the rule more resilient to future changes: if the generating rule generates different files in the future, you only need to fix one place: the <code>outs</code> of the generating rule. You should not list the generating rule in <code>deps</code> because it is a no-op. </p> <p> Source files of type <code>.srcjar</code> are unpacked and compiled. (This is useful if you need to generate a set of <code>.java</code> files with a genrule.) </p> <p> Rules: if the rule (typically <code>genrule</code> or <code>filegroup</code>) generates any of the files listed above, they will be used the same way as described for source files. </p> <p> Source files of type <code>.properties</code> are treated as resources. </p><br><br><p>All other files are ignored, as long as there is at least one file of a file type described above. Otherwise an error is raised.</p><br><br><p> This argument is almost always required, except if you specify the <code>runtime_deps</code> argument. </p> | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 228| <a id="java_library-data"></a>data | The list of files needed by this library at runtime. See general comments about <code>data</code> at <a href="${link common-definitions#typical-attributes}">Typical attributes defined by most build rules</a>. <p> When building a <code>java_library</code>, Bazel doesn't put these files anywhere; if the <code>data</code> files are generated files then Bazel generates them. When building a test that depends on this <code>java_library</code> Bazel copies or links the <code>data</code> files into the runfiles area. </p> | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 229| <a id="java_library-resources"></a>resources | A list of data files to include in a Java jar. <p> Resources may be source files or generated files. </p><br><br><p> If resources are specified, they will be bundled in the jar along with the usual <code>.class</code> files produced by compilation. The location of the resources inside of the jar file is determined by the project structure. Bazel first looks for Maven's <a href="https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html">standard directory layout</a>, (a "src" directory followed by a "resources" directory grandchild). If that is not found, Bazel then looks for the topmost directory named "java" or "javatests" (so, for example, if a resource is at <code><workspace root>/x/java/y/java/z</code>, the path of the resource will be <code>y/java/z</code>. This heuristic cannot be overridden, however, the <code>resource_strip_prefix</code> attribute can be used to specify a specific alternative directory for resource files. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 230| <a id="java_library-add_exports"></a>add_exports | Allow this library to access the given <code>module</code> or <code>package</code>. <p> This corresponds to the javac and JVM --add-exports= flags. | List of strings | optional | `[]` | 231| <a id="java_library-add_opens"></a>add_opens | Allow this library to reflectively access the given <code>module</code> or <code>package</code>. <p> This corresponds to the javac and JVM --add-opens= flags. | List of strings | optional | `[]` | 232| <a id="java_library-bootclasspath"></a>bootclasspath | Restricted API, do not use! | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 233| <a id="java_library-exported_plugins"></a>exported_plugins | The list of <code><a href="#${link java_plugin}">java_plugin</a></code>s (e.g. annotation processors) to export to libraries that directly depend on this library. <p> The specified list of <code>java_plugin</code>s will be applied to any library which directly depends on this library, just as if that library had explicitly declared these labels in <code><a href="${link java_library.plugins}">plugins</a></code>. </p> | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 234| <a id="java_library-exports"></a>exports | Exported libraries. <p> Listing rules here will make them available to parent rules, as if the parents explicitly depended on these rules. This is not true for regular (non-exported) <code>deps</code>. </p> <p> Summary: a rule <i>X</i> can access the code in <i>Y</i> if there exists a dependency path between them that begins with a <code>deps</code> edge followed by zero or more <code>exports</code> edges. Let's see some examples to illustrate this. </p> <p> Assume <i>A</i> depends on <i>B</i> and <i>B</i> depends on <i>C</i>. In this case C is a <em>transitive</em> dependency of A, so changing C's sources and rebuilding A will correctly rebuild everything. However A will not be able to use classes in C. To allow that, either A has to declare C in its <code>deps</code>, or B can make it easier for A (and anything that may depend on A) by declaring C in its (B's) <code>exports</code> attribute. </p> <p> The closure of exported libraries is available to all direct parent rules. Take a slightly different example: A depends on B, B depends on C and D, and also exports C but not D. Now A has access to C but not to D. Now, if C and D exported some libraries, C' and D' respectively, A could only access C' but not D'. </p> <p> Important: an exported rule is not a regular dependency. Sticking to the previous example, if B exports C and wants to also use C, it has to also list it in its own <code>deps</code>. </p> | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 235| <a id="java_library-javabuilder_jvm_flags"></a>javabuilder_jvm_flags | Restricted API, do not use! | List of strings | optional | `[]` | 236| <a id="java_library-javacopts"></a>javacopts | Extra compiler options for this library. Subject to <a href="make-variables.html">"Make variable"</a> substitution and <a href="common-definitions.html#sh-tokenization">Bourne shell tokenization</a>. <p>These compiler options are passed to javac after the global compiler options.</p> | List of strings | optional | `[]` | 237| <a id="java_library-licenses"></a>licenses | - | List of strings | optional | `[]` | 238| <a id="java_library-neverlink"></a>neverlink | Whether this library should only be used for compilation and not at runtime. Useful if the library will be provided by the runtime environment during execution. Examples of such libraries are the IDE APIs for IDE plug-ins or <code>tools.jar</code> for anything running on a standard JDK. <p> Note that <code>neverlink = True</code> does not prevent the compiler from inlining material from this library into compilation targets that depend on it, as permitted by the Java Language Specification (e.g., <code>static final</code> constants of <code>String</code> or of primitive types). The preferred use case is therefore when the runtime library is identical to the compilation library. </p> <p> If the runtime library differs from the compilation library then you must ensure that it differs only in places that the JLS forbids compilers to inline (and that must hold for all future versions of the JLS). </p> | Boolean | optional | `False` | 239| <a id="java_library-plugins"></a>plugins | Java compiler plugins to run at compile-time. Every <code>java_plugin</code> specified in this attribute will be run whenever this rule is built. A library may also inherit plugins from dependencies that use <code><a href="#java_library.exported_plugins">exported_plugins</a></code>. Resources generated by the plugin will be included in the resulting jar of this rule. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 240| <a id="java_library-proguard_specs"></a>proguard_specs | Files to be used as Proguard specification. These will describe the set of specifications to be used by Proguard. If specified, they will be added to any <code>android_binary</code> target depending on this library.<br><br>The files included here must only have idempotent rules, namely -dontnote, -dontwarn, assumenosideeffects, and rules that start with -keep. Other options can only appear in <code>android_binary</code>'s proguard_specs, to ensure non-tautological merges. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 241| <a id="java_library-resource_strip_prefix"></a>resource_strip_prefix | The path prefix to strip from Java resources. <p> If specified, this path prefix is stripped from every file in the <code>resources</code> attribute. It is an error for a resource file not to be under this directory. If not specified (the default), the path of resource file is determined according to the same logic as the Java package of source files. For example, a source file at <code>stuff/java/foo/bar/a.txt</code> will be located at <code>foo/bar/a.txt</code>. </p> | String | optional | `""` | 242| <a id="java_library-runtime_deps"></a>runtime_deps | Libraries to make available to the final binary or test at runtime only. Like ordinary <code>deps</code>, these will appear on the runtime classpath, but unlike them, not on the compile-time classpath. Dependencies needed only at runtime should be listed here. Dependency-analysis tools should ignore targets that appear in both <code>runtime_deps</code> and <code>deps</code>. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 243 244 245<a id="java_package_configuration"></a> 246 247## java_package_configuration 248 249<pre> 250java_package_configuration(<a href="#java_package_configuration-name">name</a>, <a href="#java_package_configuration-data">data</a>, <a href="#java_package_configuration-javacopts">javacopts</a>, <a href="#java_package_configuration-output_licenses">output_licenses</a>, <a href="#java_package_configuration-packages">packages</a>, <a href="#java_package_configuration-system">system</a>) 251</pre> 252 253<p> 254Configuration to apply to a set of packages. 255Configurations can be added to 256<code><a href="${link java_toolchain.javacopts}">java_toolchain.javacopts</a></code>s. 257</p> 258 259<h4 id="java_package_configuration_example">Example:</h4> 260 261<pre class="code"> 262<code class="lang-starlark"> 263 264java_package_configuration( 265 name = "my_configuration", 266 packages = [":my_packages"], 267 javacopts = ["-Werror"], 268) 269 270package_group( 271 name = "my_packages", 272 packages = [ 273 "//com/my/project/...", 274 "-//com/my/project/testing/...", 275 ], 276) 277 278java_toolchain( 279 ..., 280 package_configuration = [ 281 ":my_configuration", 282 ] 283) 284 285</code> 286</pre> 287 288**ATTRIBUTES** 289 290 291| Name | Description | Type | Mandatory | Default | 292| :------------- | :------------- | :------------- | :------------- | :------------- | 293| <a id="java_package_configuration-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | 294| <a id="java_package_configuration-data"></a>data | The list of files needed by this configuration at runtime. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 295| <a id="java_package_configuration-javacopts"></a>javacopts | Java compiler flags. | List of strings | optional | `[]` | 296| <a id="java_package_configuration-output_licenses"></a>output_licenses | - | List of strings | optional | `[]` | 297| <a id="java_package_configuration-packages"></a>packages | The set of <code><a href="${link package_group}">package_group</a></code>s the configuration should be applied to. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 298| <a id="java_package_configuration-system"></a>system | Corresponds to javac's --system flag. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 299 300 301<a id="java_plugin"></a> 302 303## java_plugin 304 305<pre> 306java_plugin(<a href="#java_plugin-name">name</a>, <a href="#java_plugin-deps">deps</a>, <a href="#java_plugin-srcs">srcs</a>, <a href="#java_plugin-data">data</a>, <a href="#java_plugin-resources">resources</a>, <a href="#java_plugin-add_exports">add_exports</a>, <a href="#java_plugin-add_opens">add_opens</a>, <a href="#java_plugin-bootclasspath">bootclasspath</a>, <a href="#java_plugin-generates_api">generates_api</a>, 307 <a href="#java_plugin-javabuilder_jvm_flags">javabuilder_jvm_flags</a>, <a href="#java_plugin-javacopts">javacopts</a>, <a href="#java_plugin-licenses">licenses</a>, <a href="#java_plugin-neverlink">neverlink</a>, <a href="#java_plugin-output_licenses">output_licenses</a>, <a href="#java_plugin-plugins">plugins</a>, 308 <a href="#java_plugin-processor_class">processor_class</a>, <a href="#java_plugin-proguard_specs">proguard_specs</a>, <a href="#java_plugin-resource_strip_prefix">resource_strip_prefix</a>) 309</pre> 310 311<p> 312 <code>java_plugin</code> defines plugins for the Java compiler run by Bazel. The 313 only supported kind of plugins are annotation processors. A <code>java_library</code> or 314 <code>java_binary</code> rule can run plugins by depending on them via the <code>plugins</code> 315 attribute. A <code>java_library</code> can also automatically export plugins to libraries that 316 directly depend on it using 317 <code><a href="#java_library-exported_plugins">exported_plugins</a></code>. 318</p> 319 320<h4 id="java_plugin_implicit_outputs">Implicit output targets</h4> 321 <ul> 322 <li><code><var>libname</var>.jar</code>: A Java archive.</li> 323 </ul> 324 325<p> 326 Arguments are identical to <a href="#java_library"><code>java_library</code></a>, except 327 for the addition of the <code>processor_class</code> argument. 328</p> 329 330**ATTRIBUTES** 331 332 333| Name | Description | Type | Mandatory | Default | 334| :------------- | :------------- | :------------- | :------------- | :------------- | 335| <a id="java_plugin-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | 336| <a id="java_plugin-deps"></a>deps | The list of libraries to link into this library. See general comments about <code>deps</code> at <a href="${link common-definitions#typical-attributes}">Typical attributes defined by most build rules</a>. <p> The jars built by <code>java_library</code> rules listed in <code>deps</code> will be on the compile-time classpath of this rule. Furthermore the transitive closure of their <code>deps</code>, <code>runtime_deps</code> and <code>exports</code> will be on the runtime classpath. </p> <p> By contrast, targets in the <code>data</code> attribute are included in the runfiles but on neither the compile-time nor runtime classpath. </p> | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 337| <a id="java_plugin-srcs"></a>srcs | The list of source files that are processed to create the target. This attribute is almost always required; see exceptions below. <p> Source files of type <code>.java</code> are compiled. In case of generated <code>.java</code> files it is generally advisable to put the generating rule's name here instead of the name of the file itself. This not only improves readability but makes the rule more resilient to future changes: if the generating rule generates different files in the future, you only need to fix one place: the <code>outs</code> of the generating rule. You should not list the generating rule in <code>deps</code> because it is a no-op. </p> <p> Source files of type <code>.srcjar</code> are unpacked and compiled. (This is useful if you need to generate a set of <code>.java</code> files with a genrule.) </p> <p> Rules: if the rule (typically <code>genrule</code> or <code>filegroup</code>) generates any of the files listed above, they will be used the same way as described for source files. </p> <p> Source files of type <code>.properties</code> are treated as resources. </p><br><br><p>All other files are ignored, as long as there is at least one file of a file type described above. Otherwise an error is raised.</p><br><br><p> This argument is almost always required, except if you specify the <code>runtime_deps</code> argument. </p> | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 338| <a id="java_plugin-data"></a>data | The list of files needed by this library at runtime. See general comments about <code>data</code> at <a href="${link common-definitions#typical-attributes}">Typical attributes defined by most build rules</a>. <p> When building a <code>java_library</code>, Bazel doesn't put these files anywhere; if the <code>data</code> files are generated files then Bazel generates them. When building a test that depends on this <code>java_library</code> Bazel copies or links the <code>data</code> files into the runfiles area. </p> | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 339| <a id="java_plugin-resources"></a>resources | A list of data files to include in a Java jar. <p> Resources may be source files or generated files. </p><br><br><p> If resources are specified, they will be bundled in the jar along with the usual <code>.class</code> files produced by compilation. The location of the resources inside of the jar file is determined by the project structure. Bazel first looks for Maven's <a href="https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html">standard directory layout</a>, (a "src" directory followed by a "resources" directory grandchild). If that is not found, Bazel then looks for the topmost directory named "java" or "javatests" (so, for example, if a resource is at <code><workspace root>/x/java/y/java/z</code>, the path of the resource will be <code>y/java/z</code>. This heuristic cannot be overridden, however, the <code>resource_strip_prefix</code> attribute can be used to specify a specific alternative directory for resource files. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 340| <a id="java_plugin-add_exports"></a>add_exports | Allow this library to access the given <code>module</code> or <code>package</code>. <p> This corresponds to the javac and JVM --add-exports= flags. | List of strings | optional | `[]` | 341| <a id="java_plugin-add_opens"></a>add_opens | Allow this library to reflectively access the given <code>module</code> or <code>package</code>. <p> This corresponds to the javac and JVM --add-opens= flags. | List of strings | optional | `[]` | 342| <a id="java_plugin-bootclasspath"></a>bootclasspath | Restricted API, do not use! | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 343| <a id="java_plugin-generates_api"></a>generates_api | This attribute marks annotation processors that generate API code. <p>If a rule uses an API-generating annotation processor, other rules depending on it can refer to the generated code only if their compilation actions are scheduled after the generating rule. This attribute instructs Bazel to introduce scheduling constraints when --java_header_compilation is enabled. <p><em class="harmful">WARNING: This attribute affects build performance, use it only if necessary.</em></p> | Boolean | optional | `False` | 344| <a id="java_plugin-javabuilder_jvm_flags"></a>javabuilder_jvm_flags | Restricted API, do not use! | List of strings | optional | `[]` | 345| <a id="java_plugin-javacopts"></a>javacopts | Extra compiler options for this library. Subject to <a href="make-variables.html">"Make variable"</a> substitution and <a href="common-definitions.html#sh-tokenization">Bourne shell tokenization</a>. <p>These compiler options are passed to javac after the global compiler options.</p> | List of strings | optional | `[]` | 346| <a id="java_plugin-licenses"></a>licenses | - | List of strings | optional | `[]` | 347| <a id="java_plugin-neverlink"></a>neverlink | Whether this library should only be used for compilation and not at runtime. Useful if the library will be provided by the runtime environment during execution. Examples of such libraries are the IDE APIs for IDE plug-ins or <code>tools.jar</code> for anything running on a standard JDK. <p> Note that <code>neverlink = True</code> does not prevent the compiler from inlining material from this library into compilation targets that depend on it, as permitted by the Java Language Specification (e.g., <code>static final</code> constants of <code>String</code> or of primitive types). The preferred use case is therefore when the runtime library is identical to the compilation library. </p> <p> If the runtime library differs from the compilation library then you must ensure that it differs only in places that the JLS forbids compilers to inline (and that must hold for all future versions of the JLS). </p> | Boolean | optional | `False` | 348| <a id="java_plugin-output_licenses"></a>output_licenses | - | List of strings | optional | `[]` | 349| <a id="java_plugin-plugins"></a>plugins | Java compiler plugins to run at compile-time. Every <code>java_plugin</code> specified in this attribute will be run whenever this rule is built. A library may also inherit plugins from dependencies that use <code><a href="#java_library.exported_plugins">exported_plugins</a></code>. Resources generated by the plugin will be included in the resulting jar of this rule. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 350| <a id="java_plugin-processor_class"></a>processor_class | The processor class is the fully qualified type of the class that the Java compiler should use as entry point to the annotation processor. If not specified, this rule will not contribute an annotation processor to the Java compiler's annotation processing, but its runtime classpath will still be included on the compiler's annotation processor path. (This is primarily intended for use by <a href="https://errorprone.info/docs/plugins">Error Prone plugins</a>, which are loaded from the annotation processor path using <a href="https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html"> java.util.ServiceLoader</a>.) | String | optional | `""` | 351| <a id="java_plugin-proguard_specs"></a>proguard_specs | Files to be used as Proguard specification. These will describe the set of specifications to be used by Proguard. If specified, they will be added to any <code>android_binary</code> target depending on this library.<br><br>The files included here must only have idempotent rules, namely -dontnote, -dontwarn, assumenosideeffects, and rules that start with -keep. Other options can only appear in <code>android_binary</code>'s proguard_specs, to ensure non-tautological merges. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 352| <a id="java_plugin-resource_strip_prefix"></a>resource_strip_prefix | The path prefix to strip from Java resources. <p> If specified, this path prefix is stripped from every file in the <code>resources</code> attribute. It is an error for a resource file not to be under this directory. If not specified (the default), the path of resource file is determined according to the same logic as the Java package of source files. For example, a source file at <code>stuff/java/foo/bar/a.txt</code> will be located at <code>foo/bar/a.txt</code>. </p> | String | optional | `""` | 353 354 355<a id="java_runtime"></a> 356 357## java_runtime 358 359<pre> 360java_runtime(<a href="#java_runtime-name">name</a>, <a href="#java_runtime-srcs">srcs</a>, <a href="#java_runtime-default_cds">default_cds</a>, <a href="#java_runtime-hermetic_srcs">hermetic_srcs</a>, <a href="#java_runtime-hermetic_static_libs">hermetic_static_libs</a>, <a href="#java_runtime-java">java</a>, <a href="#java_runtime-java_home">java_home</a>, 361 <a href="#java_runtime-lib_ct_sym">lib_ct_sym</a>, <a href="#java_runtime-lib_modules">lib_modules</a>, <a href="#java_runtime-output_licenses">output_licenses</a>, <a href="#java_runtime-version">version</a>) 362</pre> 363 364<p> 365Specifies the configuration for a Java runtime. 366</p> 367 368<h4 id="java_runtime_example">Example:</h4> 369 370<pre class="code"> 371<code class="lang-starlark"> 372 373java_runtime( 374 name = "jdk-9-ea+153", 375 srcs = glob(["jdk9-ea+153/**"]), 376 java_home = "jdk9-ea+153", 377) 378 379</code> 380</pre> 381 382**ATTRIBUTES** 383 384 385| Name | Description | Type | Mandatory | Default | 386| :------------- | :------------- | :------------- | :------------- | :------------- | 387| <a id="java_runtime-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | 388| <a id="java_runtime-srcs"></a>srcs | All files in the runtime. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 389| <a id="java_runtime-default_cds"></a>default_cds | Default CDS archive for hermetic <code>java_runtime</code>. When hermetic is enabled for a <code>java_binary</code> target and if the target does not provide its own CDS archive by specifying the <a href="${link java_binary.classlist}"><code>classlist</code></a> attribute, the <code>java_runtime</code> default CDS is packaged in the hermetic deploy JAR. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 390| <a id="java_runtime-hermetic_srcs"></a>hermetic_srcs | Files in the runtime needed for hermetic deployments. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 391| <a id="java_runtime-hermetic_static_libs"></a>hermetic_static_libs | The libraries that are statically linked with the launcher for hermetic deployments | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 392| <a id="java_runtime-java"></a>java | The path to the java executable. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 393| <a id="java_runtime-java_home"></a>java_home | The path to the root of the runtime. Subject to <a href="${link make-variables}">"Make" variable</a> substitution. If this path is absolute, the rule denotes a non-hermetic Java runtime with a well-known path. In that case, the <code>srcs</code> and <code>java</code> attributes must be empty. | String | optional | `""` | 394| <a id="java_runtime-lib_ct_sym"></a>lib_ct_sym | The lib/ct.sym file needed for compilation with <code>--release</code>. If not specified and there is exactly one file in <code>srcs</code> whose path ends with <code>/lib/ct.sym</code>, that file is used. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 395| <a id="java_runtime-lib_modules"></a>lib_modules | The lib/modules file needed for hermetic deployments. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 396| <a id="java_runtime-output_licenses"></a>output_licenses | - | List of strings | optional | `[]` | 397| <a id="java_runtime-version"></a>version | The feature version of the Java runtime. I.e., the integer returned by <code>Runtime.version().feature()</code>. | Integer | optional | `0` | 398 399 400<a id="java_test"></a> 401 402## java_test 403 404<pre> 405java_test(<a href="#java_test-name">name</a>, <a href="#java_test-deps">deps</a>, <a href="#java_test-srcs">srcs</a>, <a href="#java_test-data">data</a>, <a href="#java_test-resources">resources</a>, <a href="#java_test-add_exports">add_exports</a>, <a href="#java_test-add_opens">add_opens</a>, <a href="#java_test-bootclasspath">bootclasspath</a>, 406 <a href="#java_test-classpath_resources">classpath_resources</a>, <a href="#java_test-create_executable">create_executable</a>, <a href="#java_test-deploy_manifest_lines">deploy_manifest_lines</a>, <a href="#java_test-env">env</a>, <a href="#java_test-env_inherit">env_inherit</a>, <a href="#java_test-javacopts">javacopts</a>, 407 <a href="#java_test-jvm_flags">jvm_flags</a>, <a href="#java_test-launcher">launcher</a>, <a href="#java_test-licenses">licenses</a>, <a href="#java_test-main_class">main_class</a>, <a href="#java_test-neverlink">neverlink</a>, <a href="#java_test-plugins">plugins</a>, <a href="#java_test-resource_strip_prefix">resource_strip_prefix</a>, 408 <a href="#java_test-runtime_deps">runtime_deps</a>, <a href="#java_test-stamp">stamp</a>, <a href="#java_test-test_class">test_class</a>, <a href="#java_test-use_launcher">use_launcher</a>, <a href="#java_test-use_testrunner">use_testrunner</a>) 409</pre> 410 411<p> 412A <code>java_test()</code> rule compiles a Java test. A test is a binary wrapper around your 413test code. The test runner's main method is invoked instead of the main class being compiled. 414</p> 415 416<h4 id="java_test_implicit_outputs">Implicit output targets</h4> 417<ul> 418 <li><code><var>name</var>.jar</code>: A Java archive.</li> 419 <li><code><var>name</var>_deploy.jar</code>: A Java archive suitable 420 for deployment. (Only built if explicitly requested.) See the description of the 421 <code><var>name</var>_deploy.jar</code> output from 422 <a href="#java_binary">java_binary</a> for more details.</li> 423</ul> 424 425<p> 426See the section on <code>java_binary()</code> arguments. This rule also 427supports all <a href="https://bazel.build/reference/be/common-definitions#common-attributes-tests">attributes common 428to all test rules (*_test)</a>. 429</p> 430 431<h4 id="java_test_examples">Examples</h4> 432 433<pre class="code"> 434<code class="lang-starlark"> 435 436java_library( 437 name = "tests", 438 srcs = glob(["*.java"]), 439 deps = [ 440 "//java/com/foo/base:testResources", 441 "//java/com/foo/testing/util", 442 ], 443) 444 445java_test( 446 name = "AllTests", 447 size = "small", 448 runtime_deps = [ 449 ":tests", 450 "//util/mysql", 451 ], 452) 453</code> 454</pre> 455 456**ATTRIBUTES** 457 458 459| Name | Description | Type | Mandatory | Default | 460| :------------- | :------------- | :------------- | :------------- | :------------- | 461| <a id="java_test-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | 462| <a id="java_test-deps"></a>deps | The list of other libraries to be linked in to the target. See general comments about <code>deps</code> at <a href="common-definitions.html#typical-attributes">Typical attributes defined by most build rules</a>. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 463| <a id="java_test-srcs"></a>srcs | The list of source files that are processed to create the target. This attribute is almost always required; see exceptions below. <p> Source files of type <code>.java</code> are compiled. In case of generated <code>.java</code> files it is generally advisable to put the generating rule's name here instead of the name of the file itself. This not only improves readability but makes the rule more resilient to future changes: if the generating rule generates different files in the future, you only need to fix one place: the <code>outs</code> of the generating rule. You should not list the generating rule in <code>deps</code> because it is a no-op. </p> <p> Source files of type <code>.srcjar</code> are unpacked and compiled. (This is useful if you need to generate a set of <code>.java</code> files with a genrule.) </p> <p> Rules: if the rule (typically <code>genrule</code> or <code>filegroup</code>) generates any of the files listed above, they will be used the same way as described for source files. </p><br><br><p> This argument is almost always required, except if a <a href="#java_binary.main_class"><code>main_class</code></a> attribute specifies a class on the runtime classpath or you specify the <code>runtime_deps</code> argument. </p> | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 464| <a id="java_test-data"></a>data | The list of files needed by this library at runtime. See general comments about <code>data</code> at <a href="${link common-definitions#typical-attributes}">Typical attributes defined by most build rules</a>. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 465| <a id="java_test-resources"></a>resources | A list of data files to include in a Java jar.<br><br><p> Resources may be source files or generated files. </p><br><br><p> If resources are specified, they will be bundled in the jar along with the usual <code>.class</code> files produced by compilation. The location of the resources inside of the jar file is determined by the project structure. Bazel first looks for Maven's <a href="https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html">standard directory layout</a>, (a "src" directory followed by a "resources" directory grandchild). If that is not found, Bazel then looks for the topmost directory named "java" or "javatests" (so, for example, if a resource is at <code><workspace root>/x/java/y/java/z</code>, the path of the resource will be <code>y/java/z</code>. This heuristic cannot be overridden, however, the <code>resource_strip_prefix</code> attribute can be used to specify a specific alternative directory for resource files. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 466| <a id="java_test-add_exports"></a>add_exports | Allow this library to access the given <code>module</code> or <code>package</code>. <p> This corresponds to the javac and JVM --add-exports= flags. | List of strings | optional | `[]` | 467| <a id="java_test-add_opens"></a>add_opens | Allow this library to reflectively access the given <code>module</code> or <code>package</code>. <p> This corresponds to the javac and JVM --add-opens= flags. | List of strings | optional | `[]` | 468| <a id="java_test-bootclasspath"></a>bootclasspath | Restricted API, do not use! | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 469| <a id="java_test-classpath_resources"></a>classpath_resources | <em class="harmful">DO NOT USE THIS OPTION UNLESS THERE IS NO OTHER WAY)</em> <p> A list of resources that must be located at the root of the java tree. This attribute's only purpose is to support third-party libraries that require that their resources be found on the classpath as exactly <code>"myconfig.xml"</code>. It is only allowed on binaries and not libraries, due to the danger of namespace conflicts. </p> | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 470| <a id="java_test-create_executable"></a>create_executable | Deprecated, use <code>java_single_jar</code> instead. | Boolean | optional | `True` | 471| <a id="java_test-deploy_manifest_lines"></a>deploy_manifest_lines | A list of lines to add to the <code>META-INF/manifest.mf</code> file generated for the <code>*_deploy.jar</code> target. The contents of this attribute are <em>not</em> subject to <a href="make-variables.html">"Make variable"</a> substitution. | List of strings | optional | `[]` | 472| <a id="java_test-env"></a>env | - | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` | 473| <a id="java_test-env_inherit"></a>env_inherit | - | List of strings | optional | `[]` | 474| <a id="java_test-javacopts"></a>javacopts | Extra compiler options for this binary. Subject to <a href="make-variables.html">"Make variable"</a> substitution and <a href="common-definitions.html#sh-tokenization">Bourne shell tokenization</a>. <p>These compiler options are passed to javac after the global compiler options.</p> | List of strings | optional | `[]` | 475| <a id="java_test-jvm_flags"></a>jvm_flags | A list of flags to embed in the wrapper script generated for running this binary. Subject to <a href="${link make-variables#location}">$(location)</a> and <a href="make-variables.html">"Make variable"</a> substitution, and <a href="common-definitions.html#sh-tokenization">Bourne shell tokenization</a>.<br><br><p>The wrapper script for a Java binary includes a CLASSPATH definition (to find all the dependent jars) and invokes the right Java interpreter. The command line generated by the wrapper script includes the name of the main class followed by a <code>"$@"</code> so you can pass along other arguments after the classname. However, arguments intended for parsing by the JVM must be specified <i>before</i> the classname on the command line. The contents of <code>jvm_flags</code> are added to the wrapper script before the classname is listed.</p><br><br><p>Note that this attribute has <em>no effect</em> on <code>*_deploy.jar</code> outputs.</p> | List of strings | optional | `[]` | 476| <a id="java_test-launcher"></a>launcher | Specify a binary that will be used to run your Java program instead of the normal <code>bin/java</code> program included with the JDK. The target must be a <code>cc_binary</code>. Any <code>cc_binary</code> that implements the <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html"> Java Invocation API</a> can be specified as a value for this attribute.<br><br><p>By default, Bazel will use the normal JDK launcher (bin/java or java.exe).</p><br><br><p>The related <a href="${link user-manual#flag--java_launcher}"><code> --java_launcher</code></a> Bazel flag affects only those <code>java_binary</code> and <code>java_test</code> targets that have <i>not</i> specified a <code>launcher</code> attribute.</p><br><br><p>Note that your native (C++, SWIG, JNI) dependencies will be built differently depending on whether you are using the JDK launcher or another launcher:</p><br><br><ul> <li>If you are using the normal JDK launcher (the default), native dependencies are built as a shared library named <code>{name}_nativedeps.so</code>, where <code>{name}</code> is the <code>name</code> attribute of this java_binary rule. Unused code is <em>not</em> removed by the linker in this configuration.</li><br><br><li>If you are using any other launcher, native (C++) dependencies are statically linked into a binary named <code>{name}_nativedeps</code>, where <code>{name}</code> is the <code>name</code> attribute of this java_binary rule. In this case, the linker will remove any code it thinks is unused from the resulting binary, which means any C++ code accessed only via JNI may not be linked in unless that <code>cc_library</code> target specifies <code>alwayslink = True</code>.</li> </ul><br><br><p>When using any launcher other than the default JDK launcher, the format of the <code>*_deploy.jar</code> output changes. See the main <a href="#java_binary">java_binary</a> docs for details.</p> | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 477| <a id="java_test-licenses"></a>licenses | - | List of strings | optional | `[]` | 478| <a id="java_test-main_class"></a>main_class | Name of class with <code>main()</code> method to use as entry point. If a rule uses this option, it does not need a <code>srcs=[...]</code> list. Thus, with this attribute one can make an executable from a Java library that already contains one or more <code>main()</code> methods. <p> The value of this attribute is a class name, not a source file. The class must be available at runtime: it may be compiled by this rule (from <code>srcs</code>) or provided by direct or transitive dependencies (through <code>runtime_deps</code> or <code>deps</code>). If the class is unavailable, the binary will fail at runtime; there is no build-time check. </p> | String | optional | `""` | 479| <a id="java_test-neverlink"></a>neverlink | - | Boolean | optional | `False` | 480| <a id="java_test-plugins"></a>plugins | Java compiler plugins to run at compile-time. Every <code>java_plugin</code> specified in this attribute will be run whenever this rule is built. A library may also inherit plugins from dependencies that use <code><a href="#java_library.exported_plugins">exported_plugins</a></code>. Resources generated by the plugin will be included in the resulting jar of this rule. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 481| <a id="java_test-resource_strip_prefix"></a>resource_strip_prefix | The path prefix to strip from Java resources. <p> If specified, this path prefix is stripped from every file in the <code>resources</code> attribute. It is an error for a resource file not to be under this directory. If not specified (the default), the path of resource file is determined according to the same logic as the Java package of source files. For example, a source file at <code>stuff/java/foo/bar/a.txt</code> will be located at <code>foo/bar/a.txt</code>. </p> | String | optional | `""` | 482| <a id="java_test-runtime_deps"></a>runtime_deps | Libraries to make available to the final binary or test at runtime only. Like ordinary <code>deps</code>, these will appear on the runtime classpath, but unlike them, not on the compile-time classpath. Dependencies needed only at runtime should be listed here. Dependency-analysis tools should ignore targets that appear in both <code>runtime_deps</code> and <code>deps</code>. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 483| <a id="java_test-stamp"></a>stamp | Whether to encode build information into the binary. Possible values: <ul> <li> <code>stamp = 1</code>: Always stamp the build information into the binary, even in <a href="https://bazel.build/docs/user-manual#stamp"><code>--nostamp</code></a> builds. <b>This setting should be avoided</b>, since it potentially kills remote caching for the binary and any downstream actions that depend on it. </li> <li> <code>stamp = 0</code>: Always replace build information by constant values. This gives good build result caching. </li> <li> <code>stamp = -1</code>: Embedding of build information is controlled by the <a href="https://bazel.build/docs/user-manual#stamp"><code>--[no]stamp</code></a> flag. </li> </ul> <p>Stamped binaries are <em>not</em> rebuilt unless their dependencies change.</p> | Integer | optional | `0` | 484| <a id="java_test-test_class"></a>test_class | The Java class to be loaded by the test runner.<br/> <p> By default, if this argument is not defined then the legacy mode is used and the test arguments are used instead. Set the <code>--nolegacy_bazel_java_test</code> flag to not fallback on the first argument. </p> <p> This attribute specifies the name of a Java class to be run by this test. It is rare to need to set this. If this argument is omitted, it will be inferred using the target's <code>name</code> and its source-root-relative path. If the test is located outside a known source root, Bazel will report an error if <code>test_class</code> is unset. </p> <p> For JUnit3, the test class needs to either be a subclass of <code>junit.framework.TestCase</code> or it needs to have a public static <code>suite()</code> method that returns a <code>junit.framework.Test</code> (or a subclass of <code>Test</code>). For JUnit4, the class needs to be annotated with <code>org.junit.runner.RunWith</code>. </p> <p> This attribute allows several <code>java_test</code> rules to share the same <code>Test</code> (<code>TestCase</code>, <code>TestSuite</code>, ...). Typically additional information is passed to it (e.g. via <code>jvm_flags=['-Dkey=value']</code>) so that its behavior differs in each case, such as running a different subset of the tests. This attribute also enables the use of Java tests outside the <code>javatests</code> tree. </p> | String | optional | `""` | 485| <a id="java_test-use_launcher"></a>use_launcher | Whether the binary should use a custom launcher.<br><br><p>If this attribute is set to false, the <a href="${link java_binary.launcher}">launcher</a> attribute and the related <a href="${link user-manual#flag--java_launcher}"><code>--java_launcher</code></a> flag will be ignored for this target. | Boolean | optional | `True` | 486| <a id="java_test-use_testrunner"></a>use_testrunner | Use the test runner (by default <code>com.google.testing.junit.runner.BazelTestRunner</code>) class as the main entry point for a Java program, and provide the test class to the test runner as a value of <code>bazel.test_suite</code> system property.<br><br><br/> You can use this to override the default behavior, which is to use test runner for <code>java_test</code> rules, and not use it for <code>java_binary</code> rules. It is unlikely you will want to do this. One use is for <code>AllTest</code> rules that are invoked by another rule (to set up a database before running the tests, for example). The <code>AllTest</code> rule must be declared as a <code>java_binary</code>, but should still use the test runner as its main entry point.<br><br>The name of a test runner class can be overridden with <code>main_class</code> attribute. | Boolean | optional | `True` | 487 488 489<a id="java_toolchain"></a> 490 491## java_toolchain 492 493<pre> 494java_toolchain(<a href="#java_toolchain-name">name</a>, <a href="#java_toolchain-android_lint_data">android_lint_data</a>, <a href="#java_toolchain-android_lint_jvm_opts">android_lint_jvm_opts</a>, <a href="#java_toolchain-android_lint_opts">android_lint_opts</a>, 495 <a href="#java_toolchain-android_lint_package_configuration">android_lint_package_configuration</a>, <a href="#java_toolchain-android_lint_runner">android_lint_runner</a>, <a href="#java_toolchain-bootclasspath">bootclasspath</a>, 496 <a href="#java_toolchain-compatible_javacopts">compatible_javacopts</a>, <a href="#java_toolchain-deps_checker">deps_checker</a>, <a href="#java_toolchain-forcibly_disable_header_compilation">forcibly_disable_header_compilation</a>, <a href="#java_toolchain-genclass">genclass</a>, 497 <a href="#java_toolchain-header_compiler">header_compiler</a>, <a href="#java_toolchain-header_compiler_builtin_processors">header_compiler_builtin_processors</a>, <a href="#java_toolchain-header_compiler_direct">header_compiler_direct</a>, <a href="#java_toolchain-ijar">ijar</a>, 498 <a href="#java_toolchain-jacocorunner">jacocorunner</a>, <a href="#java_toolchain-java_runtime">java_runtime</a>, <a href="#java_toolchain-javabuilder">javabuilder</a>, <a href="#java_toolchain-javabuilder_data">javabuilder_data</a>, <a href="#java_toolchain-javabuilder_jvm_opts">javabuilder_jvm_opts</a>, 499 <a href="#java_toolchain-javac_supports_multiplex_workers">javac_supports_multiplex_workers</a>, <a href="#java_toolchain-javac_supports_worker_cancellation">javac_supports_worker_cancellation</a>, 500 <a href="#java_toolchain-javac_supports_worker_multiplex_sandboxing">javac_supports_worker_multiplex_sandboxing</a>, <a href="#java_toolchain-javac_supports_workers">javac_supports_workers</a>, <a href="#java_toolchain-javacopts">javacopts</a>, 501 <a href="#java_toolchain-jspecify_implicit_deps">jspecify_implicit_deps</a>, <a href="#java_toolchain-jspecify_javacopts">jspecify_javacopts</a>, <a href="#java_toolchain-jspecify_packages">jspecify_packages</a>, <a href="#java_toolchain-jspecify_processor">jspecify_processor</a>, 502 <a href="#java_toolchain-jspecify_processor_class">jspecify_processor_class</a>, <a href="#java_toolchain-jspecify_stubs">jspecify_stubs</a>, <a href="#java_toolchain-jvm_opts">jvm_opts</a>, <a href="#java_toolchain-licenses">licenses</a>, <a href="#java_toolchain-misc">misc</a>, <a href="#java_toolchain-oneversion">oneversion</a>, 503 <a href="#java_toolchain-oneversion_allowlist">oneversion_allowlist</a>, <a href="#java_toolchain-oneversion_allowlist_for_tests">oneversion_allowlist_for_tests</a>, <a href="#java_toolchain-oneversion_whitelist">oneversion_whitelist</a>, 504 <a href="#java_toolchain-package_configuration">package_configuration</a>, <a href="#java_toolchain-proguard_allowlister">proguard_allowlister</a>, <a href="#java_toolchain-reduced_classpath_incompatible_processors">reduced_classpath_incompatible_processors</a>, 505 <a href="#java_toolchain-singlejar">singlejar</a>, <a href="#java_toolchain-source_version">source_version</a>, <a href="#java_toolchain-target_version">target_version</a>, <a href="#java_toolchain-timezone_data">timezone_data</a>, <a href="#java_toolchain-tools">tools</a>, <a href="#java_toolchain-turbine_data">turbine_data</a>, 506 <a href="#java_toolchain-turbine_jvm_opts">turbine_jvm_opts</a>, <a href="#java_toolchain-xlint">xlint</a>) 507</pre> 508 509<p> 510Specifies the configuration for the Java compiler. Which toolchain to be used can be changed through 511the --java_toolchain argument. Normally you should not write those kind of rules unless you want to 512tune your Java compiler. 513</p> 514 515<h4>Examples</h4> 516 517<p>A simple example would be: 518</p> 519 520<pre class="code"> 521<code class="lang-starlark"> 522 523java_toolchain( 524 name = "toolchain", 525 source_version = "7", 526 target_version = "7", 527 bootclasspath = ["//tools/jdk:bootclasspath"], 528 xlint = [ "classfile", "divzero", "empty", "options", "path" ], 529 javacopts = [ "-g" ], 530 javabuilder = ":JavaBuilder_deploy.jar", 531) 532</code> 533</pre> 534 535**ATTRIBUTES** 536 537 538| Name | Description | Type | Mandatory | Default | 539| :------------- | :------------- | :------------- | :------------- | :------------- | 540| <a id="java_toolchain-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | 541| <a id="java_toolchain-android_lint_data"></a>android_lint_data | Labels of tools available for label-expansion in android_lint_jvm_opts. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 542| <a id="java_toolchain-android_lint_jvm_opts"></a>android_lint_jvm_opts | The list of arguments for the JVM when invoking Android Lint. | List of strings | optional | `[]` | 543| <a id="java_toolchain-android_lint_opts"></a>android_lint_opts | The list of Android Lint arguments. | List of strings | optional | `[]` | 544| <a id="java_toolchain-android_lint_package_configuration"></a>android_lint_package_configuration | Android Lint Configuration that should be applied to the specified package groups. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 545| <a id="java_toolchain-android_lint_runner"></a>android_lint_runner | Label of the Android Lint runner, if any. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 546| <a id="java_toolchain-bootclasspath"></a>bootclasspath | The Java target bootclasspath entries. Corresponds to javac's -bootclasspath flag. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 547| <a id="java_toolchain-compatible_javacopts"></a>compatible_javacopts | Internal API, do not use! | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> List of strings</a> | optional | `{}` | 548| <a id="java_toolchain-deps_checker"></a>deps_checker | Label of the ImportDepsChecker deploy jar. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 549| <a id="java_toolchain-forcibly_disable_header_compilation"></a>forcibly_disable_header_compilation | Overrides --java_header_compilation to disable header compilation on platforms that do not support it, e.g. JDK 7 Bazel. | Boolean | optional | `False` | 550| <a id="java_toolchain-genclass"></a>genclass | Label of the GenClass deploy jar. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 551| <a id="java_toolchain-header_compiler"></a>header_compiler | Label of the header compiler. Required if --java_header_compilation is enabled. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 552| <a id="java_toolchain-header_compiler_builtin_processors"></a>header_compiler_builtin_processors | Internal API, do not use! | List of strings | optional | `[]` | 553| <a id="java_toolchain-header_compiler_direct"></a>header_compiler_direct | Optional label of the header compiler to use for direct classpath actions that do not include any API-generating annotation processors.<br><br><p>This tool does not support annotation processing. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 554| <a id="java_toolchain-ijar"></a>ijar | Label of the ijar executable. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 555| <a id="java_toolchain-jacocorunner"></a>jacocorunner | Label of the JacocoCoverageRunner deploy jar. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 556| <a id="java_toolchain-java_runtime"></a>java_runtime | The java_runtime to use with this toolchain. It defaults to java_runtime in execution configuration. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 557| <a id="java_toolchain-javabuilder"></a>javabuilder | Label of the JavaBuilder deploy jar. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 558| <a id="java_toolchain-javabuilder_data"></a>javabuilder_data | Labels of data available for label-expansion in javabuilder_jvm_opts. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 559| <a id="java_toolchain-javabuilder_jvm_opts"></a>javabuilder_jvm_opts | The list of arguments for the JVM when invoking JavaBuilder. | List of strings | optional | `[]` | 560| <a id="java_toolchain-javac_supports_multiplex_workers"></a>javac_supports_multiplex_workers | True if JavaBuilder supports running as a multiplex persistent worker, false if it doesn't. | Boolean | optional | `True` | 561| <a id="java_toolchain-javac_supports_worker_cancellation"></a>javac_supports_worker_cancellation | True if JavaBuilder supports cancellation of persistent workers, false if it doesn't. | Boolean | optional | `True` | 562| <a id="java_toolchain-javac_supports_worker_multiplex_sandboxing"></a>javac_supports_worker_multiplex_sandboxing | True if JavaBuilder supports running as a multiplex persistent worker with sandboxing, false if it doesn't. | Boolean | optional | `False` | 563| <a id="java_toolchain-javac_supports_workers"></a>javac_supports_workers | True if JavaBuilder supports running as a persistent worker, false if it doesn't. | Boolean | optional | `True` | 564| <a id="java_toolchain-javacopts"></a>javacopts | The list of extra arguments for the Java compiler. Please refer to the Java compiler documentation for the extensive list of possible Java compiler flags. | List of strings | optional | `[]` | 565| <a id="java_toolchain-jspecify_implicit_deps"></a>jspecify_implicit_deps | Experimental, do not use! | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 566| <a id="java_toolchain-jspecify_javacopts"></a>jspecify_javacopts | Experimental, do not use! | List of strings | optional | `[]` | 567| <a id="java_toolchain-jspecify_packages"></a>jspecify_packages | Experimental, do not use! | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 568| <a id="java_toolchain-jspecify_processor"></a>jspecify_processor | Experimental, do not use! | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 569| <a id="java_toolchain-jspecify_processor_class"></a>jspecify_processor_class | Experimental, do not use! | String | optional | `""` | 570| <a id="java_toolchain-jspecify_stubs"></a>jspecify_stubs | Experimental, do not use! | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 571| <a id="java_toolchain-jvm_opts"></a>jvm_opts | The list of arguments for the JVM when invoking the Java compiler. Please refer to the Java virtual machine documentation for the extensive list of possible flags for this option. | List of strings | optional | `[]` | 572| <a id="java_toolchain-licenses"></a>licenses | - | List of strings | optional | `[]` | 573| <a id="java_toolchain-misc"></a>misc | Deprecated: use javacopts instead | List of strings | optional | `[]` | 574| <a id="java_toolchain-oneversion"></a>oneversion | Label of the one-version enforcement binary. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 575| <a id="java_toolchain-oneversion_allowlist"></a>oneversion_allowlist | Label of the one-version allowlist. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 576| <a id="java_toolchain-oneversion_allowlist_for_tests"></a>oneversion_allowlist_for_tests | Label of the one-version allowlist for tests. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 577| <a id="java_toolchain-oneversion_whitelist"></a>oneversion_whitelist | Deprecated: use oneversion_allowlist instead | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 578| <a id="java_toolchain-package_configuration"></a>package_configuration | Configuration that should be applied to the specified package groups. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 579| <a id="java_toolchain-proguard_allowlister"></a>proguard_allowlister | Label of the Proguard allowlister. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `"@bazel_tools//tools/jdk:proguard_whitelister"` | 580| <a id="java_toolchain-reduced_classpath_incompatible_processors"></a>reduced_classpath_incompatible_processors | Internal API, do not use! | List of strings | optional | `[]` | 581| <a id="java_toolchain-singlejar"></a>singlejar | Label of the SingleJar deploy jar. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 582| <a id="java_toolchain-source_version"></a>source_version | The Java source version (e.g., '6' or '7'). It specifies which set of code structures are allowed in the Java source code. | String | optional | `""` | 583| <a id="java_toolchain-target_version"></a>target_version | The Java target version (e.g., '6' or '7'). It specifies for which Java runtime the class should be build. | String | optional | `""` | 584| <a id="java_toolchain-timezone_data"></a>timezone_data | Label of a resource jar containing timezone data. If set, the timezone data is added as an implicitly runtime dependency of all java_binary rules. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | 585| <a id="java_toolchain-tools"></a>tools | Labels of tools available for label-expansion in jvm_opts. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 586| <a id="java_toolchain-turbine_data"></a>turbine_data | Labels of data available for label-expansion in turbine_jvm_opts. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | 587| <a id="java_toolchain-turbine_jvm_opts"></a>turbine_jvm_opts | The list of arguments for the JVM when invoking turbine. | List of strings | optional | `[]` | 588| <a id="java_toolchain-xlint"></a>xlint | The list of warning to add or removes from default list. Precedes it with a dash to removes it. Please see the Javac documentation on the -Xlint options for more information. | List of strings | optional | `[]` | 589 590 591