forked from k2n/saml20-clj
-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.clj
86 lines (73 loc) · 2.38 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
(ns build
(:require [clojure.java.shell :as sh]
[clojure.pprint :as pprint]
[clojure.string :as str]
[clojure.tools.build.api :as b]
[deps-deploy.deps-deploy :as dd]))
(def scm-url "git@github.com:metabase/saml20-clj.git")
(def github-url "https://github.com/metabase/saml20-clj/")
(def lib 'metabase/saml20-clj)
(def major-minor-version (str/trim (slurp "VERSION.txt")))
(defn commit-number []
(or (-> (sh/sh "git" "rev-list" "HEAD" "--count")
:out
str/trim
parse-long)
"9999-SNAPSHOT"))
(def version (str major-minor-version \. (commit-number)))
(def target "target")
(def class-dir "target/classes")
(def jar-file (format "target/%s-%s.jar" lib version))
(def sha
(or (not-empty (System/getenv "GITHUB_SHA"))
(not-empty (-> (sh/sh "git" "rev-parse" "HEAD")
:out
str/trim))))
(def pom-template
[[:description "A library for delightful database interaction."]
[:url github-url]
[:licenses
[:license
[:name "Eclipse Public License"]
[:url "http://www.eclipse.org/legal/epl-v10.html"]]]
[:developers
[:developer
[:name "Cam Saul"]]]
[:scm
[:url github-url]
[:connection (str "scm:git:" scm-url)]
[:developerConnection (str "scm:git:" scm-url)]
[:tag sha]]])
(def default-options
{:lib lib
:version version
:jar-file jar-file
:basis (b/create-basis {})
:class-dir class-dir
:target target
:src-dirs ["src"]
:pom-data pom-template})
(defn build [opts]
(let [opts (merge default-options opts)]
(b/delete {:path target})
(println "\nWriting pom.xml...")
(b/write-pom opts)
(println "\nCopying source...")
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(printf "\nBuilding %s...\n" jar-file)
(b/jar opts)
(println "Done.")))
(defn install [opts]
(printf "Installing %s to local Maven repository...\n" version)
(b/install (merge default-options opts)))
(defn build-and-install [opts]
(build opts)
(install opts))
(defn deploy [opts]
(let [opts (merge default-options opts)]
(printf "Deploying %s...\n" jar-file)
(dd/deploy {:installer :remote
:artifact (b/resolve-path jar-file)
:pom-file (b/pom-path (select-keys opts [:lib :class-dir]))})
(println "Done.")))