docs/versions/6.4.0/reference/be/java.mdx
It is good practice to use the name of the source file that is the main entry point of the application (minus the extension). For example, if your entry point is called <code>Main.java</code>, then your name could be <code>Main</code>.
</td>
</tr>
<tr>
<td id="java_binary.deps">
<code>deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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>.
</td>
</tr>
<tr>
<td id="java_binary.srcs">
<code>srcs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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>
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>
</td>
</tr>
<tr>
<td id="java_binary.resources">
<code>resources</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
A list of data files to include in a Java jar.
<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.
</p>
<p>
Resources may be source files or generated files.
</p>
</td>
</tr>
<tr>
<td id="java_binary.classpath_resources">
<code>classpath_resources</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
<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>
</td>
</tr>
<tr>
<td id="java_binary.create_executable">
<code>create_executable</code>
</td>
<td>
<p><code>Boolean; optional; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a>; default is True</code></p>
Whether the binary is executable. Non-executable binaries collect transitive
runtime Java dependencies into a deploy jar, but cannot be executed directly.
No wrapper script is created if this attribute is set. It is an error to set
this to 0 if the <code>launcher</code> or <code>main_class</code> attributes
are set.
</td>
</tr>
<tr>
<td id="java_binary.deploy_env">
<code>deploy_env</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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>.
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>.
</td>
</tr>
<tr>
<td id="java_binary.deploy_manifest_lines">
<code>deploy_manifest_lines</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
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.
</td>
</tr>
<tr>
<td id="java_binary.javacopts">
<code>javacopts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
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>
</td>
</tr>
<tr>
<td id="java_binary.jvm_flags">
<code>jvm_flags</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
A list of flags to embed in the wrapper script generated for running this binary.
Subject to <a href="/versions/6.4.0/reference/be/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>.
<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>
<p>Note that this attribute has <em>no effect</em> on <code>*_deploy.jar</code>
outputs.</p>
</td>
</tr>
<tr>
<td id="java_binary.launcher">
<code>launcher</code>
</td>
<td>
<p><code><a href="/versions/6.4.0/concepts/labels">Label</a>; optional</code></p>
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.
<p>By default, Bazel will use the normal JDK launcher (bin/java or java.exe).</p>
<p>The related <a href="/versions/6.4.0/docs/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>
<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>
<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>
<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 = 1</code>.</li>
</ul>
<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>
</td>
</tr>
<tr>
<td id="java_binary.main_class">
<code>main_class</code>
</td>
<td>
<p><code>String; optional</code></p>
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>
</td>
</tr>
<tr>
<td id="java_binary.plugins">
<code>plugins</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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.
</td>
</tr>
<tr>
<td id="java_binary.resource_jars">
<code>resource_jars</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Deprecated: Use java_import and deps or runtime_deps instead.
</td>
</tr>
<tr>
<td id="java_binary.resource_strip_prefix">
<code>resource_strip_prefix</code>
</td>
<td>
<p><code>String; optional</code></p>
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>
</td>
</tr>
<tr>
<td id="java_binary.runtime_deps">
<code>runtime_deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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>.
</td>
</tr>
<tr>
<td id="java_binary.stamp">
<code>stamp</code>
</td>
<td>
<p><code>Integer; optional; default is -1</code></p>
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="/versions/6.4.0/docs/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="/versions/6.4.0/docs/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>
</td>
</tr>
<tr>
<td id="java_binary.use_launcher">
<code>use_launcher</code>
</td>
<td>
<p><code>Boolean; optional; default is True</code></p>
Whether the binary should use a custom launcher.
<p>If this attribute is set to false, the
<a href="/versions/6.4.0/reference/be/java.html#java_binary.launcher">launcher</a> attribute and the related
<a href="/versions/6.4.0/docs/user-manual#flag--java_launcher"><code>--java_launcher</code></a> flag
will be ignored for this target.
</td>
</tr>
<tr>
<td id="java_binary.use_testrunner">
<code>use_testrunner</code>
</td>
<td>
<p><code>Boolean; optional; default is False</code></p>
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.
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.
The name of a test runner class can be overridden with <code>main_class</code> attribute.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="java_import.deps">
<code>deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
The list of other libraries to be linked in to the target.
See <a href="/versions/6.4.0/reference/be/java.html#java_library.deps">java_library.deps</a>.
</td>
</tr>
<tr>
<td id="java_import.constraints">
<code>constraints</code>
</td>
<td>
<p><code>List of strings; optional; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a></code></p>
Extra constraints imposed on this rule as a Java library.
</td>
</tr>
<tr>
<td id="java_import.exports">
<code>exports</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Targets to make available to users of this rule.
See <a href="/versions/6.4.0/reference/be/java.html#java_library.exports">java_library.exports</a>.
</td>
</tr>
<tr>
<td id="java_import.jars">
<code>jars</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; required</code></p>
The list of JAR files provided to Java targets that depend on this target.
</td>
</tr>
<tr>
<td id="java_import.neverlink">
<code>neverlink</code>
</td>
<td>
<p><code>Boolean; optional; default is False</code></p>
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.
</td>
</tr>
<tr>
<td id="java_import.proguard_specs">
<code>proguard_specs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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.
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.
</td>
</tr>
<tr>
<td id="java_import.runtime_deps">
<code>runtime_deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Libraries to make available to the final binary or test at runtime only.
See <a href="/versions/6.4.0/reference/be/java.html#java_library.runtime_deps">java_library.runtime_deps</a>.
</td>
</tr>
<tr>
<td id="java_import.srcjar">
<code>srcjar</code>
</td>
<td>
<p><code><a href="/versions/6.4.0/concepts/labels">Label</a>; optional</code></p>
A JAR file that contains source code for the compiled JAR files.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="java_library.deps">
<code>deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
The list of libraries to link into this library.
See general comments about <code>deps</code> at
<a href="/versions/6.4.0/reference/be/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>
</td>
</tr>
<tr>
<td id="java_library.srcs">
<code>srcs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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>
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>
</td>
</tr>
<tr>
<td id="java_library.data">
<code>data</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
The list of files needed by this library at runtime.
See general comments about <code>data</code> at
<a href="/versions/6.4.0/reference/be/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>
</td>
</tr>
<tr>
<td id="java_library.resources">
<code>resources</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
A list of data files to include in a Java jar.
<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.
</p>
<p>
Resources may be source files or generated files.
</p>
</td>
</tr>
<tr>
<td id="java_library.exported_plugins">
<code>exported_plugins</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
The list of <code><a href="#/reference/be/java.html#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="/versions/6.4.0/reference/be/java.html#java_library.plugins">plugins</a></code>.
</p>
</td>
</tr>
<tr>
<td id="java_library.exports">
<code>exports</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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>
</td>
</tr>
<tr>
<td id="java_library.javacopts">
<code>javacopts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
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>
</td>
</tr>
<tr>
<td id="java_library.neverlink">
<code>neverlink</code>
</td>
<td>
<p><code>Boolean; optional; default is False</code></p>
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 = 1</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>
</td>
</tr>
<tr>
<td id="java_library.plugins">
<code>plugins</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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.
</td>
</tr>
<tr>
<td id="java_library.proguard_specs">
<code>proguard_specs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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.
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.
</td>
</tr>
<tr>
<td id="java_library.resource_jars">
<code>resource_jars</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Deprecated: Use java_import and deps or runtime_deps instead.
</td>
</tr>
<tr>
<td id="java_library.resource_strip_prefix">
<code>resource_strip_prefix</code>
</td>
<td>
<p><code>String; optional</code></p>
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>
</td>
</tr>
<tr>
<td id="java_library.runtime_deps">
<code>runtime_deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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>.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="java_lite_proto_library.deps">
<code>deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
The list of <a href="protocol-buffer.html#proto_library"><code>proto_library</code></a>
rules to generate Java code for.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="java_proto_library.deps">
<code>deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
The list of <a href="protocol-buffer.html#proto_library"><code>proto_library</code></a>
rules to generate Java code for.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="java_test.deps">
<code>deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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>.
</td>
</tr>
<tr>
<td id="java_test.srcs">
<code>srcs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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>
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>
</td>
</tr>
<tr>
<td id="java_test.resources">
<code>resources</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
A list of data files to include in a Java jar.
<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.
</p>
<p>
Resources may be source files or generated files.
</p>
</td>
</tr>
<tr>
<td id="java_test.classpath_resources">
<code>classpath_resources</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
<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>
</td>
</tr>
<tr>
<td id="java_test.create_executable">
<code>create_executable</code>
</td>
<td>
<p><code>Boolean; optional; <a href="common-definitions.html#configurable-attributes">nonconfigurable</a>; default is True</code></p>
Whether the binary is executable. Non-executable binaries collect transitive
runtime Java dependencies into a deploy jar, but cannot be executed directly.
No wrapper script is created if this attribute is set. It is an error to set
this to 0 if the <code>launcher</code> or <code>main_class</code> attributes
are set.
</td>
</tr>
<tr>
<td id="java_test.deploy_manifest_lines">
<code>deploy_manifest_lines</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
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.
</td>
</tr>
<tr>
<td id="java_test.javacopts">
<code>javacopts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
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>
</td>
</tr>
<tr>
<td id="java_test.jvm_flags">
<code>jvm_flags</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
A list of flags to embed in the wrapper script generated for running this binary.
Subject to <a href="/versions/6.4.0/reference/be/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>.
<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>
<p>Note that this attribute has <em>no effect</em> on <code>*_deploy.jar</code>
outputs.</p>
</td>
</tr>
<tr>
<td id="java_test.launcher">
<code>launcher</code>
</td>
<td>
<p><code><a href="/versions/6.4.0/concepts/labels">Label</a>; optional</code></p>
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.
<p>By default, Bazel will use the normal JDK launcher (bin/java or java.exe).</p>
<p>The related <a href="/versions/6.4.0/docs/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>
<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>
<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>
<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 = 1</code>.</li>
</ul>
<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>
</td>
</tr>
<tr>
<td id="java_test.main_class">
<code>main_class</code>
</td>
<td>
<p><code>String; optional</code></p>
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>
</td>
</tr>
<tr>
<td id="java_test.plugins">
<code>plugins</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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.
</td>
</tr>
<tr>
<td id="java_test.resource_jars">
<code>resource_jars</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Deprecated: Use java_import and deps or runtime_deps instead.
</td>
</tr>
<tr>
<td id="java_test.resource_strip_prefix">
<code>resource_strip_prefix</code>
</td>
<td>
<p><code>String; optional</code></p>
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>
</td>
</tr>
<tr>
<td id="java_test.runtime_deps">
<code>runtime_deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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>.
</td>
</tr>
<tr>
<td id="java_test.stamp">
<code>stamp</code>
</td>
<td>
<p><code>Integer; optional; default is 0</code></p>
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="/versions/6.4.0/docs/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="/versions/6.4.0/docs/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>
</td>
</tr>
<tr>
<td id="java_test.test_class">
<code>test_class</code>
</td>
<td>
<p><code>String; optional</code></p>
The Java class to be loaded by the test runner.
<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>
</td>
</tr>
<tr>
<td id="java_test.use_launcher">
<code>use_launcher</code>
</td>
<td>
<p><code>Boolean; optional; default is True</code></p>
Whether the binary should use a custom launcher.
<p>If this attribute is set to false, the
<a href="/versions/6.4.0/reference/be/java.html#java_binary.launcher">launcher</a> attribute and the related
<a href="/versions/6.4.0/docs/user-manual#flag--java_launcher"><code>--java_launcher</code></a> flag
will be ignored for this target.
</td>
</tr>
<tr>
<td id="java_test.use_testrunner">
<code>use_testrunner</code>
</td>
<td>
<p><code>Boolean; optional; default is True</code></p>
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.
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.
The name of a test runner class can be overridden with <code>main_class</code> attribute.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="java_package_configuration.data">
<code>data</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
The list of files needed by this configuration at runtime.
</td>
</tr>
<tr>
<td id="java_package_configuration.javacopts">
<code>javacopts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
Java compiler flags.
</td>
</tr>
<tr>
<td id="java_package_configuration.packages">
<code>packages</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
The set of <code><a href="/versions/6.4.0/reference/be/functions.html#package_group">package_group</a></code>s
the configuration should be applied to.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="java_plugin.deps">
<code>deps</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
The list of libraries to link into this library.
See general comments about <code>deps</code> at
<a href="/versions/6.4.0/reference/be/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>
</td>
</tr>
<tr>
<td id="java_plugin.srcs">
<code>srcs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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>
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>
</td>
</tr>
<tr>
<td id="java_plugin.data">
<code>data</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
The list of files needed by this library at runtime.
See general comments about <code>data</code> at
<a href="/versions/6.4.0/reference/be/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>
</td>
</tr>
<tr>
<td id="java_plugin.resources">
<code>resources</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
A list of data files to include in a Java jar.
<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.
</p>
<p>
Resources may be source files or generated files.
</p>
</td>
</tr>
<tr>
<td id="java_plugin.generates_api">
<code>generates_api</code>
</td>
<td>
<p><code>Boolean; optional; default is False</code></p>
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>
</td>
</tr>
<tr>
<td id="java_plugin.javacopts">
<code>javacopts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
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>
</td>
</tr>
<tr>
<td id="java_plugin.neverlink">
<code>neverlink</code>
</td>
<td>
<p><code>Boolean; optional; default is False</code></p>
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 = 1</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>
</td>
</tr>
<tr>
<td id="java_plugin.output_licenses">
<code>output_licenses</code>
</td>
<td>
<p><code>Licence type; optional</code></p>
See <a href="/versions/6.4.0/reference/be/common-definitions#binary.output_licenses"><code>common attributes
</code></a>
</td>
</tr>
<tr>
<td id="java_plugin.plugins">
<code>plugins</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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.
</td>
</tr>
<tr>
<td id="java_plugin.processor_class">
<code>processor_class</code>
</td>
<td>
<p><code>String; optional</code></p>
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>.)
</td>
</tr>
<tr>
<td id="java_plugin.proguard_specs">
<code>proguard_specs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
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.
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.
</td>
</tr>
<tr>
<td id="java_plugin.resource_jars">
<code>resource_jars</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Deprecated: Use java_import and deps or runtime_deps instead.
</td>
</tr>
<tr>
<td id="java_plugin.resource_strip_prefix">
<code>resource_strip_prefix</code>
</td>
<td>
<p><code>String; optional</code></p>
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>
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="java_runtime.srcs">
<code>srcs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
All files in the runtime.
</td>
</tr>
<tr>
<td id="java_runtime.hermetic_srcs">
<code>hermetic_srcs</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Files in the runtime needed for hermetic deployments.
</td>
</tr>
<tr>
<td id="java_runtime.java">
<code>java</code>
</td>
<td>
<p><code><a href="/versions/6.4.0/concepts/labels">Label</a>; optional</code></p>
The path to the java executable.
</td>
</tr>
<tr>
<td id="java_runtime.java_home">
<code>java_home</code>
</td>
<td>
<p><code>String; optional</code></p>
The path to the root of the runtime.
Subject to <a href="/versions/6.4.0/reference/be/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.
</td>
</tr>
<tr>
<td id="java_runtime.lib_modules">
<code>lib_modules</code>
</td>
<td>
<p><code><a href="/versions/6.4.0/concepts/labels">Label</a>; optional</code></p>
The lib/modules file needed for hermetic deployments.
</td>
</tr>
<tr>
<td id="java_runtime.version">
<code>version</code>
</td>
<td>
<p><code>Integer; optional; default is 0</code></p>
The feature version of the Java runtime. I.e., the integer returned by
<code>Runtime.version().feature()</code>.
</td>
</tr>
</tbody>
</td>
</tr>
<tr>
<td id="java_toolchain.android_lint_data">
<code>android_lint_data</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Labels of tools available for label-expansion in android_lint_jvm_opts.
</td>
</tr>
<tr>
<td id="java_toolchain.android_lint_jvm_opts">
<code>android_lint_jvm_opts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
The list of arguments for the JVM when invoking Android Lint.
</td>
</tr>
<tr>
<td id="java_toolchain.android_lint_opts">
<code>android_lint_opts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
The list of Android Lint arguments.
</td>
</tr>
<tr>
<td id="java_toolchain.android_lint_package_configuration">
<code>android_lint_package_configuration</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Android Lint Configuration that should be applied to the specified package groups.
</td>
</tr>
<tr>
<td id="java_toolchain.android_lint_runner">
<code>android_lint_runner</code>
</td>
<td>
<p><code><a href="/versions/6.4.0/concepts/labels">Label</a>; optional</code></p>
Label of the Android Lint runner, if any.
</td>
</tr>
<tr>
<td id="java_toolchain.bootclasspath">
<code>bootclasspath</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
The Java target bootclasspath entries. Corresponds to javac's -bootclasspath flag.
</td>
</tr>
<tr>
<td id="java_toolchain.deps_checker">
<code>deps_checker</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Label of the ImportDepsChecker deploy jar.
</td>
</tr>
<tr>
<td id="java_toolchain.forcibly_disable_header_compilation">
<code>forcibly_disable_header_compilation</code>
</td>
<td>
<p><code>Boolean; optional; default is False</code></p>
Overrides --java_header_compilation to disable header compilation on platforms that do not
support it, e.g. JDK 7 Bazel.
</td>
</tr>
<tr>
<td id="java_toolchain.genclass">
<code>genclass</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; required</code></p>
Label of the GenClass deploy jar.
</td>
</tr>
<tr>
<td id="java_toolchain.header_compiler">
<code>header_compiler</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Label of the header compiler. Required if --java_header_compilation is enabled.
</td>
</tr>
<tr>
<td id="java_toolchain.header_compiler_direct">
<code>header_compiler_direct</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Optional label of the header compiler to use for direct classpath actions that do not
include any API-generating annotation processors.
<p>This tool does not support annotation processing.
</td>
</tr>
<tr>
<td id="java_toolchain.ijar">
<code>ijar</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; required</code></p>
Label of the ijar executable.
</td>
</tr>
<tr>
<td id="java_toolchain.jacocorunner">
<code>jacocorunner</code>
</td>
<td>
<p><code><a href="/versions/6.4.0/concepts/labels">Label</a>; optional</code></p>
Label of the JacocoCoverageRunner deploy jar.
</td>
</tr>
<tr>
<td id="java_toolchain.java_runtime">
<code>java_runtime</code>
</td>
<td>
<p><code><a href="/versions/6.4.0/concepts/labels">Label</a>; required</code></p>
The java_runtime to use with this toolchain. It defaults to java_runtime
in execution configuration.
</td>
</tr>
<tr>
<td id="java_toolchain.javabuilder">
<code>javabuilder</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; required</code></p>
Label of the JavaBuilder deploy jar.
</td>
</tr>
<tr>
<td id="java_toolchain.javabuilder_data">
<code>javabuilder_data</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Labels of data available for label-expansion in javabuilder_jvm_opts.
</td>
</tr>
<tr>
<td id="java_toolchain.javabuilder_jvm_opts">
<code>javabuilder_jvm_opts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
The list of arguments for the JVM when invoking JavaBuilder.
</td>
</tr>
<tr>
<td id="java_toolchain.javac_supports_multiplex_workers">
<code>javac_supports_multiplex_workers</code>
</td>
<td>
<p><code>Boolean; optional; default is True</code></p>
True if JavaBuilder supports running as a multiplex persistent worker, false if it doesn't.
</td>
</tr>
<tr>
<td id="java_toolchain.javac_supports_workers">
<code>javac_supports_workers</code>
</td>
<td>
<p><code>Boolean; optional; default is True</code></p>
True if JavaBuilder supports running as a persistent worker, false if it doesn't.
</td>
</tr>
<tr>
<td id="java_toolchain.javacopts">
<code>javacopts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
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.
</td>
</tr>
<tr>
<td id="java_toolchain.jvm_opts">
<code>jvm_opts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
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.
</td>
</tr>
<tr>
<td id="java_toolchain.oneversion">
<code>oneversion</code>
</td>
<td>
<p><code><a href="/versions/6.4.0/concepts/labels">Label</a>; optional</code></p>
Label of the one-version enforcement binary.
</td>
</tr>
<tr>
<td id="java_toolchain.oneversion_whitelist">
<code>oneversion_whitelist</code>
</td>
<td>
<p><code><a href="/versions/6.4.0/concepts/labels">Label</a>; optional</code></p>
Label of the one-version whitelist.
</td>
</tr>
<tr>
<td id="java_toolchain.package_configuration">
<code>package_configuration</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Configuration that should be applied to the specified package groups.
</td>
</tr>
<tr>
<td id="java_toolchain.proguard_allowlister">
<code>proguard_allowlister</code>
</td>
<td>
<p><code><a href="/versions/6.4.0/concepts/labels">Label</a>; optional; default is <code>@bazel_tools//tools/jdk:proguard_whitelister</code></code></p>
Label of the Proguard allowlister.
</td>
</tr>
<tr>
<td id="java_toolchain.resourcejar">
<code>resourcejar</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Label of the resource jar builder executable.
</td>
</tr>
<tr>
<td id="java_toolchain.singlejar">
<code>singlejar</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; required</code></p>
Label of the SingleJar deploy jar.
</td>
</tr>
<tr>
<td id="java_toolchain.source_version">
<code>source_version</code>
</td>
<td>
<p><code>String; optional</code></p>
The Java source version (e.g., '6' or '7'). It specifies which set of code structures
are allowed in the Java source code.
</td>
</tr>
<tr>
<td id="java_toolchain.target_version">
<code>target_version</code>
</td>
<td>
<p><code>String; optional</code></p>
The Java target version (e.g., '6' or '7'). It specifies for which Java runtime the class
should be build.
</td>
</tr>
<tr>
<td id="java_toolchain.timezone_data">
<code>timezone_data</code>
</td>
<td>
<p><code><a href="/versions/6.4.0/concepts/labels">Label</a>; optional</code></p>
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.
</td>
</tr>
<tr>
<td id="java_toolchain.tools">
<code>tools</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Labels of tools available for label-expansion in jvm_opts.
</td>
</tr>
<tr>
<td id="java_toolchain.turbine_data">
<code>turbine_data</code>
</td>
<td>
<p><code>List of <a href="/versions/6.4.0/concepts/labels">labels</a>; optional</code></p>
Labels of data available for label-expansion in turbine_jvm_opts.
</td>
</tr>
<tr>
<td id="java_toolchain.turbine_jvm_opts">
<code>turbine_jvm_opts</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
The list of arguments for the JVM when invoking turbine.
</td>
</tr>
<tr>
<td id="java_toolchain.xlint">
<code>xlint</code>
</td>
<td>
<p><code>List of strings; optional</code></p>
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.
</td>
</tr>
</tbody>