-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.clj
115 lines (99 loc) · 3.06 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
(ns build
(:require [clojure.tools.build.api :as b]
[deps-deploy.deps-deploy :as dd]
[clojure.pprint :as pprint]))
(def lib 'xfthhxk/kaiao)
(def version (format "0.1.%s" (b/git-count-revs nil)))
(def class-dir "target/classes")
(def jar-file "target/kaiao.jar")
(def uber-jar-file "target/kaiao-uber.jar")
(def clj-src-dirs ["src/clj"])
(def java-src-dirs ["src/java"])
(defn git-sha
[]
(b/git-process {:git-args "rev-parse --short HEAD"}))
(defonce ^:dynamic *basis* (delay nil))
(defn set-basis!
[m]
(let [d (-> {:project "deps.edn"}
(merge m)
b/create-basis
delay)]
(alter-var-root #'*basis* (constantly d))))
(set-basis! {})
(defn show-defaults [_]
(println "default-basis:")
(pprint/pprint @*basis*)
(println "target:" "target")
(println "class-dir:" class-dir)
(println "jar-file:" jar-file))
(defn clean [_]
(println "Cleaning ...")
(b/delete {:path "target"}))
(defn compile-clj [_]
(println "Compiling clj...")
(b/compile-clj {:src-dirs clj-src-dirs
:class-dir class-dir
:basis @*basis*}))
(defn- pom-template [version]
[[:description "Kaiao can be used to track in-app events for later analysis."]
[:url "https://github.com/xfthhxk/kaiao"]
[:licenses
[:license
[:name "MIT License"]
[:url "https://opensource.org/license/mit/"]]]
[:developers
[:developer
[:name "Amar Mehta"]]]
[:scm
[:url "https://github.com/xfthhxk/kaiao"]
[:connection "scm:git:https://github.com/xfthhxk/kaiao.git"]
[:developerConnection "scm:git:ssh:git@github.com:xfthhxk/kaiao.git"]
[:tag (str "v" version)]]])
(defn jar [_]
(clean nil)
(b/write-pom {:class-dir class-dir
:lib lib
:version version
:basis @*basis*
:src-dirs clj-src-dirs
:pom-data (pom-template version)})
(b/copy-dir {:src-dirs (conj clj-src-dirs "resources")
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-file}))
(defn uber
[{:keys [aliases] :as opts}]
(prn opts)
(let [aliases (remove nil? aliases)
m (cond-> {}
(seq aliases) (assoc :aliases aliases))]
(set-basis! m))
(clean nil)
(compile-clj nil)
(b/copy-dir {:src-dirs (conj clj-src-dirs "resources")
:target-dir class-dir})
(-> {:main 'kaiao.main
:manifest {"git-sha" (git-sha)}
:uber-file uber-jar-file
:src-dirs clj-src-dirs
:class-dir class-dir
:ns-compile '[kaiao.main]
:basis @*basis*}
(merge (dissoc opts :aliases))
b/uber))
(defn install [_]
(jar nil)
(println "Installing jar into local Maven repo cache...")
(b/install {:lib lib
:version version
:src-dirs clj-src-dirs}))
(defn deploy [_]
(dd/deploy {:installer :remote
:artifact (b/resolve-path jar-file)
:pom-file (b/pom-path {:lib lib
:class-dir class-dir})}))
(comment
(set-basis! {:aliases [:gcp]})
@*basis*
)