-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.clj
138 lines (96 loc) · 2.31 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
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
(ns build
(:refer-clojure :exclude [test])
(:require
[clojure.pprint :as pprint]
[clojure.set :as set]
[clojure.tools.build.util.file :as file]
[org.corfield.build :as bb]))
(def defaults
{:src-dirs ["src/main/clojure"]
:resource-dirs ["src/main/resources"]
:lib 'team.sultanov/xtdb-tarantool
:target "target"
:coverage-dir "coverage"
:jar-file "target/xtdb-tarantool.jar"
:build-meta-dir "src/main/resources/xtdb-tarantool"})
(defn pretty-print
[x]
(binding [pprint/*print-right-margin* 130]
(pprint/pprint x)))
(defn with-defaults
[opts]
(merge defaults opts))
(defn extract-meta
[opts]
(-> opts
(select-keys [:lib
:version
:build-number
:build-timestamp
:git-url
:git-branch
:git-sha])
(set/rename-keys {:lib :module})
(update :module str)))
(defn write-meta
[opts]
(let [dir (:build-meta-dir opts)]
(file/ensure-dir dir)
(->> opts
(extract-meta)
(pretty-print)
(with-out-str)
(spit (format "%s/build.edn" dir)))))
(defn outdated
[opts]
(-> opts
(with-defaults)
(bb/run-task [:nop :outdated])))
(defn outdated:upgrade
[opts]
(-> opts
(with-defaults)
(bb/run-task [:nop :outdated :outdated/upgrade])))
(defn clean
[opts]
(-> opts
(with-defaults)
(bb/clean)))
(defn repl
[opts]
(let [opts (with-defaults opts)]
(write-meta opts)
(bb/run-task opts [:test :develop])))
(defn test
[opts]
(let [opts (with-defaults opts)]
(write-meta opts)
(bb/run-task opts [:test])))
(defn test:unit
[opts]
(let [opts (with-defaults opts)]
(write-meta opts)
(bb/run-task opts [:test :test/unit])))
(defn test:integration
[opts]
(let [opts (with-defaults opts)]
(write-meta opts)
(bb/run-task opts [:test :test/integration])))
(defn jar
[opts]
(let [opts (with-defaults opts)]
(write-meta opts)
(-> opts
(assoc :scm {:url (:git-url opts)
:tag (:version opts)})
(bb/jar))))
(defn install
[opts]
(-> opts
(with-defaults)
(bb/install)))
(defn deploy
[opts]
(-> opts
(with-defaults)
(bb/deploy)))