prebuilt_jar
A prebuilt_jar()
rule is used to identify a JAR file that is checked into our repository as a precompiled binary rather than one that is built from source by Buck. Frequently, these are used to reference third-party JAR files (such as junit.jar) and are used as dependencies of java_library()
rules.
Function Signature
def prebuilt_jar(
*,
name: str,
default_target_platform: None | str = None,
target_compatible_with: list[str] = [],
compatible_with: list[str] = [],
exec_compatible_with: list[str] = [],
visibility: list[str] = [],
within_view: list[str] = ["PUBLIC"],
metadata: OpaqueMetadata = {},
tests: list[str] = [],
modifiers: OpaqueMetadata = [],
_apple_platforms: dict[str, str] = {},
_build_only_native_code: bool = select({"prelude//android/constraints:build_only_native_code": True, "DEFAULT": False}),
_dex_min_sdk_version: None | int = select({"prelude//android/constraints:min_sdk_version_19": 19, "prelude//android/constraints:min_sdk_version_20": 20, "prelude//android/constraints:min_sdk_version_21": 21, "prelude//android/constraints:min_sdk_version_22": 22, "prelude//android/constraints:min_sdk_version_23": 23, "prelude//android/constraints:min_sdk_version_24": 24, "prelude//android/constraints:min_sdk_version_25": 25, "prelude//android/constraints:min_sdk_version_26": 26, "prelude//android/constraints:min_sdk_version_27": 27, "prelude//android/constraints:min_sdk_version_28": 28, "prelude//android/constraints:min_sdk_version_29": 29, "prelude//android/constraints:min_sdk_version_30": 30, "prelude//android/constraints:min_sdk_version_31": 31, "prelude//android/constraints:min_sdk_version_32": 32, "prelude//android/constraints:min_sdk_version_33": 33, "prelude//android/constraints:min_sdk_version_34": 34, "prelude//android/constraints:min_sdk_version_35": 35, "DEFAULT": None}),
_dex_toolchain: str = "gh_facebook_buck2_shims_meta//:dex",
_exec_os_type: str = "prelude//os_lookup/targets:os_lookup",
_prebuilt_jar_toolchain: str = "gh_facebook_buck2_shims_meta//:prebuilt_jar",
binary_jar: str,
contacts: list[str] = [],
default_host_platform: None | str = None,
deps: list[str] = [],
desugar_deps: list[str] = [],
generate_abi: bool = True,
is_executable: bool = False,
javadoc_url: None | str = None,
labels: list[str] = [],
licenses: list[str] = [],
maven_coords: None | str = None,
never_mark_as_unused_dependency: bool = False,
required_for_source_only_abi: bool = True,
source_jar: None | str = None,
) -> None
Parameters
-
name
: (required)name of the target
-
default_target_platform
: (defaults to:None
)specifies the default target platform, used when no platforms are specified on the command line
-
target_compatible_with
: (defaults to:[]
)a list of constraints that are required to be satisfied for this target to be compatible with a configuration
-
compatible_with
: (defaults to:[]
)a list of constraints that are required to be satisfied for this target to be compatible with a configuration
-
exec_compatible_with
: (defaults to:[]
)a list of constraints that are required to be satisfied for this target to be compatible with an execution platform
-
visibility
: (defaults to:[]
)a list of visibility patterns restricting what targets can depend on this one
-
within_view
: (defaults to:["PUBLIC"]
)a list of visibility patterns restricting what this target can depend on
-
metadata
: (defaults to:{}
)a key-value map of metadata associated with this target
-
tests
: (defaults to:[]
)a list of targets that provide tests for this one
-
modifiers
: (defaults to:[]
)an array of modifiers associated with this target
-
binary_jar
: (required)Path to the pre-built JAR file.
-
deps
: (defaults to:[]
)Rules that must be built before this rule. Because the
binary_jar
is already built, there should be nothing to build, so this should be empty. -
javadoc_url
: (defaults to:None
)URL to the Javadoc for the
.class
files in thebinary_jar
. -
source_jar
: (defaults to:None
)Path to a JAR file that contains the
.java
files to create the.class
in thebinary_jar
. This is frequently provided for debugging purposes.
Examples
prebuilt_jar(
name = 'junit',
binary_jar = 'junit-4.8.2.jar',
source_jar = 'junit-4.8.2-sources.jar',
javadoc_url = 'http://kentbeck.github.com/junit/javadoc/4.8/',
)
java_library(
name = 'tests',
srcs = glob(['tests/**/*Test.java']),
deps = [
':junit',
],
)