remote_file
A remote_file() rule is used to download files from the Internet to be used as dependencies for other rules. These rules are downloaded by running fetch, or can be downloaded as part of build. See the note there about the .buckconfig setting to configure that.
Function Signature
def remote_file(
*,
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] = {},
_unzip_tool: str = "prelude//zip_file/tools:unzip",
contacts: list[str] = [],
default_host_platform: None | str = None,
labels: list[str] = [],
licenses: list[str] = [],
out: None | str = None,
sha1: None | str = None,
sha256: None | str = None,
size_bytes: None | int = None,
type: None | str = None,
url: str,
vpnless_url: 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
-
contacts: (defaults to:[])A list of organizational contacts for this rule. These could be individuals who you would contact in the event of a failure or other issue with the rule.
contacts = [ 'Joe Sixpack', 'Erika Mustermann' ] -
labels: (defaults to:[])Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using
buck query(). -
licenses: (defaults to:[])Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use buck query
-
out: (defaults to:None)An optional name to call the downloaded artifact. Buck will generate a default name if one is not provided that uses the
nameof the rule. -
size_bytes: (defaults to:None)Size in bytes of the downloaded artifact. Buck verifies this is correct and fails the fetch command if it doesn't match (only when a SHA-1 hash is used).
-
type: (defaults to:None)An optional type of the downloaded file.
dataRegular data file.executableExecutable file. Buck will ensure that output has appropriate permissions if applicable.
exploded_zipZip archive which will be automatically unzipped into an output directory.
-
url: (required)You can specify an
http,https, or amvnURL. If you specify amvnURL, it will be decoded as described in the javadocs for MavenUrlDecoder See the example section below. -
vpnless_url: (defaults to:None)An optional additional URL from which this resource can be downloaded when off VPN. Meta-internal only.
Examples
Here's an example of a remote_file() using an https URL.
remote_file(
name = 'android-ndk-r10e-darwin-x86_64',
url = 'https://dl.google.com/android/ndk/android-ndk-r10e-darwin-x86_64.bin',
sha1 = 'b57c2b9213251180dcab794352bfc9a241bf2557',
)
Here's an example of a remote_file() using a mvn URL being referenced
by a prebuilt_jar().
prebuilt_jar(
name = 'jetty-all',
binary_jar = 'jetty-all-9.2.10.v20150310.jar',
source_jar = ':jetty-source',
)
remote_file(
name = 'jetty-source',
out = 'jetty-all-9.2.10.v20150310-sources.jar',
url = 'mvn:org.eclipse.jetty.aggregate:jetty-all:src:9.2.10.v20150310',
sha1 = '311da310416d2feb3de227081d7c3f48742d7075',
)
Here's an example of a remote_file() using a mvn URI which uses a
non-default maven repository host.
remote_file(
name = 'jetty-source',
out = 'jetty-all-9.2.10.v20150310-sources.jar',
url = 'mvn:https://maven-repo.com:org.eclipse.jetty.aggregate:jetty-all:src:9.2.10.v20150310',
sha1 = '311da310416d2feb3de227081d7c3f48742d7075',
)
Here's an example of a remote_file() using a mvn URI which uses a
Maven classifier.
remote_file(
name = 'groovy-groovysh-indy',
out = 'jetty-all-9.2.10.v20150310-sources.jar',
url = 'mvn:org.codehaus.groovy:groovy-groovysh:jar:indy:2.4.1',
sha1 = '1600fde728c885cc9506cb102deb1b494bd7c130',
)