-
Notifications
You must be signed in to change notification settings - Fork 41
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
Document how workspace rules should interface with pom_file #15
Comments
Unfortuantely, I haven't seen any mechanism by which Alternatively/additionally, bazel-deps could probably use |
Other than the red tape involved to nail down the officially supported tag, yes. Otherwise future people are going to have the same confusion I had where I added this into an existing project & then stared blankly when it didn't do anything. (I should probably file another bug/just make a PR with a bit more documentation around that requirement, but it'd still be better for the obvious things to Just Work[tm])
Skimming the docs, it looks like that's inadequate for private use: I might be able to get bazel to interpolate in something pulled in from elsewhere, but I'd also be nervous that something somewhere would naively dump |
Over in bazel-common, there's a rule for generating poms for shipping bazel targets: https://github.com/google/bazel-common/blob/master/tools/maven/pom_file.bzl That figures out its dependencies via the 'maven_coordinates' tag on build rules, and unfortunately it's easier said than done to just infer that from a maven_jar rule (see also: google/bazel-common#15 ) In the mean time, I've hacked bazel_deps to explicitly write that tag, though it's on the 3rdparty java_library rule, rather than the maven_jar one because the latter doesn't support tags :/ I've done very minimal playing with this, but it sure LOOKS like this is correctly letting me have bazel-deps manage the song and dance going from maven -> bazel, and then generate poms so I can publish artifacts for everyone else to consume.
Looks like I'm unblocked for the moment with minimal pain by hacking bazel-deps to add the tag to the 🤞 |
I'm not sure what the best practice is (or if there is one) with regard to bazel+internal maven servers+credentials. That sounds like a way that builds become unreproducible?
That also works :) Shall we close this issue? |
Why? It's still a maven repository with immutable published artifacts and my WORKSPACE files can list expected checksums for them, etc. They just aren't publicly available and/or available by virtue of just being on. some private network. Try to hit it as some random person & it'll fail downloads and bazel will break just like if you hit a public repo and all your mirrors barfed at the same time.
I can open another issue/PR for documenting "Hey, if you want to use this, you need to do this extra legwork", but it's really unfortunate if that's the answer when |
I would recommend using java_import_external which is in the bazel codebase and documents itself as the recommended practice. Please note it does not grab transitive dependencies automatically. You can use Bazel Maven Config Generator to crawl POM metadata and generate a WORKSPACE config that's fast, reliable, and mirrors artifacts to Google Drive. See demo video and best practices guide. |
My skylark's pretty rusty after a year on the outside, but if I'm following correctly:
The
pom_file
rule crawls the targets' dependencies, using themaven_coordinates=[XXX]
tag to identify things that came from maven & can/should be included in{generated_bzl_deps}
That works fine for the deps coming from here since
workspace_defs.bzl
is turning maven artifact strings intojava_import_external
rules w/ that tag added.But anything defined as a native maven_jar is missed; it's got that artifactid directly on it, but not as that particular tag. And despite the claim here that all rules support
tags
,maven_jar
doesn't appear to support them, so I can't even just tack it on.I'm using bazel-deps to generate all the rules, so it looks like I could potentially hack that to stick the tags on the
java_library
rules it tosses underthird_party
, but it feels like if I knew what I was doing, it shouldn't be too bad to automagically get that off the underlyingmaven_jar
rule.The text was updated successfully, but these errors were encountered: