Skip to content

Commit

Permalink
feat(pin): allow only repinning the rules_jvm_external lockfile (#555)
Browse files Browse the repository at this point in the history
Now that rules_rust and rules_jvm_external both support the same
repinning method, make it possible to choose to repin a single lockfile
or all lockfiles.

Refs: bazelbuild/rules_rust#682
  • Loading branch information
gibfahn committed May 12, 2021
1 parent aa530f0 commit 8feca27
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -221,7 +221,11 @@ a build error, causing the build to fail. When this attribute is set,
it is possible to update the `maven_install.json` file using:

```shell
$ REPIN=1 bazel run @unpinned_maven//:pin
# To repin everything:
REPIN=1 bazel run @unpinned_maven//:pin

# To only repin rules_jvm_external:
RULES_JVM_EXTERNAL_REPIN=1 bazel run @unpinned_maven//:pin
```

Alternatively, it is also possible to modify the
Expand Down
16 changes: 8 additions & 8 deletions coursier.bzl
Expand Up @@ -41,7 +41,6 @@ _AAR_IMPORT_STATEMENT = """\
load("%s", "aar_import")
"""


_BUILD_PIN = """
genrule(
name = "jq-binary",
Expand Down Expand Up @@ -128,12 +127,12 @@ def _relativize_and_symlink_file(repository_ctx, absolute_path):
return artifact_relative_path

def _get_aar_import_statement_or_empty_str(repository_ctx):
if repository_ctx.attr.use_starlark_android_rules:
# parse the label to validate it
_ = Label(repository_ctx.attr.aar_import_bzl_label)
return _AAR_IMPORT_STATEMENT % repository_ctx.attr.aar_import_bzl_label
else:
return ""
if repository_ctx.attr.use_starlark_android_rules:
# parse the label to validate it
_ = Label(repository_ctx.attr.aar_import_bzl_label)
return _AAR_IMPORT_STATEMENT % repository_ctx.attr.aar_import_bzl_label
else:
return ""

# Generate the base `coursier` command depending on the OS, JAVA_HOME or the
# location of `java`.
Expand Down Expand Up @@ -337,7 +336,8 @@ def _fail_if_repin_required(repository_ctx):
if not repository_ctx.attr.fail_if_repin_required:
return False

return "REPIN" not in repository_ctx.os.environ.keys()
env_var_names = repository_ctx.os.environ.keys()
return "RULES_JVM_EXTERNAL_REPIN" not in env_var_names and "REPIN" not in env_var_names

def _pinned_coursier_fetch_impl(repository_ctx):
if not repository_ctx.attr.maven_install_json:
Expand Down

0 comments on commit 8feca27

Please sign in to comment.