-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.clj
67 lines (58 loc) · 2 KB
/
build.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
(ns build
(:refer-clojure :exclude [test])
(:require [clojure.tools.build.api :as b] ; for b/git-count-revs
[org.corfield.build :as bb]
[clojure.spec.alpha :as spec]
[clojure.tools.deps.specs :as deps-specs]
))
(def lib 'ont-app/vocabulary)
(def version "0.4.2")
(defn validate-deps
"Throws an `ex-info` of type `::invalid-deps`, or returns `opts` unchanged"
[opts]
(println "Validating deps.edn...")
(let [deps (-> "deps.edn" (slurp) (read-string))
]
(when (not (spec/valid? ::deps-specs/deps-map deps))
(throw (ex-info "Invalid deps.edn"
{:type ::invalid-deps.edn
::spec/problems (-> (spec/explain-data ::deps-specs/deps-map deps)
::spec/problems
)
})))
(println "deps.edn conforms to clojure.tools.deps.specs")
opts))
(defn test "Run the tests." [opts]
(bb/run-tests opts))
(defn ci "Run the CI pipeline of tests (and build the JAR)." [opts]
(-> opts
(assoc :lib lib :version version)
(bb/run-tests)
(bb/clean)
(bb/jar)))
(defn clean "Cleans any clj/s compilation output.
Where:
`opts` := `m` s.t. (keys m) may match #{:include-caches?, ...}
`include-caches?` when truthy indicates to clear .cpcache and .shadow-cljs directories.
"
[opts]
(println (str "Cleaning with opts:" opts "."))
;; TODO: check opts
(bb/clean opts)
(b/delete {:path "./out"})
(b/delete {:path "./cljs-test-runner-out"})
(when (:include-caches? opts)
(println (str "Clearing caches"))
(b/delete {:path "./.cpcache"})
(b/delete {:path "./.shadow-cljs"}))
opts)
(defn install "Install the JAR locally." [opts]
(-> opts
(assoc :lib lib :version version)
(bb/install)))
(defn deploy
"Deploy the JAR to Clojars. Using $CLOJARS_USERNAME and $CLOJARS_PASSWORD"
[opts]
(-> opts
(assoc :lib lib :version version)
(bb/deploy)))