-
Notifications
You must be signed in to change notification settings - Fork 57
Lean compilation
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.
Insert the following profile into :profiles
map of your project.clj
:
:lean
[:release
{:dependencies ^:replace [[org.skummet/clojure-android "1.7.0-alpha5-r1" :use-resources true]
[neko/neko "3.2.0-preview3" :exclusions [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
:skummet-skip-vars ["#'neko.init/init"
"#'neko.context/context"
"#'neko.resource/package-name"
"#'neko.-utils/keyword->static-field"
"#'neko.-utils/keyword->setter"
"#'neko.ui.traits/get-display-metrics"
"#'test.leindroid.sample.main/MainActivity-onCreate"
"#'test.leindroid.sample.main/MainActivity-init"]}}]
Latest Skummet version:
Here we define a new profile called :lean
that inherits from
:release
profile. It overrides dependencies vector with its own one, where
Clojure is replaced with special Skummet jar, and also Clojure dependency is
excluded from Neko. You should do this for every dependency you include in
your project, because you can’t have both Clojure and Skummet on your
classpath. :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.
:skummet-skip-vars
is a list of Vars that should not be lean-compiled.
Besides the given list of Neko vars you should include there all gen-classed
methods (like the shown -onCreate
, init
etc) and other Vars that you
reference directly in one way or another.
After you include and customize this profile, you can build your application with:
lein with-profile lean do clean, droid doall
There is an example of Skummet usage in the sample project.
Tutorial
- Installation
- Creating a new project
- Quick start
- Libraries and dependencies
- Editors and IDEs
- Troubleshooting
Profiles
Lean compilation
Multi-DEX project
Creating AAR libraries
Hacking the plugin
project.clj options
-
:android
- :aot
- :aot-exclude-ns
- :assets-paths
- :build-tools-version
- :build-type
- :dex-opts
- :external-classes-paths
- :external-res-paths
- :force-dex-optimize
- :ignore-log-priority
- :key-alias
- :keypass
- :keystore-path
- :lean-compile
- :library
- :manifest-options
- :manifest-template-path
- :multi-dex
- :multi-dex-proguard-conf-path
- :native-libraries-paths
- :proguard-execute
- :proguard-conf-path
- :rename-manifest-package
- :repl-device-port
- :repl-local-port
- :res-path
- :resource-jars-paths
- :sdk-path
- :sigalg
- :skummet-skip-vars
- :start-nrepl-server
- :storepass
- :target-version
- :use-debug-keystore
- :dependencies
- :java-only
- :profiles
- *warn-on-reflection*