-
Notifications
You must be signed in to change notification settings - Fork 57
Profiles
Leiningen profiles are used by lein-droid to customize the build type of the project (debug or release) and conditionally inject certain options into the project map.
Since version 0.3.x
it is discouraged to apply :base
and :user
profiles to your Android project. The primary reason for this is because
user
profile usually contains plenty of tooling dependencies that
wouldln’t, at best, work on Android, and at worst would crash your
application. To avoid this you put the following line into the :profiles
map (see sample project.clj):
:default [:dev]
This will override the default profile vector that contains :base
and
:user
.
You are free to devise any hierarchy of profiles that suits your project. Since 0.3.x lein-droid doesn’t explicitly tamper with your profiles and completely relies on Leiningen’s already powerful profile capabilities. Nevertheless, both the sample project and the template offer a simple profile hierarchy to get started.
Like in any Leiningen project, :dev
is a default profile that is used when
the application is developed. This profile contains development dependencies
(like nREPL) and compiles all namespaces on the classpath (including the
ones that are not used).
Profile to be used when building the final version of the application.
:release
doesn’t include extra dependencies, compiles only what’s
necessary, uses a separate keystore for signing your application (read
more).
This profile acts as a substitution for :user
profile which we don’t use.
You can put it into your profiles.clj
and define there options that you
would like to use across all :dev
profiles of your Clojure/Android
projects. For example, if you use CIDER it can look like this:
:android-user {:dependencies [[cider/cider-nrepl "0.8.0-SNAPSHOT"]]
:repl-options {:nrepl-middleware
[cider.nrepl.middleware.complete/wrap-complete
cider.nrepl.middleware.inspect/wrap-inspect
cider.nrepl.middleware.stacktrace/wrap-stacktrace
cider.nrepl.middleware.macroexpand/wrap-macroexpand
cider.nrepl.middleware.trace/wrap-trace
cider.nrepl.middleware.undef/wrap-undef]}}
Same as :android-user
, this is a system-wide profile that contains global
settings common for both :dev
and :release
profiles. For instance, it
can contain the path to Android SDK on your computer:
:android-common {:android {:sdk-path "/home/user/path/to/android-sdk"}}
So the difference between this profile and the previous one is that both
:dev
and :release
can inherit this profile, but only :dev
should
inherit :android-user
(because you probably don’t need CIDER in your
release version).
If you follow the template and sample project, :dev
profile will enabled be
default and you won’t have to do anything extra to execute commands with this
profile.
lein droid doall
To build the release version use the following command:
lein with-profile release droid doall
The with-profile
modifier allows you to chain subcommands like do
:
lein with-profile release droid build, droid apk
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*