-
Notifications
You must be signed in to change notification settings - Fork 56
Hacking the plugin
This documents explains how to setup an environment where you can modify lein-droid, experiment with it, implement new features, fix bugs etc.
leiningen.droid
is a facade namespace for all other lein-droid subtasks. It
is responsible for adding different defaults to the project map by calling
leininingen.droid.utils/android-parameters
, before it passes the project
map to the subtasks.
leiningen.droid.aar
contains functions that operate on AAR archives. AAR is
a special packaging format for Android libraries that combines compiled code
and resources. Lein-droid must first unzip AAR dependencies before they can
be used.
leininged.droid.classpath
initializes several hooks that modify Leiningen
behavior in certain ways. For example, there is a hook that adds a proper
android.jar
to the classpath every time get-classpath
is called; a hook
for removing duplicate dependencies from the project etc.
leiningen.droid.(code-gen|compile|build|deploy)
mostly consist of subtasks
and helper functions that bring the project the whole way from clean target
to a deployed application.
leiningen.droid.manifest
hosts functions that operate on
AndroidManifest.xml
and its templates, create and parse manifests.
leiningen.droid.new
namespace is a home to new
subtask that creates new
Clojure-Android projects from a template. Template resources live in
res/templates/ directory.
leiningen.droid.sideload
is an utility namespace that allows to dynamically
load some tooling libraries that can only be obtained from SDK directory, and
exposes functionality of those libraries via reflection.
leiningen.droid.test
provides a subtask for running local tests in
Clojure-Android projects.
leiningen.droid.utils
contains general-purpose utilities which are used by
other namespaces.
You can develop lein-droid using CIDER or any other REPL provider. If
used with CIDER, you’d have to comment :eval-in-leiningen true
line, and
add [leiningen "2.5.1"]
to the dependencies (this is a workaround for a
bug in Leiningen). Now you can jack into the plugin.
Another way to use the development plugin is to set some environment
variables (LEIN_DROID_PROFILES and LEIN_DROID_PROJECT) and run
the lein droid ...
commands from the plugin folder. To make sure that
lein-droid is loaded from sources and not from the packaged jar from Clojars:
- Determine which profile(s) to use (e.g. dev) and the full path to a Clojure on Android project.
- Call
lein droid ...
subtasks fromlein-droid/
directory with the environment variables LEIN_DROID_PROFILES and LEIN_DROID_PROJECT set appropriately. This way sources of the plugin will be loaded and used.
For example (assuming lein-droid and foreclojure-android source directories live under ~/src):
cd ~/src/lein-droid
LEIN_DROID_PROFILES=dev \ LEIN_DROID_PROJECT=$HOME/src/foreclojure-android/project.clj \ lein do clean, droid clean, droid doall
Now you are able to execute lein-droid subtasks from lein-droid/
folder
like you do from your project folder, and using the latest changes you’ve
made to the plugin. But to do that you’ll have to have :eval-in-leiningen
true
in lein-droid (i.e. plugin)’s project.clj
, so you must
comment/uncomment that line every time you restart a REPL.
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*