IMPORTANT: The Bazel docs have moved! Please update your bookmark to https://bazel.build/rules/lib/JavaPluginInfo

You can read about the migration, and let us know what you think.

Extensions > API reference > JavaPluginInfo

JavaPluginInfo

A provider encapsulating information about Java plugins.

At the moment, the only supported kind of plugins are annotation processors.

JavaPluginInfo

JavaPluginInfo JavaPluginInfo(runtime_deps, *, processor_class, data=[], generates_api=False)

The JavaPluginInfo constructor.

Parameters

Parameter Description
runtime_deps sequence of JavaInfos; required
The library containing an annotation processor.
processor_class string; or None; required
The fully qualified class name that the Java compiler uses as an entry point to the annotation processor.
data sequence of Files; or depset of Files; default = []
The files needed by this annotation processor during execution.
generates_api default = False
Set to true when this annotation processor generates API code.

Such annotation processor is applied to a Java target before producing its header jars (which contains method signatures). When no API plugins are present, header jars are generated from the sources, reducing the critical path.

WARNING: This parameter affects build performance, use it only if necessary.

api_generating_plugins

JavaPluginData JavaPluginInfo.api_generating_plugins

Returns data about API generating plugins defined or exported by this target.

Those annotation processors are applied to a Java target before producing its header jars (which contain method signatures). When no API plugins are present, header jars are generated from the sources, reducing critical path.

The api_generating_plugins is a subset of plugins.

java_outputs

list JavaPluginInfo.java_outputs

Returns information about outputs of this Java/Java-like target.

plugins

JavaPluginData JavaPluginInfo.plugins

Returns data about all plugins that a consuming target should apply.

This is typically either a java_plugin itself or a java_library exporting one or more plugins.

A java_library runs annotation processing with all plugins from this field appearing in deps and plugins attributes.

to_json

string JavaPluginInfo.to_json()

Deprecated. This API is deprecated and will be removed soon. Please do not depend on it. It is disabled with ---incompatible_struct_has_no_methods. Use this flag to verify your code is compatible with its imminent removal.
Creates a JSON string from the struct parameter. This method only works if all struct elements (recursively) are strings, ints, booleans, other structs, a list of these types or a dictionary with string keys and values of these types. Quotes and new lines in strings are escaped. Examples:
struct(key=123).to_json()
# {"key":123}

struct(key=True).to_json()
# {"key":true}

struct(key=[1, 2, 3]).to_json()
# {"key":[1,2,3]}

struct(key='text').to_json()
# {"key":"text"}

struct(key=struct(inner_key='text')).to_json()
# {"key":{"inner_key":"text"}}

struct(key=[struct(inner_key=1), struct(inner_key=2)]).to_json()
# {"key":[{"inner_key":1},{"inner_key":2}]}

struct(key=struct(inner_key=struct(inner_inner_key='text'))).to_json()
# {"key":{"inner_key":{"inner_inner_key":"text"}}}
.

Deprecated: instead, use json.encode(x) or json.encode_indent(x), which work for values other than structs and do not pollute the struct field namespace.

to_proto

string JavaPluginInfo.to_proto()

Deprecated. This API is deprecated and will be removed soon. Please do not depend on it. It is disabled with ---incompatible_struct_has_no_methods. Use this flag to verify your code is compatible with its imminent removal.
Creates a text message from the struct parameter. This method only works if all struct elements (recursively) are strings, ints, booleans, other structs or dicts or lists of these types. Quotes and new lines in strings are escaped. Struct keys are iterated in the sorted order. Examples:
struct(key=123).to_proto()
# key: 123

struct(key=True).to_proto()
# key: true

struct(key=[1, 2, 3]).to_proto()
# key: 1
# key: 2
# key: 3

struct(key='text').to_proto()
# key: "text"

struct(key=struct(inner_key='text')).to_proto()
# key {
#   inner_key: "text"
# }

struct(key=[struct(inner_key=1), struct(inner_key=2)]).to_proto()
# key {
#   inner_key: 1
# }
# key {
#   inner_key: 2
# }

struct(key=struct(inner_key=struct(inner_inner_key='text'))).to_proto()
# key {
#    inner_key {
#     inner_inner_key: "text"
#   }
# }

struct(foo={4: 3, 2: 1}).to_proto()
# foo: {
#   key: 4
#   value: 3
# }
# foo: {
#   key: 2
#   value: 1
# }

Deprecated: use proto.encode_text(x) instead.