-
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. The example of using different profiles is shown in sample project.clj.
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, 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:
:default [:dev]
This will override the default profile vector that contains :base
and
:user
.
Since 0.3.x lein-droid doesn’t explicitly tamper with project’s profiles, doesn’t rely on them having specific names and completely relies on 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.
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).
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).
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, 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]}}
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
(because you probably don’t need CIDER in your
release version).
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 subcommands using do
:
lein with-profile release do 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*