-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.boot
221 lines (202 loc) · 7.28 KB
/
build.boot
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
(set-env!
:source-paths #{"src/clj" "src/cljc" "src/cljs" "src/less"}
:resource-paths #{"resources"}
:dependencies '[[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.9.946"]
[org.clojure/core.async "0.3.465"]
;; Build dependencies
[org.clojure/tools.namespace "0.3.0-alpha4" :scope "test"]
[org.clojure/tools.nrepl "0.2.12" :scope "test"]
[adzerk/boot-test "1.2.0" :scope "test"]
[adzerk/boot-cljs "2.1.4" :scope "test"]
[adzerk/boot-reload "0.5.2" :scope "test"]
[adzerk/boot-cljs-repl "0.3.3" :scope "test"]
[com.cemerick/piggieback "0.2.2" :scope "test"]
[weasel "0.7.0" :scope "test"]
[reloaded.repl "0.2.3" :scope "test"]
[binaryage/devtools "0.9.4" :scope "test"]
[tolitius/boot-check "0.1.6" :scope "test"]
[org.clojure/test.check "0.9.0" :scope "test"]
[onetom/boot-lein-generate "0.1.3" :scope "test"]
;; Documentation generator
[boot-codox "0.10.3" :scope "test"]
;; Other development dependencies
[org.danielsz/system "0.4.0"]
;; Project dependencies
[com.stuartsierra/component "0.3.2"]
[yogthos/config "0.8"]
[com.taoensso/sente "1.11.0"]
[compojure "1.5.0"]
[ring "1.5.0"]
[ring-middleware-format "0.7.2"]
[http-kit "2.2.0"]
[cljsjs/react-with-addons "15.5.4-0"]
[reagent "0.7.0" :exclusions [cljsjs/react]]
[re-frame "0.10.1"]
[re-frisk "0.4.5"]
[reanimated "0.5.3" :exclusions [cljsjs/react-with-addons]]
[secretary "1.2.3"]
[soda-ash "0.4.0" :exclusions [cljsjs/react]]
[cljsjs/plotly "1.30.0-0"]])
(require
'[boot.lein]
'[clojure.java.io :as io]
'[adzerk.boot-test :refer [test]]
'[adzerk.boot-cljs :refer [cljs]]
'[adzerk.boot-cljs-repl :refer [cljs-repl start-repl repl-env]]
'[adzerk.boot-reload :refer [reload]]
'[tolitius.boot-check :as check]
'[codox.boot :refer [codox]]
'[system.boot :refer [system run]]
'[beer-game.server :refer [server-system]])
;; Generate a leiningen config (project.clj) based on this
;; build file for tooling that does not support boot (cursive)
(boot.lein/generate)
(task-options!
pom {:project 'beer-game
:version "0.1.0"}
jar {:manifest {"author" "Maximilian Kuschewski"}
:main 'beer-game.server}
aot {:namespace #{'beer-game.server}})
(deftask dev-env
"Sets the environment variables and paths for the development environment."
[]
(set-env! :resource-paths #(conj % "environments/dev"))
(set-env! :source-paths #(conj % "environments/dev"))
identity)
(deftask test-env
[]
(set-env! :resource-paths #(conj % "environments/dev"))
(set-env! :source-paths #(conj % "test" "environments/dev"))
identity)
(deftask prod-env
"Sets the environment variables and paths for the produciton environment."
[]
(set-env! :resource-paths #(conj % "environments/prod"))
(set-env! :source-paths #(conj % "environments/prod"))
identity)
(deftask print-msg
"Prints given message when run."
[m message MESSAGE str "The message to be printed."]
(with-pre-wrap fileset
(println message)
fileset))
;; REQUIRES less-js and less-plugin-clean-css
;; npm install -g [email protected] [email protected]
(deftask less-js
"Compiles the less files using lessc,
because boot-less / less4j can't seem to handle compiling Semantic-UI.
(GC Overflow error)."
[i input INPUT_FILE str "The input file path"
o output OUTPUT_FILE str "The output file path"]
(let [todir (tmp-dir!)
prev-less (atom nil)]
(with-pre-wrap fileset
(let [file-extensions [".less" ".config" ".overrides"]
candidates (->> fileset
input-files
(by-ext file-extensions))
changed (->> fileset
(fileset-diff @prev-less)
input-files
(by-ext file-extensions))
in-file (first (by-path [input] candidates))
tmp-in (tmp-file in-file)
tmp-out (io/file todir output)]
(if-not (empty? changed)
(do
(empty-dir! todir)
(println (count changed) " changed files." "Compiling Less...")
(boot.util/dosh "lessc" (.getPath tmp-in) (.getPath tmp-out)
"--clean-css" "--s1 --advanced --compatibility=ie8")
(reset! prev-less fileset))
(println "No Less files to compile..."))
(-> fileset
(add-resource todir)
commit!)))))
(deftask less-only
"Task for testing the less-js task"
[]
(comp
(dev-env)
(watch :verbose true)
(less-js :input "site.less" :output "public/css/site.css")))
(deftask check-code
"Check the code using boot-check"
[]
(comp
(check/with-eastwood)
(check/with-kibit)
(check/with-bikeshed)))
(deftask auto-test
"Run the tests and watch files."
[c check bool "Whether to check the code"]
(let [test-fn
(comp
(test-env)
(watch)
(print-msg :message "Testing...")
(test))]
(if check
(comp (test-fn)
(print-msg :message "Checking Code...")
(check-code))
test-fn)))
(deftask dev
"Start a repl for development with auto-watching etc..."
[]
(comp
(dev-env)
(watch :verbose true)
(system :sys #'server-system :auto true)
(reload :on-jsload 'beer-game.core/mount-root)
(repl :server true)
(less-js :input "site.less" :output "public/css/site.css")
(cljs :source-map true :optimizations :none)
(notify :visual true
:audible false)))
(deftask doc
"Generates the documentation for the project."
[]
(let [version "master"
source-uri
"https://git.rz.uni-augsburg.de/pi-m/beer_game/blob/{version}/{filepath}#L{line}"]
(comp
(test-env)
(codox :name "beer-game.server"
:version version
:metadata {:doc/format :markdown}
:output-path "server"
:source-uri source-uri)
(codox :name "beer-game.client"
:version version
:metadata {:doc/format :markdown}
:output-path "client"
:language :clojurescript
:source-uri source-uri)
(target :dir #{"doc/code"}))))
(deftask auto-doc
"Watches the source files and continuously updates the documentation."
[]
(comp
(test-env)
(watch :verbose true)
(doc)))
(deftask package
[]
(comp
(prod-env)
(cljs :optimizations :advanced
:compiler-options {:pretty-print false
:preloads nil})
(less-js :input "site.less"
:output "public/css/site.css"
)
(aot)
(pom)
(uber)
(jar :file "beer-game.jar")
(sift :include #{#".*\.jar"})
(target)
(notify :audible true
:visual true)))