Skip to content

2.8

Compare
Choose a tag to compare
@jin jin released this 18 Sep 00:47
· 530 commits to master since this release

Changelog

  • Added strict_visibility attribute to set transitive targets' visibility to //visibility:private. This is disabled by default. If enabled, only targets specified in maven_install will be accessible.
  • Updated documentation on referencing transitive targets
  • Support more packaging types (scala-jar, hk2-jar, maven-plugin) to mirror Coursier's default set.
  • Bash scripts now use #!/usr/bin/env bash to be more portable. (thanks, @puffnfresh)
  • pin.sh instructions are now more concise if you're already using maven_install.json. (thanks, @borkaehw)
  • Improved artifact pinning documentation on requiring a top level BUILD file to reference //:maven_install.json. (thanks, @KaoruDev)

Usage

In your WORKSPACE file, add:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

RULES_JVM_EXTERNAL_TAG = "2.8"
RULES_JVM_EXTERNAL_SHA = "79c9850690d7614ecdb72d68394f994fef7534b292c4867ce5e7dec0aa7bdfad"

http_archive(
    name = "rules_jvm_external",
    strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
    sha256 = RULES_JVM_EXTERNAL_SHA,
    url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
    artifacts = [
        "junit:junit:4.12",
        "androidx.test.espresso:espresso-core:3.1.1",
        "org.hamcrest:hamcrest-library:1.3",
    ],
    repositories = [
        "https://jcenter.bintray.com/",
        "https://maven.google.com",
        "https://repo1.maven.org/maven2",
    ],
)

In your BUILD file, reference the targets directly:

java_library(
    name = "java_test_deps",
    exports = [
        "@maven//:junit_junit"
        "@maven//:org_hamcrest_hamcrest_library",
    ],
)

android_library(
    name = "android_test_deps",
    exports = [
        "@maven//:junit_junit"
        "@maven//:androidx_test_espresso_espresso_core",
    ],
)