-
Notifications
You must be signed in to change notification settings - Fork 10
DRAFT: Add bzlmod support #67
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
base: main
Are you sure you want to change the base?
Conversation
drive-by: remove erroneous newlines, spaces, add clj-kondo to gitignore
drive-by: clean up tools_deps
paths is passed to the jvm, jvm takes the first one found
@@ -0,0 +1,67 @@ | |||
module( | |||
name = "rules_clojure", | |||
version = "0.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decide on a version number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the clojure tools.build convention of defaulting to "x.y.z" where x and y are user controlled, and z is the total number of git commits on master. tools.build has a script for computing z, I don't know whether bazel can help there.
def get_deps_repo_tag(repository_ctx): | ||
return repository_ctx.original_name if hasattr(repository_ctx, "original_name") else repository_ctx.attr.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a new naming scheme for repositories, which has repository_ctx.attr.name
return _main+_repo_rules+deps
or similar rather than their given names. original_name
was added in Bazel 8.1, but not backported to earlier versions. As a consequence, this PR will have rules_clojure not support the use of bzlmod on Bazel 7.x.
"_rules_clj_deps": attr.label(default="@rules_clojure//:deps.edn"), | ||
"_rules_clj_src": attr.label(default="@rules_clojure//:src")}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't see these being referenced anywhere.
org.clojure/tools.deps.alpha {:mvn/version "0.14.1178"}}}""" % (repository_ctx.path("../rules_clojure+/src"), | ||
repository_ctx.path("../rules_clojure/src")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsatisfied with this hack. I'd like to find a better way to get access to the genbuild code, whether that be by passing a reference into clojure_tools_deps
or by finding the right attribute on repository_ctx
.
) | ||
|
||
maven.install( | ||
name = "rules_clojure_maven_deps", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #22 we introduced a methodology for pinning maven dependencies for WORKSPACE.bazel files that avoided polluting the maven namespace and requiring users to load the dependencies manually. See the rationale given by the original authors of the method: https://github.com/bazel-contrib/rules_jvm/blob/e153df2d3f3077690e0e423769908f66b1d7893f/docs/postfix.md
In bzlmod, neither of these benefits stand - when one module depends on another, the dependee's dependencies are not included in a global namespace, and users do not need to manually load transitive dependencies.
Therefore, we can 'skip' the frozen dependencies part and run maven.install
using the name rules_clojure_maven_deps
immediately, maintaining compatibility across WORKSPACE and bzlmod approaches.
Added support for bzlmod. This allows bringing in rules_clojure via a MODULE.bazel file rather than through WORKSPACE.bazel, Bazel's support for which is planned to be removed "late 2025".
Usage
Todo
clojure_tools_deps
referencing of therules_clojure
repository for runningrules-clojure.gen-build
.bazel_dep(name = "rules_clojure", version = "x.y.z")
Notes
Mike Bland's ongoing series of blog posts on migrating to bzlmod was a useful resource.