-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.boot
215 lines (187 loc) · 7.17 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
(set-env!
:source-paths #{"src/java" "src/clj" "src/cljs"}
:resource-paths #{"resources"}
:format-paths #{"src/clj" "build.boot" "test"}
:format-regex #"\.(?:clj[sx]?|boot)$"
:dependencies '[[adzerk/boot-test "1.1.1" :scope "test"]
[org.clojure/clojure "1.8.0"]
[commons-io "2.4"]
[org.slf4j/slf4j-log4j12 "1.7.18"]
[clj-time "0.11.0"]
[commons-collections/commons-collections "3.2.2"]
[compojure "1.5.0"]
[ring "1.4.0"]
[org.optaplanner/optaplanner-core "6.4.0.Final" :exclusions [commons-io commons-codec]]
[ring/ring-defaults "0.2.0"]
[org.clojure/tools.namespace "0.3.0-alpha3"]
[org.danielsz/system "0.3.1" :exclusions [http-kit]]
[de.ubercode.clostache/clostache "1.4.0"]
[com.taoensso/sente "1.8.1"]
[environ "1.0.2"]
[boot-environ "1.0.2"]
[org.clojure/java.jdbc "0.4.2"]
[lobos "1.0.0-beta3" :exclude [org.clojure/java.jdbc]]
[org.xerial/sqlite-jdbc "3.8.11.2"]
[korma "0.4.2"]
[http-kit "2.3.0"]
[bouncer "1.0.0"]
[ring/ring-json "0.4.0"]
[org.clojure/data.json "0.2.6"]
[danlentz/clj-uuid "0.1.6"]
[ring/ring-mock "0.3.0" :scope "test"]
[peridot "0.4.3" :scope "test"]
[com.h2database/h2 "1.4.191"]
[postgresql "9.3-1102.jdbc41"]
[cljfmt "0.5.0"]
[me.raynes/fs "1.4.6"]
[juxt/dirwatch "0.2.3"]
[org.clojure/clojurescript "1.8.40"]
[reagent "0.6.0-alpha"]
[org.webjars/bootstrap "4.0.0-alpha.2"]
[deraen/boot-sass "0.2.1"]
[cljs-ajax "0.5.4"]
[cljsjs/jquery "2.2.2-0"]
[cljsjs/jquery-daterange-picker "0.0.8-0"]
[cljsjs/jquery-timepicker "1.8.10-0"]
[secretary "1.2.3"]
[com.andrewmcveigh/cljs-time "0.4.0"]
[adzerk/boot-cljs "1.7.228-1" :scope "test"]
[ajchemist/boot-figwheel "0.5.0-2"] ;; latest release
[com.cemerick/piggieback "0.2.1" :scope "test"]
[figwheel-sidecar "0.5.0-2" :scope "test"]
[org.clojure/tools.nrepl "0.2.12"]
[figwheel-sidecar/figwheel-sidecar "0.5.2"]])
(require '[adzerk.boot-test :refer [test]]
'[adzerk.boot-cljs :refer [cljs]]
'[system.repl :refer [init start stop go reset]]
'[environ.boot :refer [environ]]
'[system.boot :refer [system run]]
'[herder.systems :refer [dev-system prod-system]]
'[boot-figwheel]
'[deraen.boot-sass :refer [sass]])
(refer 'boot-figwheel :rename '{cljs-repl fw-cljs-repl})
(deftask build []
(comp
(javac)
(aot :namespace '#{herder.solver.helpers})
(aot :namespace '#{herder.solver.event herder.solver.person herder.solver.slot herder.solver.solution})))
(require '[cljfmt.core :refer [reformat-string]]
'[clojure.java.io :as io]
'[juxt.dirwatch :refer [watch-dir close-watcher]]
'[clojure.string :as str])
(defn reformat-str [s]
(cljfmt.core/reformat-string s {}))
(defn fix-path [{:keys [file action]}]
(let [path (.getAbsolutePath file)
matches-path (-> boot.pod/env :format-paths ((partial filter #(str/includes? path %))) empty? not)
matches-regex (-> boot.pod/env :format-regex (#(re-find % path)) nil? not)]
(if (and matches-path matches-regex)
(let [original (slurp file)
revised (reformat-str original)]
(if (not= original revised)
(spit file revised))))))
(defonce watcher (atom nil))
(deftask fix
[]
(with-pre-wrap [fs]
(if-let [old-watcher @watcher]
(close-watcher old-watcher))
(reset! watcher (watch-dir fix-path (io/file ".")))
fs))
(deftask make-solver []
(comp
(build)
(target "target")))
(deftask testing
[]
(set-env! :source-paths #(conj % "test"))
identity)
(deftask tests []
(comp
(make-solver)
(testing)
(test)))
(task-options!
figwheel {:build-ids ["dev"]
:all-builds [{:id "dev"
:compiler {:main 'herder.core
:output-to "resources/public/js/herder.js"
:output-dir "resources/public/js"
:asset-path "/static/js"}
:figwheel {:build-id "dev"
:on-jsload 'herder.core/mount-root
:heads-up-display true
:autoload true
:debug false}}]
:figwheel-options {:repl true
:http-server-root "resources/public/"}})
(deftask run-figwheel []
(with-pre-wrap [fs]
(start-figwheel!)
fs))
(deftask dev-clj []
(comp
(fix)
(make-solver)
(watch :verbose true)
(testing)
(test)))
(deftask kill-pods []
(with-pre-wrap [fs]
(doseq [pod (->> boot.pod/pods (map key))
:let [name (.getName pod)
allowed ["worker" "core" "deraen.boot-sass" "boot.pod"]]]
(if (not (.contains allowed name))
(do
(println "Killing " name)
(boot.pod/destroy-pod pod))
(println "Not killing " name)))
fs))
(deftask dev []
(comp
(fix)
(build)
(environ :env {:http-port "3000"})
(figwheel)
(run-figwheel)
(sift
:add-jar {'cljsjs/jquery-daterange-picker #"^cljsjs/common/jquery-daterange-picker.inc.css$"
'cljsjs/jquery-timepicker #"^cljsjs/common/jquery-timepicker.inc.css$"}
:move {#"cljsjs/common/(jquery-daterange-picker.inc.css)" "resources/public/css/$1"
#"cljsjs/common/(jquery-timepicker.inc.css)" "resources/public/css/$1"})
(watch)
(sass)
(sift :move {#"herder/sass/(.*)" "resources/public/css/$1"})
(build)
(target :no-clean true)
(system :sys #'dev-system :auto true :files ["lobos.clj" "handler.clj" "solver.clj" "systems.clj" "run.clj" "rules.drl"])
(testing)
(test)
(kill-pods)))
(deftask prod-build []
(comp
(build)
(cljs :ids #{"herder"})
(sift
:add-jar {'cljsjs/jquery-daterange-picker #"^cljsjs/common/jquery-daterange-picker.inc.css$"
'cljsjs/jquery-timepicker #"^cljsjs/common/jquery-timepicker.inc.css$"}
:move {#"cljsjs/common/(jquery-daterange-picker.inc.css)" "resources/public/css/$1"
#"cljsjs/common/(jquery-timepicker.inc.css)" "resources/public/css/$1"
#"herder.js" "resources/public/js/herder.js"
#"herder.out/(.*)" "resources/public/js/herder.out/$1"})
(sass)
(sift :move {#"herder/sass/(.*)" "resources/public/css/$1"})
(target :no-clean true)))
(deftask fix-classpath []
(with-pre-wrap [fs]
(set-env! :resource-paths #(conj % "target"))
fs))
(deftask prod-run []
(comp
(fix-classpath)
(system :sys #'prod-system :auto true)
(wait)))
(deftask watch-tests []
(comp
(watch)
(tests)))