Extensions > API reference > JavaInfo

JavaInfo

A provider encapsulating information about Java and Java-like targets.

annotation_processing

java_annotation_processing JavaInfo.annotation_processing

Returns information about annotation processing for this Java/Java-like target. May return None.

compilation_info

java_compilation_info JavaInfo.compilation_info

Returns compilation information for this Java/Java-like target. May return None.

compile_jars

depset JavaInfo.compile_jars

Returns the Jars required by this target directly at compile time. They can be interface jars (ijar or hjar), regular jars or both, depending on whether rule implementations chose to create interface jars or not.

full_compile_jars

depset JavaInfo.full_compile_jars

Returns the regular, full compile time Jars required by this target directly. They can be

Note: JavaInfo.compile_jars can return a mix of interface Jars and regular Jars.

Only use this method if interface Jars don't work with your rule set(s) (e.g. some Scala targets) If you're working with Java-only targets it's preferable to use interface Jars via JavaInfo.compile_jars

outputs

java_output_jars JavaInfo.outputs

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

runtime_output_jars

sequence JavaInfo.runtime_output_jars

Returns a list of runtime Jars created by this Java/Java-like target.

source_jars

sequence JavaInfo.source_jars

Returns a list of Jars with all the source files (including those generated by annotations) of the target itself, i.e. NOT including the sources of the transitive dependencies.

to_json

string JavaInfo.to_json()

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"}}}

to_proto

string JavaInfo.to_proto()

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
# }

transitive_compile_time_jars

depset JavaInfo.transitive_compile_time_jars

Returns the transitive set of Jars required to build the target. Returns the same as JavaInfo.transitive_deps for legacy reasons.

transitive_deps

depset JavaInfo.transitive_deps

Returns the transitive set of Jars required to build the target. Returns the same as JavaInfo.transitive_compile_time_jars for legacy reasons.

transitive_exports

depset JavaInfo.transitive_exports

Returns a set of labels that are being exported from this rule transitively.

transitive_runtime_deps

depset JavaInfo.transitive_runtime_deps

Returns the transitive set of Jars required on the target's runtime classpath. Returns the same as JavaInfo.transitive_runtime_jars for legacy reasons.

transitive_runtime_jars

depset JavaInfo.transitive_runtime_jars

Returns a transitive set of Jars required on the target's runtime classpath. Returns the same as JavaInfo.transitive_runtime_deps for legacy reasons.

transitive_source_jars

depset JavaInfo.transitive_source_jars

Returns the Jars containing source files of the current target and all of its transitive dependencies.