question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use rules_jvm_external to manage Bazel's third_party Java dependencies

See original GitHub issue

Once https://github.com/bazelbuild/rules_jvm_external/pull/169 is merged, rules_jvm_external will be able to resolve Maven dependencies transitively using maven_install.json, a pinned list of transitive artifacts. This file is generated with an initial call to Coursier via rules_jvm_external. Subsequent calls will use http_file with sha256 checksums to verify integrity and take advantage of Bazel’s repository cache.

Benefit 1: No need to vendor jars in third_party. Instead, one can just update the maven_install declaration in the WORKSPACE file with new artifacts / versions, and check in the updated maven_install.json file. Contributions touching third_party no longer need to be split up into two changes (third_party and non-third_party).

Benefit 2: No need for Bazel maintainers to manually wire up transitive dependencies in third_party. rules_jvm_external will resolve and fetch artifacts from Maven into $output_base/external/@maven with a fully wired up BUILD file. The missing piece is a post-build step to vendor that directory back into Bazel’s source tree.

Benefit 3: Maintaining capability for fully offline builds, since artifact downloads will be managed by Bazel and can be integrated with the distdir in a straightforward manner.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
buchgrcommented, Jun 18, 2019

Is the SHA256 checksum of a dependency a sufficient representation for the dependency itself?

The last few times we talked about this it was not …

Correct. The files would be generated into $output_base/external, but we can copy it back into the source tree.

I have actually also wanted to do this already after I first found about the rules_jvm_external. I believe this alone would already be a HUGE win.

0reactions
jincommented, Jun 18, 2019

The last few times we talked about this it was not …

Fair enough. I have a PR that allows rules_jvm_external to write directly into a source tree and use the new workspace.managed_directories feature: https://github.com/bazelbuild/rules_jvm_external/pull/168

Read more comments on GitHub >

github_iconTop Results From Across the Web

bazel - Recommended rule to download maven artifacts into ...
In general, use maven_install to skip the tedious work of managing transitive dependencies, and jvm_import_external if you want more manual ...
Read more >
A repository rule for calculating transitive Maven dependencies
We're excited to introduce the initial release of rules_jvm_external , a repository rule to resolve and fetch artifacts transitively in ...
Read more >
bazelbuild/rules_jvm_external - Aspect's Bazel Documentation
API Documentation for bazelbuild/rules_jvm_external. ... publish rule understands the following variables (declared using --define when using bazel run ):.
Read more >
Bazel rules for JFlex & Cup | bazel_rules - GitHub Pages
This repository offers two rules for projects using the Bazel build system: Rule to generate java source files from a lexer specification, with...
Read more >
Building Java Applications with Bazel - Baeldung
Learn how to build Java applications using the Bazel build tool. ... the section above specifies all the dependencies (jar files) as part...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found