Releases: bazel-contrib/rules_jvm_external
3.0
Changelog
- The minimum supported Bazel version is now 1.0.0.
- @justhecuke fixed issues with authenticated URLs with
maven_install.json
, therefore adding authentication support to artifact pinning, making use ofnetrc
internally. maven_install
no longer implicitly depends onpython
.
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "3.0"
RULES_JVM_EXTERNAL_SHA = "62133c125bf4109dfd9d2af64830208356ce4ef8b165a6ef15bbff7460b35c3a"
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",
],
)
2.10
Changelog
- Added a migration tool to convert
maven_jar
usages tomaven_install
. See announcement and usage instructions. - Bazel can now provide helpful
buildozer add dep
messages when referencing a class not provided through a direct JAR dependency. This is a feature of Bazel's strict Java dependency compiler plugin, where referenced classes from transitive targets need to be declared as direct dependencies. For example:
$ bazel build //:B_no_dep
...
B.java:6: error: [strict] Using type com.google.common.collect.Lists from an indirect dependency (TOOL_INFO: "@maven//:com_google_guava_guava"). See command below **
System.err.println(Lists.reverse(A.INTEGERS));
^
** Please add the following dependencies:
@maven//:com_google_guava_guava to //:B_no_dep
** You can use the following buildozer command:
buildozer 'add deps @maven//:com_google_guava_guava' //:B_no_dep
...
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.10"
RULES_JVM_EXTERNAL_SHA = "1bbf2e48d07686707dd85357e9a94da775e1dbd7c464272b3664283c9c716d26"
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",
],
)
2.9
Changelog
- Coursier has been bumped to v2.0.0-RC3-4.
- Added support for custom
maven_install.json
locations. Learn more here - @cheister added a
resolve_timeout
attribute tomaven_install
. The default value is 600 seconds. - @cheister added the ability to parse HTTP proxy URLs with inlined username and password.
- @puffnfresh fixed an issue with invalid parsed paths containing inlined usernames.
- Fixed an incompatibility between
override_targets
andstrict_visibility
. - Added a Protocol Buffers Java example project that uses
override_targets
andstrict_visibility
.
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.9"
RULES_JVM_EXTERNAL_SHA = "e5b97a31a3e8feed91636f42e19b11c49487b85e5de2f387c999ea14d77c7f45"
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",
],
)
2.8
Changelog
- Added
strict_visibility
attribute to set transitive targets' visibility to//visibility:private
. This is disabled by default. If enabled, only targets specified inmaven_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 usingmaven_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",
],
)
2.7
Changelog
- Updated Coursier version to 2.0.0-RC3. The Coursier binary is no longer fetched from Maven repositories, but from GitHub and the Bazel mirror.
- The Coursier update fixes 2 issues: embedded version ranges in
maven_coordinates
tag, and incorrect generated dependency targets for particular artifacts.
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.7"
RULES_JVM_EXTERNAL_SHA = "f04b1466a00a2845106801e0c5cec96841f49ea4e7d1df88dc8e4bf31523df74"
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",
],
)
2.6.1
Changelog
- Fixed an issue that surfaced in 2.6 when using private Maven repositories.
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.6.1"
RULES_JVM_EXTERNAL_SHA = "45203b89aaf8b266440c6b33f1678f516a85b3e22552364e7ce6f7c0d7bdc772"
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",
],
)
2.6
Changelog
- Added support for mirror URLs in
maven_install.json
. This increases redundancy when usingpinned_maven_artifacts
if certain mirrors are down. - Added support for POM-only / parent artifacts.
- Updated pinning instructions for
bazel run @unpinned_maven//:pin
to specify the fully qualified label tomaven_install.json
for improved inter-operability between repositories. (thanks, @borkaehw) - Reworked internal HTTP Basic username and password to use Coursier's
--credentials
flag. (thanks, @TheMarex)
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.6"
RULES_JVM_EXTERNAL_SHA = "064b9085b21c349c8bd8be015a73efd6226dd2ff7d474797b3507ceca29544bb"
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",
],
)
2.5
Changelog
maven_install.json
now includes a field containing the checksum of the pinned dependency tree. The purpose is to prevent accidental modification ofmaven_install.json
directly. To generate this checksum, runbazel run @unpinned_maven//:pin
for a newmaven_install.json
.- Added the ability to override generated target labels using the
override_targets
attribute. Read the documentation for more information. - Extended
generate_compat_repositories
to also generate@group_artifact//:group_artifact
labels, which can also be referenced using@group_artifact
. - Fixed an issue between artifact pinning and
use_unsafe_shared_cache
.
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.5"
RULES_JVM_EXTERNAL_SHA = "249e8129914be6d987ca57754516be35a14ea866c616041ff0cd32ea94d2f3a1"
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 = [
"androidx.test.espresso:espresso-core:3.1.1",
"junit:junit:4.12",
"com.google.inject:guice:4.0",
],
repositories = [
"https://jcenter.bintray.com/",
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
In your BUILD file, reference the targets directly:
android_library(
name = "test_library",
srcs = glob(["**/*.java"]),
deps = [
"@maven//:com_google_inject_guice",
],
exports = [
"@maven//:androidx_test_espresso_espresso_core",
"@maven//:junit_junit",
],
)
2.4
Changelog
- Added a
version_conflict_policy
attribute tomaven_install
to determine whether to pin artifacts based on the versions specified in the WORKSPACE, or rely on Coursier's default conflict resolution algorithm. See the documentation for more information. (thanks, @beasleyr-vmw) - Fixed issues with
maven_install.json
content (thanks, @beasleyr-vmw) and filename generation. - Added documentation on using
rules_jvm_external
as a library maintainer. (thanks, @Dig-Doug)
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.4"
RULES_JVM_EXTERNAL_SHA = "2393f002b0a274055a4e803801cd078df90d1a8ac9f15748d1f803b97cfcdc9c"
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 = [
"androidx.test.espresso:espresso-core:3.1.1",
"junit:junit:4.12",
"com.google.inject:guice:4.0",
],
repositories = [
"https://jcenter.bintray.com/",
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
In your BUILD file, reference the targets directly:
android_library(
name = "test_deps",
exports = [
"@maven//:androidx_test_espresso_espresso_core",
"@maven//:junit_junit",
"@maven//:com_google_inject_guice",
],
)
2.3
Changelog
- Added support for pinning the transitive closure of artifacts and their checksums into a JSON file called
maven_install.json
. This feature improves artifact resolution and fetch speed, since it uses Bazel's download mechanism which caches files on their sha256 checksums. It also improves resiliency and security through encoding the sha256 checksums and original artifact urls into the JSON file. See the documentation for more information. - Added a new
generate_compat_repositories
attribute tomaven_install
to simplify the migration path frommaven_jar
andjvm_import_external
. If enabled,maven_install
will generate acompat.bzl
file containing the repository aliases that are compatible with those rules. For example,@com_google_guava_guava//jar
will be generated for@maven//:com_google_guava_guava
. See the documentation for more information. - Added Stardoc-generated complete API reference for
maven_install
and themaven
specification helpers. - Fixed an issue with cyclic dependencies.
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.3"
RULES_JVM_EXTERNAL_SHA = "375b1592e3f4e0a46e6236e19fc30c8020c438803d4d49b13b40aaacd2703c30"
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 = [
"androidx.test.espresso:espresso-core:3.1.1",
"junit:junit:4.12",
"com.google.inject:guice:4.0",
],
repositories = [
"https://jcenter.bintray.com/",
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
In your BUILD file, reference the targets directly:
android_library(
name = "test_deps",
exports = [
"@maven//:androidx_test_espresso_espresso_core",
"@maven//:junit_junit",
"@maven//:com_google_inject_guice",
],
)