Buck: remote_file()
Support Ukraine. Help Provide Humanitarian Aid to Ukraine.

remote_file()

This is liable to change in the future.

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 buck fetch, or can be downloaded as part of buck build. See the note there about the .buckconfig setting to configure that.

Arguments

  • name (required) #

    The short name for this build target.

  • url (required) #

    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.

  • sha1 (required) #

    The SHA-1 hash of the downloaded artifact. Buck verifies this is correct and fails the fetch command if it doesn't match in order to guarantee repeatable builds.

  • 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 name of the rule.

  • type (defaults to data) #

    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.

  • visibility (defaults to []) #

    List of build target patterns that identify the build rules that can include this rule as a dependency, for example, by listing it in their deps or exported_deps attributes. For more information, see visibility.

  • 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.

  • 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 attrfilter().

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