-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.clj
72 lines (64 loc) · 2.02 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
(ns build
(:refer-clojure :exclude [compile])
(:require [clojure.tools.build.api :as b]
[deps-deploy.deps-deploy :as dd]))
(def lib 'dev.dotfox/jsonista.jcs)
(defn- the-version
([patch] (the-version patch false))
([patch snapshot?] (str "1.0." patch (when snapshot? "-SNAPSHOT"))))
(def version (the-version (b/git-count-revs nil)))
(def snapshot (the-version (b/git-count-revs nil) true))
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
(defn clean [opts]
(println "Cleaning target directory...")
(b/delete {:path "target"})
opts)
(defn compile [opts]
(println "Compiling java sources...")
(b/javac {:src-dirs ["src/java"]
:class-dir class-dir
:basis basis
:javac-opts ["-source" "8" "-target" "8"]})
opts)
(defn- jar-opts [opts]
(let [version (if (:snapshot opts) snapshot version)]
(assoc opts
:lib lib
:version version
:jar-file jar-file
:scm {:tag (str "v" version)}
:basis (b/create-basis {})
:class-dir class-dir
:target "target"
:src-dirs ["src/clj" "src/java" "target/classes"]
:src-pom "pom.xml")))
(defn jar [opts]
(let [opts (jar-opts opts)]
(println "Writing pom.xml...")
(b/write-pom opts)
(println "Copying source...")
(b/copy-dir {:src-dirs ["src/clj" "src/java"] :target-dir class-dir})
(println "Building JAR...")
(b/jar opts)
opts))
(defn deploy [opts]
(let [{:keys [jar-file installer] :as opts} (jar-opts opts)]
(dd/deploy {:installer installer
:artifact (b/resolve-path jar-file)
:pom-file (b/pom-path (select-keys opts [:lib :class-dir]))})))
(defn deploy-remote [opts]
(-> opts
(clean)
(compile)
(jar)
(assoc :installer :remote)
(deploy)))
(defn deploy-local [opts]
(-> opts
(clean)
(compile)
(jar)
(assoc :installer :local)
(deploy)))