Skip to content

Commit eb58e0b

Browse files
committed
Significantly improve performance, reliability and memory usage
Vendor tools.reader and java.classpath dependencies
1 parent f647a23 commit eb58e0b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4921
-883
lines changed

.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
test --test_output=all
22
test --verbose_failures
33

4-
build --java_runtime_version=remotejdk_17
5-
build --tool_java_runtime_version=remotejdk_17
4+
build --java_runtime_version=local_jdk
5+
build --tool_java_runtime_version=local_jdk

.circleci/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
- run:
2323
name: example tests
2424
command: cd examples/simple && bazel test //...
25+
- run:
26+
name: stress tests
27+
command: cd examples/stress && bazel test //...
28+
2529

2630
workflows:
2731
test-workflow:

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Note that `clojure_library` AOT is _non-transitive_. By default `(clojure.core/c
6363

6464
If you don't need to AOT, `clojure_library` isn't necessary, just use `java_library` with `resource_strip_prefix`.
6565

66-
Note that AOT will determine whether a library should appear in `deps` or `runtime_deps`. If a library is being AOT'd, everything that it requires will need to appear in `deps`. If it is not being AOT'd, dependencies should be listed in `runtime_deps`.
66+
Note that AOT will determine whether a library should appear in `deps` or `runtime_deps`. If a library is being AOT'd, everything that it loads at compile time will need to appear in `deps`. If it is not being AOT'd, dependencies should be listed in `runtime_deps`.
6767

6868
### clojure_repl
6969

@@ -177,19 +177,21 @@ Prefer namespace metadata for specifying extra dependencies in your code. Howeve
177177

178178
put `:bazel {:deps {}}` at the top level of your deps.edn file. `:deps` will be merged in when running `gen_srcs`. Deps are a map of bazel labels to a map of extra fields to merge into the `clojure_library`.
179179

180+
`examples/stress/deps.edn` contains known examples of libraries that require extra annotations to compile under rules clojure.
181+
180182
### no AOT
181183

182184
```clojure
183185
:bazel {:no-aot #{foo.bar}}
184186
```
185187

186-
Instructs gen-build to not AOT that namespace.
188+
Instructs gen-build to not AOT that namespace. Note that this doesn't affect 3rd party dependencies yet.
187189

188190
### Coarse dependencies
189191

190192
Fine grained dependencies are ideal from an efficiency perspective, but it isn't always possible to make them work.
191193

192-
`gen_srcs` also creates a few extra targets in every directory on the deps.edn search path. It will produce `clojure_library` targets named `__clj_lib` containing all source files in the directory (non-AOT'd), and all subpackages. `//src:__clj_files` includes all src files under `src`. These targets are useful for static analysis tools.
194+
`gen_srcs` also creates a few extra targets in every directory on the deps.edn search path. It will produce `clojure_library` targets named `__clj_lib` containing all source files in the directory (non-AOT'd), and all subpackages. `//src:__clj_files` includes all src files under `src`. These targets are useful for e.g. static analysis tools like clj-kondo.
193195

194196
`__clj_lib` does not include dependencies. Use `@deps//:__all` to pull in all dependencies.
195197

@@ -294,13 +296,28 @@ This makes things much nicer and more standard for users of the rules.
294296
- builds are non-reproducible for one reason:
295297
- there isn't a public API to reset the ID clojure uses for naming anonymous functions, which means anonymous AOT function names are non-deterministic
296298
- When using gen-deps, I haven't found a way to identify :provided dependencies. Those have to be added by hand for now
297-
- Do not use `user.clj`. If there is a user.clj at the root of your classpath, it will be loaded every time a new Clojure runtime is created, which can be many times during an AOT job. Additionally, dependencies in the user.clj are invisible to `gen-build`
298299

299300
# Compatibility
300301

301-
rules_clojure requires JDK 17 or higher. It is currently tested with Bazel 7.4.1 and JDK21
302+
rules_clojure requires JDK 21 or higher. It is currently tested with Bazel 7.4.1 and JDK21
302303

303304
# Thanks
304305

305306
- Forked from https://github.com/simuons/rules_clojure
306307
- Additional inspiration from https://github.com/markdingram/bazel-clojure
308+
- Contains vendored code from tools.namespace https://github.com/clojure/tools.namespace
309+
- Contains vendored code from tools.reader https://github.com/clojure/tools.reader
310+
- Contains vendored code from java.classpath https://github.com/clojure/java.classpath
311+
312+
313+
314+
Copyright and License
315+
----------------------------------------
316+
317+
Copyright © 2025 Griffin Bank. All rights reserved. The use and
318+
distribution terms for this software are covered by the
319+
[Eclipse Public License 1.0] which can be found in the file
320+
epl-v10.html at the root of this distribution. By using this software
321+
in any fashion, you are agreeing to be bound by the terms of this
322+
license. You must not remove this notice, or any other, from this
323+
software.

WORKSPACE

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ maven_install(
2727
maven.artifact(
2828
group = "org.clojure",
2929
artifact = "clojure",
30-
version = "1.11.1",
30+
version = "1.12.1",
3131
exclusions = [
3232
"org.clojure:spec.alpha",
3333
"org.clojure:core.specs.alpha"
@@ -36,21 +36,19 @@ maven_install(
3636
maven.artifact(
3737
group = "org.clojure",
3838
artifact = "spec.alpha",
39-
version = "0.3.218",
39+
version = "0.5.238",
4040
exclusions = ["org.clojure:clojure"]
4141
),
4242
maven.artifact(
4343
group = "org.clojure",
4444
artifact = "core.specs.alpha",
45-
version = "0.2.62",
45+
version = "0.4.74",
4646
exclusions = [
4747
"org.clojure:clojure",
4848
"org.clojure:spec.alpha"
4949
]
5050
),
5151
"org.clojure:data.json:2.4.0",
52-
"org.clojure:java.classpath:1.0.0",
53-
"org.clojure:tools.namespace:1.1.0",
5452
"org.clojure:tools.deps.alpha:0.14.1212"
5553
],
5654
maven_install_json = "@//:frozen_deps_install.json",
@@ -75,9 +73,14 @@ rules_clojure_setup()
7573
maven_install(
7674
name = "clojure_old",
7775
artifacts = [
78-
"org.clojure:clojure:1.8.0",],
76+
"org.clojure:clojure:1.8.0"],
7977
fail_if_repin_required = True,
8078
repositories = [
8179
"https://repo1.maven.org/maven2",
8280
"https://repo.clojars.org/"
8381
])
82+
83+
local_repository(
84+
name = "example-simple",
85+
path = "examples/simple",
86+
)

deps.edn

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
{:paths ["src", "classes"]
33
:deps {org.clojure/data.json {:mvn/version "2.4.0"}
44
org.clojure/java.classpath {:mvn/version "1.0.0"}
5-
org.clojure/tools.deps.alpha {:mvn/version "0.14.1212"}
6-
org.clojure/tools.namespace {:mvn/version "1.1.0"}}
5+
org.clojure/tools.deps.alpha {:mvn/version "0.14.1212"}}
76
:aliases {:dev {:extra-paths "test"}}}

deps/rules_clojure_maven_deps.zip

-2.79 KB
Binary file not shown.

examples/simple/.bazelrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
build --java_runtime_version=remotejdk_17
2-
build --tool_java_language_version=17
3-
build --tool_java_runtime_version=remotejdk_17
1+
build --java_runtime_version=local_jdk
2+
build --tool_java_runtime_version=local_jdk

examples/simple/deps.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{:deps
2-
{org.clojure/clojure {:mvn/version "1.11.1"}}
2+
{org.clojure/clojure {:mvn/version "1.12.1"}}
33
:paths ["src"]}

examples/simple/src/example/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ load("@rules_clojure//:rules.bzl", "clojure_library", "clojure_binary")
22

33
package(default_visibility = ["//visibility:public"])
44

5+
java_library(name="src",
6+
resources=glob(["*.clj"]),
7+
resource_strip_prefix="src")
8+
59
clojure_library(name="core",
610
srcs=["core.clj"],
711
resource_strip_prefix="src",

examples/stress/.bazeliskrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
USE_BAZEL_VERSION=7.4.1

0 commit comments

Comments
 (0)