Welcome! Please see the About page for a little more info on how this works.

0 votes
ago in Clojure CLI by

Following the existing example:

https://clojure.org/reference/clojure_cli#deps_prep

{:paths ["src" "target/classes"]
 :deps/prep-lib
 {:ensure "target/classes"
  :alias :build
  :fn compile-java}}

How does one control cache invalidation? i.e. if any .java file has been added or modified, a compilation should be re-triggered.

The linked doc says:

:ensure - directory existence determines whether prep is needed

It seems to me that only the existence of a directory may not be sufficient to determine if a lib is 'prepped?' One might want to add a custom function, for instance.

This use case is particularly painful in monorepos, where a given sub-project may depend on a sibling project's java classes.

There's the option of wrapping things with babashka, which worked well for me, however it is surprising that standalone tools.deps appeared to be insufficient for this use case.

1 Answer

+1 vote
ago by

There's no general way to know if a local project's build directory is stale. In that case, you'll need to force a re-prep, either by deleting the ensure directory or by using the :force flag on prep.

https://clojure.github.io/tools.deps.cli/clojure.tools.deps.cli.api-api.html#clojure.tools.deps.cli.api/prep

ago by
Thanks, I see that that's the current state of things.

Do you foresee an improvement? Re-building things by hand is error-prone. I have technical members at my team which aren't primarily Clojure developers, so automation would only help.
ago by
Don't have anything planned currently.
...