-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.clj
57 lines (49 loc) · 1.85 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
(ns build
(:require [clojure.string :as str]
[clojure.tools.build.api :as b]
[deps-deploy.deps-deploy :as d]
[clojure.tools.deps :as t]))
(def lib 'io.github.runeanielsen/typesense-clj)
(def version (format "0.1.%s" (b/git-count-revs nil)))
(def class-dir "target/classes")
(def jar-file (format "target/%s-%s.jar" (name lib) version))
;; delay to defer side effects (artifact downloads)
(def basis (delay (b/create-basis {:project "deps.edn"})))
(def pom-template
[[:description "Clojure HTTP client for Typesense "]
[:url "https://github.com/runeanielsen/typesense-clj/"]
[:licenses
[:license
[:name "MIT"]
[:url "https://github.com/runeanielsen/typesense-clj/blob/master/LICENSE"]]]
[:developers
[:developer
[:name "Rune Andreas Nielsen"]]]])
(defn- run-task [aliases]
(println "\nRunning task for" (str/join "," (map name aliases)))
(let [basis (b/create-basis {:aliases aliases})
combined (t/combine-aliases basis aliases)
cmds (b/java-command
{:basis basis
:main 'clojure.main
:main-args (:main-opts combined)})
{:keys [exit]} (b/process cmds)]
(when-not (zero? exit) (throw (ex-info "Task failed" {})))))
(defn clean [_]
(b/delete {:path "target"}))
(defn build [_]
(b/write-pom {:pom-data pom-template
:class-dir class-dir
:lib lib
:version version
:basis @basis
:src-dirs ["src"]})
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-file}))
(defn tests [_]
(run-task [:test :runner]))
(defn deploy [_]
(d/deploy {:installer :remote :artifact (b/resolve-path jar-file)
:pom-file (b/pom-path {:class-dir class-dir :lib lib})}))