forked from mentat-collective/emmy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.clj
92 lines (80 loc) · 2.67 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
(ns build
"tools.build declarations for the emmy library."
(:require [clojure.tools.build.api :as b]))
;; ## Variables
(def lib 'org.mentat/emmy)
(def version (slurp "resources/EMMY_VERSION"))
(defn- ->version
([] version)
([suffix]
(if suffix
(format "%s-%s" version suffix)
version)))
;; source for jar creation.
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(defn ->jar-file [version]
(format "target/%s-%s.jar" (name lib) version))
;; ## Tasks
(defn clean [opts]
(println "\nCleaning target...")
(b/delete {:path "target"})
opts)
(defn jar
"Builds a jar containing all library code and
Optionally supply a string via `:version-suffix` to append `-<suffix>` to the
generated version."
[{:keys [version-suffix] :as opts}]
(let [version (->version version-suffix)
jar-file (->jar-file version)]
(b/write-pom
{:class-dir class-dir
:lib lib
:version version
:scm
{:tag (str "v" version)
:connection "scm:git:git://github.com/mentat-collective/emmy.git"
:developConnection "scm:git:ssh://git@github.com/mentat-collect/emmy.git"
:url "https://github.com/mentat-collective/emmy"}
:basis basis
:src-pom "template/pom.xml"
:src-dirs ["src"]
:resource-dirs ["resources"]})
(doseq [f ["README.md" "LICENSE" "deps.edn"]]
(b/copy-file {:src f :target (format "%s/%s" class-dir f)}))
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-file})
(println (str "Created " jar-file "."))
(assoc opts
:jar-file jar-file
:built-jar-version version)))
(defn install
"Clean, generate a jar and install the jar into the local Maven repository."
[opts]
(clean opts)
(let [{:keys [built-jar-version jar-file]} (jar opts)]
(b/install {:class-dir class-dir
:lib lib
:version built-jar-version
:basis basis
:jar-file jar-file})
(println (str "Installed " jar-file " to local Maven repository."))
opts))
(defn publish
"Generates a jar with all project sources and resources and publishes it to
Clojars."
[opts]
(clean opts)
(let [{:keys [jar-file]} (jar opts)]
(println (str "Publishing " jar-file " to Clojars!"))
((requiring-resolve 'deps-deploy.deps-deploy/deploy)
(merge {:installer :remote
:sign-releases? false
:artifact jar-file
:pom-file (b/pom-path {:lib lib :class-dir class-dir})}
opts))
;; TODO put a catch here if the version already exists?
(println "Published.")
opts))