Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Profiles

Alexander Yakushev edited this page Oct 24, 2014 · 7 revisions

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.

Omitting default profiles

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.

Lein-droid’s proposed profiles

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.

:dev

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).

:release

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).

:android-user

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]}}

:android-common

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).

Using the profiles

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