-
Notifications
You must be signed in to change notification settings - Fork 56
project.clj options
This page contains a detailed description of all project.clj
options
that are used by lein-droid.
A default project.clj
file that gets created with lein droid new
...
command has most of the necessary options defined, so the most of
the time you won’t have to change lein-droid related attributes much.
You can also explore a sample file which contains example uses of different lein-droid options.
This is where main and most relevant configuration options are. This option should itself be a map, which contents are described below.
This is similar to Leiningen’s own :aot
option. This could
either be:
- a list of namespaces to be AOT-compiled. List can contain strings for exact match, or regular expressions;
-
:all
to AOT-compile all used namespaces; -
:all-with-unused
to AOT-compile all namespaces.
:all-with-unused
is usually used with :dev
profile because you
want to have the complete libraries available while you are
developing. For :release
profile it is better to use :all
value because it compiles only those namespaces that are
necessary.
This should be a list of namespaces not to be AOT-compiled. List can contain
strings for exact match, or regular expressions, for example
:aot-exclude-ns [#"cljs-tooling\..+"]
. This option has priority over :aot
— namespaces will be excluded after the include list is calculated.
The list of directories which contain assets used by your application. By
default its value is ["./assets"]
.
By default lein-droid uses the latest version of Android Build
Tools from android-sdk-dir/build-tools/
. Use this option to
force a specific version to be used.
If it’s value is :release
, lein-droid will perform release-specific
operations. This option should be set in the :release
profile.
With this option you can pass additional arguments to dx
executable. We usually use it to give more memory to dx and force
use of multiple cores when building large projects like this:
["-JXmx4096M" "--num-threads=2"]
.
This options is a list of directories with classfiles, and JARs that you want to include in your classpath. It is inadvisable to use this option because it makes your project build environment-dependent. Consider deploying your JAR libraries to local Maven repository instead.
Directories in which to find additional resources. It is inadvisable to use this option, consider packaging your resource libraries into AARs and using them as dependencies.
If you still get errors during DEXing, even with increasing memory in
:dex-opts
, you can set this option to true. This will result in slower
DEXing during debug builds but may resolve the issue.
Setting this parameter to a vector of logging priorities will
force the respective logging methods from neko.log
namespace to
be completely ignored in the build. You can use this parameter,
for example, to elide all neko.log/d
calls from the release
build in compile time.
Available priorities: :verbose
, :debug
, :info
, :warning
,
:error
.
This option should be an alias of your key inside
:keystore-path
.
You should set this option only for the :release
profile, since
:dev
profile uses special debug key for signing applications.
It is better to set this option in ~/.lein/profiles.clj
for
better repeatability.
This options can contain a password to your key in the private keystore. It is not advised to use this option.
If not set, you will be asked for the password during release build which is a more secure method.
If you still decide to use this option, specify it in
~/.lein/profiles.clj
to avoid exposing your password.
This options should point at a keystore file for signing your release builds. Please consult this guide for more information on keys and application signing.
You should set this option only for the :release
profile, since
:dev
profile uses special debug key for signing applications.
It is better to set this option in ~/.lein/profiles.clj
for
better repeatability.
This option should be set to true if you are developing a Clojure/Android library that relies on Android SDK to be compiled and built.
Contains a map that will be passed to Clostache when rendering AndroidManifest.xml template file.
Path to the Mustache template file of project’s manifest file. Defaults to
AndroidManifest.template.xml
. You can also use a solid
AndroidManifest.xml
file here instead, if your manifest doesn’t require
any templating.
A list of native libraries to include into your application.
This option changes the application package name defined in manifest to the given string. Inside the application package stays the same. This allows to install several versions of the same application onto the device (for instance, have debug and release version simultaneously).
This option should be a port number that will be opened by nREPL on the Android device. By default it is set to 9999.
This option should be a port number which will be opened on your local machine to access the remote nREPL. By default it is set to 9999.
Path to resources folder. By default it is set to "./res"
.
A list of JARs which contain resources you want to include into your
application. Use this option only to include JVM-style resources (obtainable
with clojure.java.io/resource
), not the Android-style resources resources
(that need a record in R.java
). You can also include such resources from
:dependencies.
Its value should be a string that specifies the path to your
Android SDK. Its root path is where tools
, platform-tools
and
other directories are.
It is a good idea to set this option in ~/.lein/profiles.clj
file, in
:android-common profile. This way you won’t have to copy it into every
project, and it also make your project contain less environment-specific
parts.
If your release keystore uses signing algorithm different from
the default SHA1withRSA
, you can specify it using this
parameter. For example, if your keystore was generated using DSA,
you should set this parameter to SHA1withDSA
.
Set this option to true if you want to start nREPL server even in release
builds of your application. If so, don’t forget to include nrepl dependency
in :release
profile.
This options can contain a password to your private keystore. It is not advised to use this option.
If not set, you will be asked for the password during release build which is a more secure method.
If you still decide to use this option, specify it in
~/.lein/profiles.clj
to avoid exposing your password.
This option should be a number which specifies the version of Android API you want to target. You can see the mapping between version names and API numbers here.
You can also use a keyword instead of a number for certain SDK versions. Here’s the mapping:
Keyword | Version number |
---|---|
:ics |
15 |
:jelly-bean |
18 |
:kitkat |
19 |
:lollipop |
21 |
Force usage of debug keystore for signing the APK regardless of the :build-type option. Useful to test the release builds without having to enter release keystore credentials.
This options is the same like in every other project.clj
, it should contain
a vector of dependency definitions. If you want to include JVM-format
resources from certain dependency, add :use-resources true
to the
definition vector, like this:
:dependencies [[org.clojure-android/clojure "1.5.1-SNAPSHOT" :use-resources true]
...]
You can also use AAR dependencies here.
There are two main dependencies that are crucial for Clojure/Android development (you can get a working setup without them, but it won’t be much fun). First is org.clojure-android/clojure, which is a special Clojure build that enables dynamic compilation on Android. Apart from that there are no other changes, so consider which version to use the same as you do it for regular Clojure. Most of the time the latest version will do:
Neko is a primary library for CoA development. It initializes dynamic compilation and provides with various utilities for creating UI and using Android API. You can get Neko from Clojars as well:
Other dependencies are up to you, lein-droid allows you to use any
conventional Clojure libraries in your projects as long as they don’t require
any JVM-specific classes (like sun.*
package and the like).
If this option is set to true, lein-droid will act like a common Android build tool. Use this option for building Java-only AAR libraries.
A default project.clj
file in a Clojure-Android project contains
two profiles: :dev
and :release
. These two profiles contain
options specific to the debug and release builds respectively. For
example, :dev
profile contains nREPL dependency which release
build usually doesn’t need.
For more information check Profiles page. It also explains how to specify system-wide attributes for Clojure-Android projects.
This option is highly recommended to be enabled, since reflection on Android
is much slower than on JVM, and most initial performance problems with
Clojure/Android development come from unnoticed reflection cases. If
*warn-on-reflection*
is set to true, you will see them during project
compilation stage. The option looks like:
:global-vars {*warn-on-reflection* true}
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*