What is the difference between maven install and pinned maven install in bazel?

2.1k Views Asked by At

I am trying to understand a bit of internals of bazel jvm external. The bazel documentation was not clear enough for me to understand.

What is the difference between the following steps.

Step 1
maven_install(
  # artifacts, repositories, ...
  maven_install_json = "//:maven_install.json",
)

This step internally calls coursier.bzl to fetch dependencies over @bazel_tools//tools/build_defs/repo:http.bzl

Step 2

    load("@maven//:defs.bzl", "pinned_maven_install")
    pinned_maven_install()

This step appears to be calling @bazel_tools//tools/build_defs/repo:http.bzl without going through coursier.bzl

Questions What is the difference between step 1 and step 2, both appear to be fetching artifacts over HTTP ? Eg: Is step 1 fetching unpinned version only and step 2 fetching pinned version only ?

1

There are 1 best solutions below

2
On

You can refer to the following code documentation from def.bzl.

Providing the maven_install_json property instruct maven_install rule to construct two repositories - one for the unpinned artifacts (first invocation) and one for the pinned artifacts (second invocation).

Later, on the second step, loads the pinned artifacts from the pinned artifacts repository. You can see the rule being generated here.