Skip to main content

remote_file

name

def name(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_apple_platforms: dict[str, str] = ...,
_unzip_tool: str = ...,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
out: None | str = ...,
sha1: None | str = ...,
sha256: None | str = ...,
type: None | str = ...,
url: str,
vpnless_url: None | str = ...,
) -> None

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.

Parameters

  • name: name of the target

  • default_target_platform: specifies the default target platform, used when no platforms are specified on the command line

  • target_compatible_with: a list of constraints that are required to be satisfied for this target to be compatible with a configuration

  • compatible_with: a list of constraints that are required to be satisfied for this target to be compatible with a configuration

  • exec_compatible_with: a list of constraints that are required to be satisfied for this target to be compatible with an execution platform

  • visibility: a list of visibility patterns restricting what targets can depend on this one

  • within_view: a list of visibility patterns restricting what this target can depend on

  • metadata: a key-value map of metadata associated with this target

  • tests: a list of targets that provide tests for this one

  • modifiers: an array of modifiers associated with this target

  • out: An optional name to call the downloaded artifact. Buck will generate a default name if one is not provided that uses the name of the rule.

  • type: An optional type of the downloaded file.

    data Regular data file. executable

    Executable file. Buck will ensure that output has appropriate permissions if applicable.

    exploded_zip

    Zip archive which will be automatically unzipped into an output directory.

  • url: You can specify an http, https, or a mvn URL. If you specify a mvn URL, it will be decoded as described in the javadocs for MavenUrlDecoder See the example section below.

  • vpnless_url: An optional additional URL from which this resource can be downloaded when off VPN. Meta-internal only.

Details

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',
)