tools-deps

cfleming 2024-02-21T00:57:58.712989Z

Is there any way I can use deps to just execute a main() function from a Java class, without loading Clojure first? I need to control the classloader, so I’d like to build the classpath using deps but then execute a class which will later bootstrap Clojure.

2024-02-21T01:17:06.207679Z

There is an option to have deps print out the class path if I recall

cfleming 2024-02-21T01:17:44.361369Z

Yes, -Spath, but that means I need a script of some kind, which I was hoping to avoid.

cfleming 2024-02-21T01:18:00.894769Z

I can’t see any option for this though.

Alex Miller (Clojure team) 2024-02-21T02:00:18.849189Z

I don't understand why deps is relevant here?

Alex Miller (Clojure team) 2024-02-21T02:01:23.852039Z

the Clojure CLI is a Clojure program runner - it always ultimately uses clojure.main right now as the main class

Alex Miller (Clojure team) 2024-02-21T02:02:22.598929Z

but if you have a classpath and a main, why is either deps or the CLI even relevant

Alex Miller (Clojure team) 2024-02-21T02:02:28.848749Z

just call java

cfleming 2024-02-21T02:55:31.836099Z

Because I’d like to use deps to create the classpath. I can do it with a script as hiredman suggests, but then it’s more difficult to debug the resulting process as opposed to running it directly via Cursive.

cfleming 2024-02-21T03:07:22.032089Z

And I lose all sorts of affordances that IntelliJ provides for JVM processes.

Alex Miller (Clojure team) 2024-02-21T03:11:36.251079Z

you can use tools.deps as a library to create the classpath (it's in the basis)

Alex Miller (Clojure team) 2024-02-21T03:12:16.735129Z

when you say "deps" I am unclear what that means, and I think more precision would be useful. do you mean tools.deps the library? the Clojure CLI?

cfleming 2024-02-21T03:13:42.177639Z

I’d like to use Cursive’s existing machinery, which runs via deps.clj (equivalent of the CLI). But it seems like I can’t do that without some kind of second hop (either a script or a Java process which creates the classpath) before invoking the actual app.

cfleming 2024-02-21T03:15:41.715419Z

I’m trying to do this because I’m running the tests for Cursive, and I’m getting issues because of how Clojure initialises the classloader. I’d like to run some Java code before loading Clojure so I can control that. This is all because the latest version of lein has upgraded the maven resolver it uses, and my tests now fail because the classes now conflict with ones which the IntelliJ platform provides. I thought it would be easy, but it’s not turning out that way unfortunately.

cfleming 2024-02-21T03:16:23.683259Z

Anyway, I can keep looking for a solution, I just wanted to double check that the CLI didn’t provide what I was hoping for.