6

I was trying to do some simple scripting work with Clojure. For example, I would load a json which contains a map from a file, remove a given key, and save it back to the file. With leiningen, seems I would have to create an app, add data.json or whatever into the dependencies, then I could start a lein repl to do the real work. Think about doing the same thing with Python. It should be done with 3 lines of code in Python. Is there an easy way to do it with leiningen?

3
  • You don't have to use lein, but t helps with setting up application structure. I've used lein for so long, I don't know how to hand compile Clojure and run it, but there are probably examples out there. Commented May 27, 2013 at 22:02
  • 1
    The jvm makes using clojure for things like this very inconvenient, because of the startup time (and ram usage if you work around the startup time with a pool of waiting jvms). Commented May 27, 2013 at 23:15
  • You can run a single JVM instance using Nailgun (github.com/martylamb/nailgun), load Clojure to it, and serve requests in a client-server manner (over localhost). Commented May 28, 2013 at 6:49

2 Answers 2

12

You can try out the lein-oneoff plugin which was made for situations like these (I'm the author). It lets you declare dependencies and write code in a single file, avoiding the need to generate a proper leiningen project.

Sign up to request clarification or add additional context in comments.

Comments

7

You can use lein-exec.

To add a bit more info, I wrote up some notes on standalone scripts with Clojure.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.