Getting started with Bazel / Maven repository

163 views
Skip to first unread message

Thomas Hirsch

unread,
Feb 21, 2023, 10:17:05 AM2/21/23
to bazel-discuss
Hi, 

I have a seemingly simple problem.

I would like to download a ZIP file from a Maven repository.
I already have a simple workspace file:

```
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

RULES_JVM_EXTERNAL_TAG = "4.5"
RULES_JVM_EXTERNAL_SHA = "b17d7388feb9bfa7f2fa09031b32707df529f26c91ab9e5d909eb1676badd9a6"

http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
)

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(
name = "maven",
artifacts = [
"<artifact-string>",
],
repositories = [
"http://<nexus-ip-and-port>/nexus/content/groups/dev",
]
)
```
So far so good, but now I am wondering how I could test this.

There are two caveats:
The file is not a JAR file but aZIP file, containing Python code.
The repository requires credentials.

I have read through a lot of documentation, but I am increasingly getting the impression, that I would need to learn Bazel from the very ground up in order to make sense of any of this. Could anyone suggest a simple BUILD file with something like a "copy" target or "download" target, that just depends on this artifact, and would trigger a download, so I could verify that I have everything configured correctly up to this point?

Jingwen Chen

unread,
Feb 21, 2023, 10:23:39 AM2/21/23
to Thomas Hirsch, bazel-discuss
Would a regular http_file to the direct URL suffice? It also supports netrc auth. It doesn't sound like you need the transitive resolution for maven jars, so rules_jvm_external is probably unnecessary.


--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/32cb9c38-9b71-47dc-ab29-9ab2c12ef5fcn%40googlegroups.com.

Thomas Hirsch

unread,
Feb 21, 2023, 10:27:34 AM2/21/23
to bazel-discuss
I have tried that, actually, but the problem there is that our Nexu repository doesn't support SAH265 just yet, which is required, by Bazel.
And I really want to start somewhere,and then migrate piece by piece, and downloading a ZIP or JAR from Nexus, and then use that to produce some other output file is basically the simplest use case I could think of when it comes to a build tool
I understand that Bazal represents a 180 degree paradigm shift, but still I feel like this is something the tool should be able to handle in one way or another.
Reply all
Reply to author
Forward
0 new messages