-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.clj
75 lines (66 loc) · 2.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
(ns build
(:require [clojure.tools.build.api :as b]
[deps-deploy.deps-deploy :as dd]))
(def lib 'org.clojars.lukaszkorecki/mokujin)
(def version-stable (format "1.0.0.%s" (b/git-count-revs nil)))
(defn version-snapshot [suffix] (format "%s-SNAPSHOT-%s" version-stable suffix))
(def class-dir "target/classes")
(defn jar-file [version] (format "target/%s-%s.jar" (name lib) version))
(def target "target")
;; delay to defer side effects (artifact downloads)
(def basis (delay (b/create-basis {:project "deps.edn"})))
(def ^:private pom-template
[[:description "A very thin wrapper around clojure.tools.logging which adds MDC support"]
[:url "https://github.com/lukaszkorecki/mokujin"]
[:licenses
[:license
[:name "MIT"]
[:url "https://opensource.org/license/mit/"]]]
[:scm
[:url "https://github.com/lukaszkorecki/mokujin"]
[:connection "scm:git:git://github.com/lukaszkorecki/mokujin.git"]
[:developerConnection "scm:git:ssh://git@github.com/lukaszkorecki/mokujin.git"]]])
(defn ^:private jar-opts
[{:keys [version] :as opts}]
(assoc opts
:lib lib
:version version
:jar-file (jar-file version)
:basis (b/create-basis)
:class-dir class-dir
:target target
:src-dirs ["src"]
:pom-data pom-template))
;; Tasks
(defn clean [_]
(b/delete {:path target}))
(defn jar
[{:keys [snapshot] :as _args}]
(let [{:keys [jar-file] :as opts} (jar-opts {:version (if snapshot
(version-snapshot snapshot)
version-stable)})]
(println (format "Cleaning '%s'..." target))
(b/delete {:path "target"})
(println (format "Writing 'pom.xml'..."))
(b/write-pom opts)
(println (format "Copying source files to '%s'..." class-dir))
(b/copy-dir {:src-dirs ["src" "resources"] :target-dir class-dir})
(println (format "Building JAR to '%s'..." jar-file))
(b/jar opts)
(println "Finished.")))
(defn install
[{:keys [snapshot]}]
(let [{:keys [jar-file] :as opts} (jar-opts {:version (if snapshot
(version-snapshot snapshot)
version-stable)})]
(dd/deploy {:installer :local
:artifact (b/resolve-path jar-file)
:pom-file (b/pom-path (select-keys opts [:lib :class-dir]))})))
(defn publish
[{:keys [snapshot]}]
(let [{:keys [jar-file] :as opts} (jar-opts {:version (if snapshot
(version-snapshot snapshot)
version-stable)})]
(dd/deploy {:installer :remote
:artifact (b/resolve-path jar-file)
:pom-file (b/pom-path (select-keys opts [:lib :class-dir]))})))