Skip to content

Commit 46b472d

Browse files
hvadehrarules_java Copybara
authored andcommitted
Minor documentation fixes
PiperOrigin-RevId: 678562013 Change-Id: I4a52cc458f4b72478c0286a7300cb1214d410d0d
1 parent b6cf2eb commit 46b472d

File tree

8 files changed

+22
-25
lines changed

8 files changed

+22
-25
lines changed

java/bazel/rules/bazel_java_binary.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def make_java_binary(executable):
381381
creates a self-contained jar file with a manifest that allows it to be run with the
382382
<code>java -jar</code> command or with the wrapper script's <code>--singlejar</code>
383383
option. Using the wrapper script is preferred to <code>java -jar</code> because it
384-
also passes the <a href="${link java_binary.jvm_flags}">JVM flags</a> and the options
384+
also passes the <a href="#java_binary-jvm_flags">JVM flags</a> and the options
385385
to load native libraries.
386386
</p>
387387
<p>
@@ -411,9 +411,9 @@ application (minus the extension). For example, if your entry point is called
411411
412412
<p>
413413
A <code>deps</code> attribute is not allowed in a <code>java_binary</code> rule without
414-
<a href="${link java_binary.srcs}"><code>srcs</code></a>; such a rule requires a
415-
<a href="${link java_binary.main_class}"><code>main_class</code></a> provided by
416-
<a href="${link java_binary.runtime_deps}"><code>runtime_deps</code></a>.
414+
<a href="#java_binary-srcs"><code>srcs</code></a>; such a rule requires a
415+
<a href="#java_binary-main_class"><code>main_class</code></a> provided by
416+
<a href="#java_binary-runtime_deps"><code>runtime_deps</code></a>.
417417
</p>
418418
419419
<p>The following code snippet illustrates a common mistake:</p>

java/bazel/rules/bazel_java_binary_nonexec.bzl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@
1414

1515
"""Defines a java_binary rule class that is non-executable.
1616
17-
There are three physical rule classes for java_binary and we want all of them
17+
There are two physical rule classes for java_binary and we want both of them
1818
to have a name string of "java_binary" because various tooling expects that.
19-
But we also need the rule classes to be defined in separate files. That way the
20-
hash of their bzl environments will be different. See http://b/226379109,
21-
specifically #20, for details.
2219
"""
2320

2421
load(":bazel_java_binary.bzl", "make_java_binary")

java/bazel/rules/bazel_java_import.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ java_import = rule(
4242
doc = """
4343
<p>
4444
This rule allows the use of precompiled <code>.jar</code> files as
45-
libraries for <code><a href="${link java_library}">java_library</a></code> and
45+
libraries for <code><a href="#java_library">java_library</a></code> and
4646
<code>java_binary</code> rules.
4747
</p>
4848

java/bazel/rules/bazel_java_plugin.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ java_plugin = rule(
128128
<code>java_binary</code> rule can run plugins by depending on them via the <code>plugins</code>
129129
attribute. A <code>java_library</code> can also automatically export plugins to libraries that
130130
directly depend on it using
131-
<code><a href="${link java_library.exported_plugins}">exported_plugins</a></code>.
131+
<code><a href="#java_library-exported_plugins">exported_plugins</a></code>.
132132
</p>
133133
134134
<h4 id="java_plugin_implicit_outputs">Implicit output targets</h4>
@@ -137,7 +137,7 @@ java_plugin = rule(
137137
</ul>
138138
139139
<p>
140-
Arguments are identical to <a href="${link java_library}"><code>java_library</code></a>, except
140+
Arguments are identical to <a href="#java_library"><code>java_library</code></a>, except
141141
for the addition of the <code>processor_class</code> argument.
142142
</p>
143143
""",

java/bazel/rules/bazel_java_test.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test code. The test runner's main method is invoked instead of the main class be
5454
5555
<p>
5656
See the section on <code>java_binary()</code> arguments. This rule also
57-
supports all <a href="${link common-definitions#common-attributes-tests}">attributes common
57+
supports all <a href="https://bazel.build/reference/be/common-definitions#common-attributes-tests">attributes common
5858
to all test rules (*_test)</a>.
5959
</p>
6060
@@ -126,7 +126,7 @@ Whether to encode build information into the binary. Possible values:
126126
<ul>
127127
<li>
128128
<code>stamp = 1</code>: Always stamp the build information into the binary, even in
129-
<a href="${link user-manual#flag--stamp}"><code>--nostamp</code></a> builds. <b>This
129+
<a href="https://bazel.build/docs/user-manual#stamp"><code>--nostamp</code></a> builds. <b>This
130130
setting should be avoided</b>, since it potentially kills remote caching for the
131131
binary and any downstream actions that depend on it.
132132
</li>
@@ -136,7 +136,7 @@ Whether to encode build information into the binary. Possible values:
136136
</li>
137137
<li>
138138
<code>stamp = -1</code>: Embedding of build information is controlled by the
139-
<a href="${link user-manual#flag--stamp}"><code>--[no]stamp</code></a> flag.
139+
<a href="https://bazel.build/docs/user-manual#stamp"><code>--[no]stamp</code></a> flag.
140140
</li>
141141
</ul>
142142
<p>Stamped binaries are <em>not</em> rebuilt unless their dependencies change.</p>

java/docs/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bzl_library(
1616
)
1717

1818
stardoc(
19-
name = "rule_docs",
19+
name = "rules_docs",
2020
out = "rules_docs.out",
2121
input = "rules.bzl",
2222
rule_template = ":rule.vm",

java/docs/rules.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ java_binary(<a href="#java_binary-name">name</a>, <a href="#java_binary-deps">de
5252
creates a self-contained jar file with a manifest that allows it to be run with the
5353
<code>java -jar</code> command or with the wrapper script's <code>--singlejar</code>
5454
option. Using the wrapper script is preferred to <code>java -jar</code> because it
55-
also passes the <a href="${link java_binary.jvm_flags}">JVM flags</a> and the options
55+
also passes the <a href="#java_binary-jvm_flags">JVM flags</a> and the options
5656
to load native libraries.
5757
</p>
5858
<p>
@@ -82,9 +82,9 @@ application (minus the extension). For example, if your entry point is called
8282

8383
<p>
8484
A <code>deps</code> attribute is not allowed in a <code>java_binary</code> rule without
85-
<a href="${link java_binary.srcs}"><code>srcs</code></a>; such a rule requires a
86-
<a href="${link java_binary.main_class}"><code>main_class</code></a> provided by
87-
<a href="${link java_binary.runtime_deps}"><code>runtime_deps</code></a>.
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>.
8888
</p>
8989

9090
<p>The following code snippet illustrates a common mistake:</p>
@@ -159,7 +159,7 @@ java_import(<a href="#java_import-name">name</a>, <a href="#java_import-deps">de
159159

160160
<p>
161161
This rule allows the use of precompiled <code>.jar</code> files as
162-
libraries for <code><a href="${link java_library}">java_library</a></code> and
162+
libraries for <code><a href="#java_library">java_library</a></code> and
163163
<code>java_binary</code> rules.
164164
</p>
165165

@@ -313,7 +313,7 @@ java_plugin(<a href="#java_plugin-name">name</a>, <a href="#java_plugin-deps">de
313313
<code>java_binary</code> rule can run plugins by depending on them via the <code>plugins</code>
314314
attribute. A <code>java_library</code> can also automatically export plugins to libraries that
315315
directly depend on it using
316-
<code><a href="${link java_library.exported_plugins}">exported_plugins</a></code>.
316+
<code><a href="#java_library-exported_plugins">exported_plugins</a></code>.
317317
</p>
318318

319319
<h4 id="java_plugin_implicit_outputs">Implicit output targets</h4>
@@ -322,7 +322,7 @@ java_plugin(<a href="#java_plugin-name">name</a>, <a href="#java_plugin-deps">de
322322
</ul>
323323

324324
<p>
325-
Arguments are identical to <a href="${link java_library}"><code>java_library</code></a>, except
325+
Arguments are identical to <a href="#java_library"><code>java_library</code></a>, except
326326
for the addition of the <code>processor_class</code> argument.
327327
</p>
328328

@@ -423,7 +423,7 @@ test code. The test runner's main method is invoked instead of the main class be
423423

424424
<p>
425425
See the section on <code>java_binary()</code> arguments. This rule also
426-
supports all <a href="${link common-definitions#common-attributes-tests}">attributes common
426+
supports all <a href="https://bazel.build/reference/be/common-definitions#common-attributes-tests">attributes common
427427
to all test rules (*_test)</a>.
428428
</p>
429429

@@ -479,7 +479,7 @@ java_test(
479479
| <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 | `[]` |
480480
| <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 | `""` |
481481
| <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 | `[]` |
482-
| <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="${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 | `0` |
482+
| <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` |
483483
| <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 | `""` |
484484
| <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` |
485485
| <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` |

test/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ diff_test(
5555
cp bazel-bin/java/docs/rules_docs.out java/docs/rules.md
5656
""",
5757
file1 = "//java/docs:rules.md",
58-
file2 = "//java/docs:rule_docs",
58+
file2 = "//java/docs:rules_docs",
5959
)
6060

6161
validate_configs()

0 commit comments

Comments
 (0)