Skip to content

Commit

Permalink
Remove hardcoded javadocopts (#1212)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnybod authored Sep 7, 2024
1 parent b452dd5 commit 61817e0
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 66 deletions.
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Generate a javadoc from all the `deps`
| <a id="javadoc-doc_deps"></a>doc_deps | `javadoc` targets referenced by the current target.<br><br>Use this to automatically add appropriate `-linkoffline` javadoc options to resolve references to packages documented by the given javadoc targets that have `url` specified. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
| <a id="javadoc-doc_url"></a>doc_url | The URL at which this documentation will be hosted.<br><br>This information is only used by javadoc targets depending on this target. | String | optional | `""` |
| <a id="javadoc-excluded_workspaces"></a>excluded_workspaces | A list of bazel workspace names to exclude from the generated jar | List of strings | optional | `["com_google_protobuf", "protobuf"]` |
| <a id="javadoc-javadocopts"></a>javadocopts | javadoc options. Note sources and classpath are derived from the deps. Any additional options can be passed here. | List of strings | optional | `[]` |
| <a id="javadoc-javadocopts"></a>javadocopts | javadoc options. Note sources and classpath are derived from the deps. Any additional options can be passed here. If nothing is passed, a default list of options is used: ["-notimestamp", "-use", "-quiet", "-Xdoclint:-missing", "-encoding", "UTF8"] | List of strings | optional | `["-notimestamp", "-use", "-quiet", "-Xdoclint:-missing", "-encoding", "UTF8"]` |


<a id="java_export"></a>
Expand Down
1 change: 0 additions & 1 deletion private/rules/java_export.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ def maven_export(
manifest_entries = manifest_entries if manifest_entries else {}
deploy_env = deploy_env if deploy_env else []
excluded_workspaces = excluded_workspaces if excluded_workspaces else {}
javadocopts = javadocopts if javadocopts else []
doc_url = doc_url if doc_url else ""
doc_deps = doc_deps if doc_deps else []
tags = tags if tags else []
Expand Down
16 changes: 13 additions & 3 deletions private/rules/javadoc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ _JavadocInfo = provider(
},
)

_DEFAULT_JAVADOCOPTS = [
"-notimestamp",
"-use",
"-quiet",
"-Xdoclint:-missing",
"-encoding",
"UTF8",
]

def generate_javadoc(
ctx,
javadoc,
Expand Down Expand Up @@ -64,7 +73,6 @@ def _javadoc_impl(ctx):
# from dep[JavaInfo].compilation_info (which, FWIW, always returns
# `None` https://github.com/bazelbuild/bazel/issues/10170). For this
# reason we allow people to set javadocopts via the rule attrs.

generate_javadoc(
ctx,
ctx.executable._javadoc,
Expand Down Expand Up @@ -107,8 +115,10 @@ javadoc = rule(
"javadocopts": attr.string_list(
doc = """javadoc options.
Note sources and classpath are derived from the deps. Any additional
options can be passed here.
""",
options can be passed here. If nothing is passed, a default list of options is used:
%s
""" % _DEFAULT_JAVADOCOPTS,
default = _DEFAULT_JAVADOCOPTS,
),
"doc_deps": attr.label_list(
doc = """`javadoc` targets referenced by the current target.
Expand Down
2 changes: 1 addition & 1 deletion private/rules/kt_jvm_export.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def kt_jvm_export(
maven_coordinates_tags = ["maven_coordinates=%s" % maven_coordinates]
lib_name = "%s-lib" % name

javadocopts = kwargs.pop("javadocopts", [])
javadocopts = kwargs.pop("javadocopts", None)

# ensure that the kotlin-stdlib is included in deploy_env
if KOTLIN_STDLIB not in deploy_env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ public static void main(String[] args) throws IOException {
}
Version version = Runtime.version();

options.addAll(
Arrays.asList(
"-notimestamp", "-use", "-quiet", "-Xdoclint:-missing", "-encoding", "UTF8"));

// Generate frames if we can. Java prior to v9 generates frames automatically.
// In Java 13, the flag was removed.
if (version.compareTo(JAVA_9) > 0 && version.compareTo(JAVA_13) < 0) {
Expand Down
Loading

0 comments on commit 61817e0

Please sign in to comment.