-
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;
-
: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. Most
of the time this lists consists of Clojure’s own namespaces that
use JVM-specific classes. As of Clojure 1.5, excluded namespaces
are clojure.parallel
and clojure.core.reducers
.
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 different 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"]
.
By default, :dev
profile has this option enabled and in
:release
it is disabled. You can set this option to true in
:release
profile if you use dynamic compilation as your
application’s feature (and not just for REPL development).
This options is a list of directories with classfiles, and JARs that you want to include in your classpath. Use this only for libraries that aren’t available in Maven repositories and Clojars since it makes your project build environment-dependent.
Directories in which to find additional resources.
If you still get errors during DEXing, even with :dex-opts
changed liberally, 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
.
A list of native libraries to include into your application.
This should contain a list of paths to project you want to use as dependencies.
Dependency projects are used for libraries which contain resources you want to use in your application, e.g. ActionBarSherlock library.
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. It is usually and by default "./res"
in
your project root.
A list of JARs which contain resources you want to include into your application.
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. 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
.
Same as :enable-dynamic-compilation
, 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.
Its value should be a vector of strings which describe support libraries’ versions that should be included into your project. Currently there are five support libraries:
v4
v7-appcompat
v7-gridlayout
v7-mediarouter
v13
N.B.: I’m not sure if v7-* libraries will work this way since they
additionally have resources to be included. Most probably, to use
v7 support libraries you’ll have to include them as
:project-dependencies
.
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 |
---|---|
:froyo |
8 |
:gingerbread |
10 |
:honeycomb |
13 |
:ics |
15 |
:jelly-bean |
17 |
Set this option to true if you intend to use additional Google APIs like Maps or Google Play Services.
This options is the same like in every other project.clj
, it
should contain a vector of dependency definitions. If you want to
include 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]
...]
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).
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.
If this option is set to true, lein-droid will act like a common Android build tool. Use this option if for some reason you want to use lein-droid for building your regular Java/Android applications.
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.
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*