This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
/
droid.clj
87 lines (80 loc) · 3.17 KB
/
droid.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
;; ## Clojure is simple. Android should also be.
;; This plugin is intended to make your Clojure/Android development as
;; seamless and efficient as when developing ordinar Clojure JVM programs.
;;
(ns leiningen.droid
(:refer-clojure :exclude [compile doall repl])
(:use [leiningen.clean :only [delete-file-recursively]]
[leiningen.core.project :only [merge-profiles unmerge-profiles]]
[leiningen.core.main :only [abort]]
[leiningen.help :only (subtask-help-for)]
[leiningen.droid.compile :only (compile code-gen)]
[leiningen.droid
[build :only [create-dex crunch-resources package-resources create-apk
sign-apk zipalign-apk apk build]]
[deploy :only [install run forward-port repl deploy]]
[new :only [new]]
[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)))
(defn foo
"This function just prints the project map."
[project & args]
(println project))
(defn doall
"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."
[project]
(let [release-project (-> project
(unmerge-profiles [:dev])
(merge-profiles [:release])
android-parameters)]
(delete-file-recursively (:compile-path project) :silently)
(build release-project)
(apk release-project)
(install release-project)))
(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]}
droid
"Supertask for Android-related tasks (see `lein droid` for list)."
([project]
(help #'droid))
([project & [cmd & args]]
(when (and (nil? project) (not (#{"new" "help"} cmd)))
(abort "This subtask requires to be run from the project folder."))
(case cmd
;; Standalone tasks
"new" (if (< (count args) 2)
(abort (wrong-usage "lein droid new" #'new))
(apply new args))
"code-gen" (code-gen project)
"compile" (compile project)
"create-dex" (create-dex project)
"crunch-resources" (crunch-resources project)
"package-resources" (package-resources project)
"create-apk" (create-apk project)
"sign-apk" (sign-apk project)
"zipalign-apk" (zipalign-apk project)
"install" (apply install project args)
"run" (apply run project args)
"forward-port" (apply forward-port project args)
"repl" (repl project)
;; Meta tasks
"build" (build project)
"apk" (apk project)
"deploy" (apply deploy project args)
"doall" (apply doall project args)
"release" (release project)
;; Help tasks
"foo" (foo project)
"help" (help #'droid))))