3
votes

Context

If I want Lein 1.7 to start out with a particular class loaded, I do:

:repl-init init.init

Now, instead of having lein load up a *.clj file, I want lein to do the equiv of "java Foo", where Foo is classes/Foo.class

Question:

My project.clj look alike:

(defproject ...
  :aot [Foo]
  ???? )

What do I put in ???? to make "lein repl" startup by executing "java Foo" ?

Thanks!

1

1 Answers

4
votes

If I understand your question, you can still use :repl-init for this by having a call to the class you want pre-loaded in a namespace that gets loaded by the repl. in this example i'm using println statement as a standin for the setup you want done :-)

project.clj:

(defproject foooo "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.3.0"]]
  :aot [foooo.core]
  :main foooo.core
  :repl-init foooo.core)

core.clj

(ns foooo.core
  (:gen-class))
(println "setting up for fun")

(defn -main [])

compiling: arthur@a:~/foooo$ lein compile Compiling foooo.core Compilation succeeded.

running:

arthur@a:~/foooo$ CLASSPATH=./lib/clojure-1.3.0.jar:./classes/ java foooo.core 1
setting up for fun

or:

arthur@a:~/foooo$ lein run
setting up for fun

REPLing:

arthur@a:~/foooo$ lein repl
REPL started; server listening on localhost port 63392
setting up for fun
foooo.core=>