Question

Can I control compiler options (optimizations, generation of debug info and so on) via Leiningen (project file)?

Is javac involved at some point or JVM code emitted by directly Clojure compiler? I want to make my uberjar as small and fast as possible.

Another close question is jvm-options. I am not familiar with Java, but seems like they make sense in case of run by Leiningen (via lein run) because uberjar executed directly by JVM and I control it's options: java -client <other options> -jar uberapp_uberjar.jar

Doc says I can use profiles. On my mac I can't find profile fiels in ~/.lein/. There is show-profiles command, is there command to show a profile?

Was it helpful?

Solution

There is a whole range of options you can set in the leiningen project.clj file, and java options of all sorts is part of this.

When I need to see what is possible I always look at this project.clj sample file on github

https://github.com/technomancy/leiningen/blob/master/sample.project.clj

I believe he have been relative good at keeping it up to date

OTHER TIPS

:javac-options can take any javac option.

For example:

(defproject com.example.foo/bar "0.1.0-SNAPSHOT"
:description
"Some awesome app."

:url "http://www.example.com"
:license {:name "" :url ""}
:dependencies [[org.clojure/clojure "1.5.1"]
               [org.clojure/clojure-contrib "1.2.0"]]

:aot [com.example.foo.core]
:main com.example.foo.core
:target-dir "target/"
:source-paths ["src"]
:compile-path "target/classes"
:javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options" "-g"])

The comment DaoWen posted is incorrect.

Clojure code is compiled on the fly into JVM bytecode as can be seen here.

As for your question, you can pass JVM options to leiningen in the project.clj file:

(defproject example "0.0.1"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :dependencies [[org.clojure/clojure "1.5.1"]
  :jvm-opts ["-javaagent:newrelic/newrelic.jar"]})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top