Skip to content

Support build-time dependencies for jank-build.bb scripts.#809

Open
kylc wants to merge 6 commits into
jank-lang:mainfrom
kylc:build-script-dependency
Open

Support build-time dependencies for jank-build.bb scripts.#809
kylc wants to merge 6 commits into
jank-lang:mainfrom
kylc:build-script-dependency

Conversation

@kylc

@kylc kylc commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Adds support for build dependencies: dependencies for your jank-build.bb script. For example, a common jank-build-cmake library which includes helpers for executing CMake, to be used by all jank-build.bb scripts in the wild which drive a CMake build.

This mimics the Cargo build-dependencies feature.

I have updated my lein-jank-playground to demo this:

  1. jank-json-sys declares a :build-dependencies entry in its project.clj file
  2. It uses the dependency in its jank-build.bb file
  3. This dependency is resolved via Maven as usual, in this case to an artifact on clojars (source: https://github.com/kylc/lein-jank-playground/tree/main/jank-build-cmake). It is added to the babashka classpath when the build script is executed.

Also includes some misc. fixups and some integration tests for the build system.

TODO

  • Validate (build?)-dependencies-of-build-dependencies behavior
  • Think about whether using this non-standard pom.xml dependency scope jank-build will cause any problems down the line

@kylc kylc marked this pull request as draft June 12, 2026 00:34
@jeaye

jeaye commented Jun 14, 2026

Copy link
Copy Markdown
Member

This looks great. I will ask technomancy if he sees any issue with the scope usage for build deps.

@kylc kylc force-pushed the build-script-dependency branch from 9a95df6 to 6173442 Compare June 14, 2026 18:06
@kylc kylc changed the title WIP: Support build-time dependencies for jank-build.bb scripts. Support build-time dependencies for jank-build.bb scripts. Jun 14, 2026
(do
(lmain/warn "No :main entrypoint for project.")
(lmain/exit 1)))))
(lmain/warn "No :main entrypoint for project."))))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got rid of the exit calls here because some standard lein tasks call out to these unconditionally. For example lein install seems to always lein compile (that makes sense for building JVM JARs). In our case, if a library does not have a main, this will cause lein install to abort, which we don't want.

[{:op :extract-src
:dep dep
:jar (str src-jar)
:fprint (fingerprint-file src-jar)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bit more to figure out with the fingerprinting to make sure rebuilds trigger whenever something changes. Consider this a mostly functional placeholder for now.

@kylc kylc marked this pull request as ready for review June 14, 2026 18:22
@kylc

kylc commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

This looks great. I will ask technomancy if he sees any issue with the scope usage for build deps.

It's nice because the scope fits into the standard leiningen dependency tree functionality, so we can easily pick out build dependencies without any additional code. But if it's a no-go then we can implement our own logic to read the dependencies' project.clj and pull out the build-dependencies key.

@kylc

kylc commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

This is ready for review. I shoehorned some other improvements into this same PR, but they are somewhat organized as separate commits.

@jeaye

jeaye commented Jun 15, 2026

Copy link
Copy Markdown
Member

I asked technomancy and some others, on IRC, and heard back that our usage of dependency scopes here should be just fine.

@jeaye jeaye left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! Just hoping to get the tests into CI.

@@ -0,0 +1,78 @@
(ns leiningen.jank.integration-test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind hooking this into CI for this PR? I think we'll need a new job for the lein-jank project. Maybe .github/workflows/test-lein-jank.yml.

Otherwise, I'll never remember to run this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants