-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.boot
104 lines (91 loc) · 3.58 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
(def +version+ "0.5.1-SNAPSHOT")
(set-env!
:resource-paths #{"src" "boot-less/src" "lein-less4j/src"}
:source-paths #{"test" "test-resources"}
:dependencies '[[org.clojure/clojure "1.7.0" :scope "provided"]
[boot/core "2.5.2" :scope "provided"]
[adzerk/boot-test "1.0.7" :scope "test"]
;; Webjars-locator uses logging
[org.slf4j/slf4j-nop "1.7.12" :scope "test"]
[com.github.sommeri/less4j "1.17.2"]
[com.github.sommeri/less4j-javascript "0.0.1" :exclusions [com.github.sommeri/less4j]]
[org.webjars/webjars-locator "0.29"]
;; For testing the webjars asset locator implementation
[org.webjars/bootstrap "3.3.6" :scope "test"]])
(require '[adzerk.boot-test :refer [test]])
(task-options!
pom {:version +version+
:url "https://github.com/deraen/less4clj"
:scm {:url "https://github.com/deraen/less4clj"}
: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] (re-find #"less4clj" (tmp-path x)))
(comp
(pom
:project 'deraen/less4clj
:description "Clojure wrapper for Less4j.")
(jar)
(install)))
(with-files
(fn [x] (re-find #"boot_less" (tmp-path x)))
(comp
(pom
:project 'deraen/boot-less
:description "Boot task to compile {less}"
:dependencies [])
(write-version-file :namespace 'deraen.boot-less.version)
(jar)
(install)))
(with-files
(fn [x] (re-find #"leiningen" (tmp-path x)))
(comp
(pom
:project 'deraen/lein-less4j
:description "Leinigen task to compile {less}"
:dependencies [])
(write-version-file :namespace 'leiningen.less4j.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")))))
(deftask run-tests []
(comp
(test :namespaces #{'less4clj.core-test 'less4clj.webjars-test})))