Permalink
Browse files

Fix subtask docs

  • Loading branch information...
1 parent a442f8d commit e85a04535fca776c37cd7bd523bf7949c6e014d7 @alexander-yakushev alexander-yakushev committed Jun 19, 2012
Showing with 35 additions and 29 deletions.
  1. +8 −7 src/leiningen/droid.clj
  2. +23 −18 src/leiningen/droid/build.clj
  3. +4 −4 src/leiningen/droid/deploy.clj
@@ -17,24 +17,25 @@
[utils :only [proj wrong-usage android-parameters ensure-paths]]]))
(defn help
- "Shows the list of possible lein droid subtasks."
- [droid-var]
- (println (subtask-help-for "" droid-var)))
+ "Shows the list of possible `lein droid` subtasks."
+ ([]) ([droid-var]
+ (println "lein-droid is a plugin for Clojure/Android development."
+ (subtask-help-for nil droid-var))))
(defn foo
"This function just prints the project map."
[project & args]
(println project))
(defn doall
- "Performs all Android tasks from compilation to the deployment."
+ "Metatask. Performs all Android tasks from compilation to the deployment."
[project & device-args]
(doto project
build apk)
(apply deploy project device-args))
(defn release
- "Builds, packs and deploys the release version of the project."
+ "Metatask. Builds, packs and deploys the release version of the project."
[project]
(let [release-project (-> project
(unmerge-profiles [:dev])
@@ -48,8 +49,8 @@
(defn ^{:no-project-needed true
:subtasks [#'new #'code-gen #'compile #'create-dex #'crunch-resources
#'package-resources #'create-apk #'sign-apk #'zipalign-apk
- #'install #'run #'forward-port #'repl #'build #'apk #'doall
- #'help]}
+ #'install #'run #'forward-port #'repl #'build #'apk #'deploy
+ #'doall #'release #'help]}
droid
"Supertask for Android-related tasks (see `lein droid` for list)."
([project]
@@ -21,11 +21,10 @@
;; runtime that will be triggered when Leiningen is closed.
;;
(defn create-dex
- "Creates the DEX file from the compiled .class files. It is done by
- executing `dx` binary from Android SDK."
+ "Creates a DEX file from the compiled .class files."
[{{:keys [sdk-path out-dex-path]} :android,
compile-path :compile-path :as project}]
- (info "Creating dex...")
+ (info "Creating DEX....")
(ensure-paths sdk-path)
(let [dx-bin (str sdk-path "/platform-tools/dx")
annotations (str sdk-path "/tools/support/annotations.jar")
@@ -36,12 +35,14 @@
(.addShutdownHook (Runtime/getRuntime) (Thread. #(.destroy proc))))))
(defn build
- "Compiles all source files and creates a DEX-file."
+ "Metatask. Runs `compile`, `create-dex`."
[project]
(doto project compile create-dex))
(defn crunch-resources
- "Calls `aapt` binary with the _crunch_ task."
+ "Updates the pre-processed PNG cache.
+
+ Calls `aapt` binary with the _crunch_ task."
[{{:keys [sdk-path res-path out-res-path]} :android}]
(info "Crunching resources...")
(ensure-paths sdk-path res-path)
@@ -51,13 +52,13 @@
"-C" out-res-path)))
(defn package-resources
- "Calls `aapt` binary with the _package_ task.
+ "Packages application resources.
If this task is run with :dev profile, then it ensures that
- AndroidManifest.xml has Internet permission for running REPL. This
- is achieved by backing up the original manifest file and creating a
- new one with Internet permission appended to it. After the packaging
- the original manifest file is restored."
+ AndroidManifest.xml has Internet permission for running the REPL
+ server. This is achieved by backing up the original manifest file
+ and creating a new one with Internet permission appended to it.
+ After the packaging the original manifest file is restored."
[{{:keys [sdk-path target-version manifest-path assets-path res-path
out-res-path out-res-pkg-path]} :android :as project}]
(info "Packaging resources...")
@@ -85,8 +86,10 @@
(io/delete-file backup-file))))
(defn create-apk
- "Creates an APK file by running `apkbuilder` tool on the generated
- DEX-file and resource package."
+ "Creates an deployment-ready APK file.
+
+ It is done by running `apkbuilder` tool on the generated DEX-file
+ and the resource package."
[{{:keys [sdk-path out-apk-path out-res-pkg-path out-dex-path]} :android,
source-paths :source-paths, java-source-paths :java-source-paths
:as project}]
@@ -104,10 +107,11 @@
"-rj" (str clojure-jar))))
(defn sign-apk
- "Signs APK file with either a debug keystore key or a release key
- based on whether the build type is development one.
+ "Signs APK file with the key taken from the keystore.
- Creates a debug keystore if it is missing."
+ Either a debug keystore key or a release key is used based on
+ whether the build type is the debug one. Creates a debug keystore if
+ it is missing."
[{{:keys [out-apk-path keystore-path key-alias]} :android :as project}]
(info "Signing APK...")
(let [dev-build (dev-build? project)
@@ -128,7 +132,9 @@
unaligned-path key-alias)))
(defn zipalign-apk
- "Calls `zipalign` binary on APK file."
+ "Aligns resources locations on 4-byte boundaries in the APK file.
+
+ Done by calling `zipalign` binary on APK file."
[{{:keys [sdk-path out-apk-path]} :android :as project}]
(info "Aligning APK...")
(let [zipalign-bin (str sdk-path "/tools/zipalign")
@@ -142,8 +148,7 @@
(sh zipalign-bin "4" unaligned-path aligned-path)))
(defn apk
- "Crunches and packages resources, creates an APK file, signs and
- zip-aligns it."
+ "Metatask. Crunches and packages resources, creates, signs and aligns an APK."
[project]
(doto project
crunch-resources package-resources
@@ -69,8 +69,9 @@
(get-launcher-activity manifest-path))))
(defn forward-port
- "Binds a port on the local machine to the port on the device
- allowing to connect to the remote REPL."
+ "Binds a port on the local machine to the port on the device.
+
+ This allows to connect to the remote REPL from the current machine."
[{{:keys [adb-bin repl-device-port repl-local-port]} :android} & device-args]
(info "Binding device port" repl-device-port
"to local port" repl-local-port "...")
@@ -86,8 +87,7 @@
(launch-nrepl {:attach (str "localhost:" repl-local-port)}))
(defn deploy
- "Installs the APK to the device, executes it and forwards a port from
- the device to the local machine."
+ "Metatask. Runs `install, `run`, `forward-port`."
[{{:keys [adb-bin]} :android :as project} & device-args]
(let [device (get-device-args adb-bin device-args)]
(apply install project device)

0 comments on commit e85a045

Please sign in to comment.