Releases: bazel-contrib/rules_jvm_external
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",
],
)
2.2
Changelog
- There is now an
excluded_artifacts
attribute inmaven_install
. Artifacts is this list will be excluded across all transitive dependencies during resolution. (thanks @TheMarex) - Fixed a crash when the
http_proxy
environment variable is set, but empty. (thanks @wlx65003) - Better integration with buildozer to fix dependencies on generated targets. (thanks @borkaehw)
- Coursier has been upgraded to v1.1.0-M14-4. (thanks @mandrean)
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.2"
RULES_JVM_EXTERNAL_SHA = "f1203ce04e232ab6fdd81897cf0ff76f2c04c0741424d192f28e65ae752ce2d6"
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.1
Changelog
- Add support for orbit package types
- Add support for test-jar packaging type
- Bump Coursier version to 1.1.0-M14-1
- Don't print rdeps error message if there are no rdeps for the artifact
- Fetch standard jars and sources at the same time
- Add support for Coursier checksum verification
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.1"
RULES_JVM_EXTERNAL_SHA = "515ee5265387b88e4547b34a57393d2bcb1101314bcc5360ec7a482792556f42"
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",
],
# Fetch srcjars. Defaults to False.
fetch_sources = True,
)
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.0.1
Changelog
- Deleted gmaven_rules code and docs. Use the
gmaven_rules
repository to keep using those rules. - POM-only dependencies are now supported.
- Added "neverlink" support: compile-time only dependencies. More information
- Internal change: turn the shell integration tests into java tests
Patch fix for v2.0:
- Fixed an issue while generating BUILD targets
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.0.1"
RULES_JVM_EXTERNAL_SHA = "55e8d3951647ae3dffde22b4f7f8dee11b3f70f3f89424713debd7076197eaca"
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",
],
# Fetch srcjars. Defaults to False.
fetch_sources = True,
)
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.0
NOTE: This release has a bug (#111). Please use v2.0.1 instead.
Changelog
- Delete gmaven code and docs. Use the
gmaven_rules
repository to keep using those rules. - Support pom-only dependencies.
- Internal change: turn the shell integration tests into java tests
- Add "neverlink" support: compile-time only dependencies
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "2.0"
RULES_JVM_EXTERNAL_SHA = "c60ad75370c1416497ec69a0c915d6971644bc77875a2a4b687c9f7cacf2cf30"
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",
],
# Fetch srcjars. Defaults to False.
fetch_sources = True,
)
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",
],
)
1.3
Changelog
- Added support for HTTP proxies using the
http_proxy
environment variable. More information about this. Thanks, @Zetten! - Fixed support for artifact classifier resolution. Thanks, @dgarzon!
- Internal change: the repository rule now downloads the Coursier standalone jar on demand, instead of using a vendored bootstrap jar.
Other changes include new Java Spring Boot and Scala Akka (thanks, @dgarzon) examples.
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "1.3"
RULES_JVM_EXTERNAL_SHA = "63a9162eb8b530da76453857bd3404db8852080976b93f237577f8000287e73d"
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",
],
# Fetch srcjars. Defaults to False.
fetch_sources = True,
)
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",
],
)
1.2
Changelog
- Added support for Kotlin-compiled JARs.
- The generated artifact targets'
tags
attribute now contain the artifacts' original coordinates. More information. - Fixed an issue on Windows where initial runs of the rule fail.
- Added new examples. These include Kotlin and Robolectric projects.
- Added API reference documentation.
- Improved error messages when Coursier fails to download an artifact.
Usage
In your WORKSPACE file, add:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "1.2"
RULES_JVM_EXTERNAL_SHA = "e5c68b87f750309a79f59c2b69ead5c3221ffa54ff9496306937bfa1c9c8c86b"
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",
],
# Fetch srcjars. Defaults to False.
fetch_sources = True,
)
In your BUILD file, reference the targets directly:
android_library(
name = "test_deps",
exports = [
"@maven//:androidx_test_espresso_espresso_core",
"@maven//:junit_junit",
],
)
Legacy gmaven_rules
This release also contains the legacy gmaven_rules
rules. We will not be including these legacy rules in
upcoming releases.
To keep existing builds working with the legacy @gmaven_rules
external repository, add an additional http_archive
target to the WORKSPACE file:
http_archive(
name = "gmaven_rules",
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,
)
1.1
Changelog
- Fixed an issue on Windows where the Coursier JSON output could not be read.
- Fixed an issue on Windows where the generated BUILD file contained invalid paths.
Usage
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "1.1"
RULES_JVM_EXTERNAL_SHA = "ade316ec98ba0769bb1189b345d9877de99dd1b1e82f5a649d6ccbcb8da51c1f"
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",
"com.google.inject:guice:4.0",
],
repositories = [
# Private repositories are supported through HTTP Basic auth
"http://username:password@localhost:8081/artifactory/my-repository",
"https://jcenter.bintray.com/",
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
# Fetch srcjars. Defaults to False.
fetch_sources = True,
)
load("@rules_jvm_external//:defs.bzl", "artifact")
android_library(
name = "test_deps",
exports = [
"@maven//:androidx_test_espresso_espresso_core", # artifact("androidx.test.espresso:espresso-core"),
"@maven//:junit_junit", # artifact("junit:junit"),
],
)
Legacy gmaven_rules
This release also contains the legacy gmaven_rules
rules. We will not be including these legacy rules in
upcoming releases.
To keep existing builds working with the legacy @gmaven_rules
external repository, add an additional http_archive
target to the WORKSPACE file:
http_archive(
name = "gmaven_rules",
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,
)
1.0
Overview
We're happy to announce the initial release of rules_jvm_external
. This release contains a repository rule to resolve and fetch artifacts transitively from Maven repositories, like Maven Central and Google Maven.
Usage
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
RULES_JVM_EXTERNAL_TAG = "1.0"
RULES_JVM_EXTERNAL_SHA = "48e0f1aab74fabba98feb8825459ef08dcc75618d381dff63ec9d4dd9860deaa"
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",
"com.google.inject:guice:4.0",
],
repositories = [
# Private repositories are supported through HTTP Basic auth
"http://username:password@localhost:8081/artifactory/my-repository",
"https://bintray.com/bintray/jcenter",
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
# Fetch srcjars. Defaults to False.
fetch_sources = True,
)
load("@rules_jvm_external//:defs.bzl", "artifact")
android_library(
name = "test_deps",
exports = [
"@maven//:androidx_test_espresso_espresso_core", # artifact("androidx.test.espresso:espresso-core"),
"@maven//:junit_junit", # artifact("junit:junit"),
],
)
Legacy gmaven_rules
This release also contains the legacy gmaven_rules
rules. We will not be including these legacy rules in
upcoming releases.
To keep existing builds working with the legacy @gmaven_rules
external repository, add an additional http_archive
target to the WORKSPACE file:
http_archive(
name = "gmaven_rules",
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,
)
December 12 2018, Snapshot 2
Add this in your WORKSPACE file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Google Maven Repository
GMAVEN_TAG = "20181212-2"
http_archive(
name = "gmaven_rules",
strip_prefix = "gmaven_rules-%s" % GMAVEN_TAG,
url = "https://github.com/bazelbuild/gmaven_rules/archive/%s.tar.gz" % GMAVEN_TAG,
)
load("@gmaven_rules//:gmaven.bzl", "gmaven_rules")
gmaven_rules()
Use the gmaven_artifact
macro in your BUILD file:
load("@gmaven_rules//:defs.bzl", "gmaven_artifact")
android_library(
...
deps = [
gmaven_artifact("com.android.support:design:aar:27.0.2"),
gmaven_artifact("com.android.support:support_annotations:jar:27.0.2"),
gmaven_artifact("com.android.support.test.espresso:espresso_core:aar:3.0.1"),
],
)