Skip to content

Commit

Permalink
Document artifact macro and dependencies list in README
Browse files Browse the repository at this point in the history
Also document strict_visibility_value from bazel-contrib#649
  • Loading branch information
dmivankov committed Jan 26, 2022
1 parent bcdef21 commit 9c577c2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ To use it, add the load statement to the top of your BUILD file:
load("@rules_jvm_external//:defs.bzl", "artifact")
```

Full `group:artifact:[packaging:[classifier:]]version` maven coordinates are also
supported and translate to corresponding versionless target.

Note that usage of this macro makes BUILD file refactoring with tools like
`buildozer` more difficult, because the macro hides the actual target label at
the syntax level.
Expand Down Expand Up @@ -855,6 +858,31 @@ maven_install(
)
```

It is also possible to change strict visibility value from default `//visibility:private`
to a value specified by `strict_visibility_value=` attribute.

### Accessing transitive dependencies list

It is possible to retrieve full list of dependencies in the dependency tree, including
transitive, source, javadoc and other artifacts. `maven_artifacts` list contains full
versioned maven coordinate strings of all dependencies.

For example:
```python
load("@maven//:defs.bzl", "maven_artifacts")

load("@rules_jvm_external//:defs.bzl", "artifact")
load("@rules_jvm_external//:specs.bzl", "parse")

all_jar_coordinates = [c for c in maven_artifacts if parse.parse_maven_coordinate(c).get("packaging", "jar") == "jar"]
all_jar_targets = [artifact(c) for c in all_jar_coordinates]

java_library(
name = "depends_on_everything",
runtime_deps = all_jar_targets,
)
```

### Fetch and resolve timeout

The default timeout to fetch and resolve artifacts is 600 seconds. If you need
Expand Down

0 comments on commit 9c577c2

Please sign in to comment.