Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a deps and a setup macro #481

Merged
merged 3 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ http_archive(
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
Expand All @@ -98,6 +106,14 @@ or environment variables. See the [Coursier
documentation](https://get-coursier.io/docs/other-credentials.html#property-file)
for more information.

`rules_jvm_external_setup` uses a default list of maven repositories to download
`rules_jvm_external`'s own dependencies from. Should you wish to change this,
use the `repositories` parameter:

```python
rules_jvm_external_setup(repositories = ["https://mycorp.com/artifacts"])
```

Next, reference the artifacts in the BUILD file with their versionless label:

```python
Expand Down
16 changes: 12 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,20 @@ http_archive(
# dependencies. So, we omit them to keep the WORKSPACE file simpler.
# https://skydoc.bazel.build/docs/getting_started_stardoc.html

load("//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

# Begin test dependencies

load("//:defs.bzl", "maven_install")

load("//:specs.bzl", "maven")

maven_install(
name = "outdated",
artifacts = [
Expand All @@ -63,10 +75,6 @@ maven_install(
],
)

# Begin test dependencies

load("//:specs.bzl", "maven")

maven_install(
artifacts = [
"com.google.guava:guava:27.0-jre",
Expand Down
16 changes: 16 additions & 0 deletions repositories.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("//:defs.bzl", "maven_install")

_DEFAULT_REPOSITORIES = [
"https://repo1.maven.org/maven2",
"https://jcenter.bintray.com/",
"https://maven.google.com",
]

def rules_jvm_external_deps(repositories = _DEFAULT_REPOSITORIES):
maven_install(
name = "rules_jvm_external_deps",
artifacts = [
],
maven_install_json = "@rules_jvm_external//:rules_jvm_external_deps_install.json",
repositories = repositories,
)
9 changes: 9 additions & 0 deletions rules_jvm_external_deps_install.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"dependency_tree": {
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": 2914,
"conflict_resolution": {},
"dependencies": [
],
"version": "0.1.0"
}
}
4 changes: 4 additions & 0 deletions setup.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
load("@rules_jvm_external_deps//:defs.bzl", "pinned_maven_install")

def rules_jvm_external_setup():
pinned_maven_install()