-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.clj
69 lines (60 loc) · 1.9 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
(ns build
"For help, run:
clojure -A:deps -T:build help/doc"
(:refer-clojure :exclude [test])
(:require
[clojure.tools.build.api :as b]
[deps-deploy.deps-deploy :as dd]))
(def lib 'org.clojars.greenlabs/tools.graphql)
(def version (format "1.0.%s" (b/git-count-revs nil)))
(def class-dir "target/classes")
(defn- pom-template
[version]
[[:description "Clojure tools for GraphQL"]
[:url "https://github.com/green-labs/tools.graphql"]
[:licenses
[:license
[:name "Apache License, Version 2.0"]
[:url "http://www.apache.org/licenses/LICENSE-2.0"]]]
[:scm
[:url "https://github.com/green-labs/tools.graphql"]
[:connection "scm:git:https://github.com/green-labs/tools.graphql.git"]
[:developerConnection "scm:git:ssh:[email protected]:green-labs/tools.graphql.git"]
[:tag (str "v" version)]]])
(def ^:private basis
(delay (b/create-basis {})))
(defn- jar-opts
[opts]
(println "Version:" version)
(assoc opts
:lib lib :version version
:jar-file (format "target/%s-%s.jar" lib version)
:basis @basis
:class-dir class-dir
:target "target"
:src-dirs ["src"]
:pom-data (pom-template version)))
(defn clean
[_]
(println "Removing target/ ...")
(b/delete {:path "target"}))
(defn build-jar
[opts]
(let [j-opts (jar-opts opts)]
(println "Writing pom.xml ...")
(b/write-pom j-opts)
(println "Copying source ...")
(b/copy-dir {:src-dirs ["src"] :target-dir class-dir})
(println "Building" (:jar-file j-opts) "...")
(b/jar j-opts)))
(defn deploy
"Build the jar and deploy it to Clojars. Expects env vars CLOJARS_USERNAME &
CLOJARS_PASSWORD."
[opts]
(clean opts)
(build-jar opts)
(let [{:keys [jar-file] :as opts} (jar-opts opts)]
(dd/deploy {:installer :remote
:artifact (b/resolve-path jar-file)
:pom-file (b/pom-path (select-keys opts [:lib :class-dir]))}))
opts)