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 Jun 22, 2015 · 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. The example of using different profiles is shown in sample project.clj.

Omitting default profiles

It is discouraged to apply :base and :user profiles to your Android project, because :user profile usually contains plenty of tooling dependencies that, at best, wouldn’t work on Android, and at worst would crash your application. To avoid this put the following line into the :profiles map of project.clj:

:default [:dev]

This will override the default profile vector that contains :base and :user.

Lein-droid’s proposed profiles

Lein-droid doesn’t explicitly tamper with project’s profiles, doesn’t rely on them having specific names, but instead uses Leiningen’s already powerful profile inheritance capabilities. So you are free to devise any hierarchy of profiles that suits your project. Nevertheless, both the sample project and the template offer a simple profile hierarchy to get you started.

:dev

Like in any Leiningen project, :dev is a default profile that is used while 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 yet).

:release

Profile to be used when building the final version of the application. :release doesn’t include extra dependencies, compiles only what’s necessary and 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 define it in profiles.clj and put in there options that you would like to use across all :dev profiles of your Clojure/Android projects. For example, it can contain CIDER-related configuration.

:android-common

Similar to :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.

Using the profiles

If you follow the architecture from template or sample project, :dev profile will be enabled by 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 subtasks using do:

lein with-profile release do droid build, droid apk