google / bazel-common

Common functionality for Google's open-source libraries that are built with bazel.
Apache License 2.0
84 stars 40 forks source link

javadoc_library doesn't grok tree artifacts #161

Open ghost opened 2 years ago

ghost commented 2 years ago

I am trying to use generate Javadoc from auto-generated Java sources (e.g. Java bindings generated from WSDL). My Java source generator produces a tree artifact. However, I cannot provide tree artifacts to javadoc_library, because javadoc_library simply passes srcs directly to the javadoc command-line. As a result, the action fails with the following:

javadoc: error - Illegal package name: "bazel-out/k8-dbg-obj/bin/path/to/my/treeartifact
netdpb commented 2 years ago

What do you mean by a "tree artifact"?

ghost commented 2 years ago

What do you mean by a "tree artifact"?

https://bazel.build/reference/glossary#artifact sums it up better than I could. :)

A source file or a generated file. Can also be a directory of files, known as "tree artifacts". Tree artifacts are black boxes to Bazel: Bazel does not treat the files in tree artifacts as individual artifacts and thus cannot reference them directly as action inputs / outputs. An artifact can be an input to multiple actions, but must only be generated by at most one action.

I.e. when an action produces a directory (as declared by ctx.actions.declare_directory), that output directory is a tree artifact.

netdpb commented 2 years ago

Aha. So since passing a directory to Args.add_all() actually adds each file recursively found in that directory, we just switch to using Args?