Lean compilation

Alexander Yakushev edited this page Jan 31, 2016 · 8 revisions

Lein-droid supports lean compilation mode via Project Skummet. This gives much faster load time and smaller APK size/memory footprint for your Clojure-Android applications.

Howto

Insert the following profile into :profiles map of your project.clj:

:lean
[:release
 {:dependencies ^:replace [[org.skummet/clojure "1.7.0-r1"]
                           [neko/neko "4.0.0-alpha5"]]
  :exclusions [[org.clojure/clojure]
               [org.clojure-android/clojure]]
  :jvm-opts ["-Dclojure.compile.ignore-lean-classes=true"]
  :global-vars ^:replace {clojure.core/*warn-on-reflection* true}
  :android {:lean-compile true
            :proguard-execute true
            :proguard-conf-path "build/proguard-minify.cfg"}}]

Latest Skummet version:

https://clojars.org/org.skummet/clojure/latest-version.svg

Here we define a new profile called :lean that inherits from :release profile. It replaces the dependency list with the one having a special Skummet dependency. The following :exclusions make sure that regular Clojure does not get included from dependencies. :jvm-opts line is just necessary. :globar-vars is added here because *warn-on-reflection* Var has to be namespace-qualified with Skummet. :lean-compile parameter is also just necessary. :proguard-... options enable Proguard which reduces the APK size and memory footprint.

NB: To use Proguard you must have exactly JDK7 installed. JDK8 is not supported by Proguard.

After you include and customize this profile, you can build your application with:

lein with-profile lean do clean, droid doall

Example

There is an example of Skummet usage in the sample project.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.