Fork me on GitHub
Jacob Emcken20:08:37

I'm was looking for a way to do lein install but with cli tools. I found clojure -X:deps mvn-install but that requires me to reference a jar file. So I guess my question is... how to I build the jar file then? 😅

Alex Miller (Clojure team)20:08:32 of course :)

Jacob Emcken20:08:13

I cloned the Clojure library tbh I don't understand how I am supposed to build it


You generally don't need to install libraries locally to use them. Just declare them as dependencies in your project.

Jacob Emcken20:08:43

I know that but I changed something in it that I want to try out


OK, so use :local/root as a dependency on it.

Jacob Emcken20:08:23

in a lein project 😉


Haha... OK, well, there's your problem 🙂


OK then probably the easiest way to make a JAR from beholder is to use depstar, since beholder doesn't have a build script or any aliases for that.

Jacob Emcken20:08:26

to figure out what that is


Here's the steps you need:

(! 1026)-> git clone [email protected]:nextjournal/beholder.git
Cloning into 'beholder'...
(! 1027)-> cd beholder/
(! 1028)-> clojure -X:deps mvn-pom
(! 1029)-> clojure -Sdeps '{:aliases {:depstar {:deps {com.github.seancorfield/depstar {:mvn/version "2.1.278"}}}}}' -X:depstar hf.depstar/jar :jar beholder.jar
Building thin jar: beholder.jar
Processing pom.xml for {beholder/beholder {:mvn/version "0.1.0"}}
(! 1030)-> clojure -X:deps mvn-install :jar '"beholder.jar"'
Installing beholder.jar 
Installed to /Users/sean/.m2/repository/beholder/beholder/0.1.0


(edited to show actual commands and results)


Then you can depend on it (via lein or here in a CLI REPL):

(! 1033)-> clj -Sdeps '{:deps {beholder/beholder {:mvn/version "0.1.0"}}}'
Clojure 1.10.3
user=> (require 'nextjournal.beholder)
user=> (nextjournal.beholder/watch prn ".")
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.
#object[io.methvin.watcher.DirectoryWatcher 0x65bb9029 "io.methvin.watcher.DirectoryWatcher@65bb9029"]
user=> (spit "test.txt" "Hello")
user=> {:type :create, :path #object[sun.nio.fs.UnixPath 0x69ee6735 "/Users/sean/clojure/fresh/./test.txt"]}


beholder officially uses for it's jars/release process. So that's probably the supported path.


That includes the install step too


The beholder project only seemed to have a :release alias so I wasn't sure what would be needed without also tracking down that library and learning about it 🙂


@jacob429 Hope the above gets you going...


I hadn't heard of it before, but searched for "release.edn" on github and it came up 🙂


Oh, so it's actually as simple as clj -M:release install


(pity there's no docs in beholder or its deps.edn file to make that clear since they're using a deps/release process that is not common/mainstream 🙂 )


Is there a standard release process yet? (depstar doesn't count)


I think depstar is the most widely used JAR builder for deps.edn-based projects currently? But I hope it will be able to go away once's uber task does more merging stuff.


I'd like to have deps.edn be my source of truth and use it to generate my pom.xml - is there a way to specify what should go in the <scm> tag? Right now cljdocs integration is broken because I don't have a source link in there.


Oh, I'm using depstar, btw, with :sync-pom true


@winsome that's why clj-new generates a fully-fledged pom.xml into new projects.


Can I use clj-new on an existing project, or is that just like lein new?


It's just like lein new. But you could use it to create a new project somewhere, with the same qualified project name that your current project has, and then copy the generated pom.xml file into your project.


I'm working on deps-new which will be able to overlay new files into existing projects (and is much, much simpler to write new templates for).


That sounds good, thanks. And deps-new is a great idea!


Adding a full-featured pom.xml file is a good new feature for deps-new -- I'll create an issue.


yeah, it's something I never think of until it's release time, which can be quite distant from creation time (never in most cases :p)

Jacob Emcken21:08:01

@dominicm Thanks clojure -M:release install seemed to work


is there a way to configure the clj/`clojure` commands globally so that we can apply a particular command line argument to all clj/`clojure` calls? for example, i would like to set --report stderr globally so that i don't have to change each and every existing call to these commands.


ok. thanks, Alex.

Alex Miller (Clojure team)22:08:54

in general, I think is better for the Clojure CLI as it composes better with main args and -X etc

Alex Miller (Clojure team)22:08:50

you could make an alias with :jvm-opts [""] that could be combined with any other alias

Alex Miller (Clojure team)22:08:59

this question is for default jvm opts if you want to vote for it (which would let you do the thing above more broadly)

Alex Miller (Clojure team)22:08:31

but I think adding such a thing needs much more consideration in how it combines


understood. i'll go with the alias approach for now as we already have :dev alias that's referenced at every call site to clojure. thank you.