-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.boot
122 lines (104 loc) · 4.1 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
(def +version+ "0.6.0")
(set-env!
:resource-paths #{"src"}
:source-paths #{"test" "test-resources"}
:dependencies '[[org.clojure/clojure "1.10.1" :scope "provided"]
[metosin/bat-test "0.4.3" :scope "test"]
[io.bit3/jsass "5.11.0"]
[cheshire "5.9.0"]
[org.webjars/webjars-locator "0.37"]
[hawk "0.2.11"]
[org.clojure/tools.cli "0.4.2"]
[com.stuartsierra/component "0.4.0" :scope "test"]
[suspendable "0.1.1" :scope "test"]
[integrant "0.7.0" :scope "test"]
;; Webjars-locator uses logging
[org.slf4j/slf4j-nop "1.7.29" :scope "test"]
;; For testing the webjars asset locator implementation
[org.webjars.bower/bootstrap "4.3.1" :scope "test"]
[org.webjars.bower/material-design-iconic-font "2.2.0" :scope "test"]
[org.webjars.bower/material-design-lite "1.3.0" :scope "test"]])
(require '[metosin.bat-test :refer [bat-test]])
(task-options!
pom {:version +version+
:url "https://github.com/deraen/sass4clj"
:scm {:url "https://github.com/deraen/sass4clj"}
:license {"Eclipse Public License" "http://www.eclipse.org/legal/epl-v10.html"}})
(defn with-files
"Runs middleware with filtered fileset and merges the result back into complete fileset."
[p middleware]
(fn [next-handler]
(fn [fileset]
(let [merge-fileset-handler (fn [fileset']
(next-handler (commit! (assoc fileset :tree (merge (:tree fileset) (:tree fileset'))))))
handler (middleware merge-fileset-handler)
fileset (assoc fileset :tree (reduce-kv
(fn [tree path x]
(if (p x)
(assoc tree path x)
tree))
(empty (:tree fileset))
(:tree fileset)))]
(handler fileset)))))
(deftask write-version-file
[n namespace NAMESPACE sym "Namespace"]
(let [d (tmp-dir!)]
(fn [next-handler]
(fn [fileset]
(let [f (clojure.java.io/file d (-> (name namespace)
(clojure.string/replace #"\." "/")
(clojure.string/replace #"-" "_")
(str ".clj")))]
(clojure.java.io/make-parents f)
(spit f (format "(ns %s)\n\n(def +version+ \"%s\")" (name namespace) +version+)))
(next-handler (-> fileset (add-resource d) commit!))))))
(deftask build []
(comp
(with-files
(fn [x] (and (re-find #"sass4clj" (tmp-path x))
(not (re-find #"leiningen" (tmp-path x)))))
(comp
(pom
:project 'deraen/sass4clj
:description "Clojure wrapper for jsass")
(jar)
(install)))
(with-files
(fn [x] (re-find #"boot_sass" (tmp-path x)))
(comp
(pom
:project 'deraen/boot-sass
:description "Boot task to compile SASS"
:dependencies [])
(write-version-file :namespace 'deraen.boot-sass.version)
(jar)
(install)))
(with-files
(fn [x] (re-find #"leiningen" (tmp-path x)))
(comp
(pom
:project 'deraen/lein-sass4clj
:description "Leinigen task to compile SASS"
:dependencies [])
(write-version-file :namespace 'leiningen.sass4clj.version)
(jar)
(install)))))
(deftask dev []
(comp
(watch)
(repl :server true)
(build)
(target)))
(deftask deploy []
(comp
(build)
(push :repo "clojars" :gpg-sign (not (.endsWith +version+ "-SNAPSHOT")))))
(ns-unmap *ns* 'test)
(deftask test []
(comp
(write-version-file :namespace 'sass4clj.version)
(bat-test :report 'eftest.report.pretty/report)))
(deftask autotest []
(comp
(watch)
(test)))