-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.clj
67 lines (56 loc) · 1.68 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
;; Based on the tools.build Guide's examples
;; https://clojure.org/guides/tools_build
;; https://clojure.github.io/tools.build/clojure.tools.build.api.html
(ns build
(:require [clojure.tools.build.api :as b]))
(def lib 'org.pilosus/dienstplan)
(def main 'dienstplan.core)
(def version (format "1.1.%s" (b/git-count-revs nil)))
(def class-dir "target/classes")
(def src-dirs ["src" "resources"])
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s-%s.jar" (name lib) version))
(def uber-file (format "target/uberjar/%s-%s-standalone.jar" (name lib) version))
(defn- build-opts
[opts]
(merge
{:class-dir class-dir
:lib lib
:version version
:basis basis
:src-dirs src-dirs
:target-dir class-dir ;; b/copy-dir specific
:jar-file jar-file ;; b/jar specific
:ns-compile [main] ;; b/compile-clj specific
:uber-file uber-file ;; b/uber specific
:main main ;; b/uber specific
}
opts))
(defn clean [_]
(println "Cleaning...")
(b/delete {:path "target"}))
(defn jar
[opts]
(let [opts' (build-opts opts)]
(println "Writing pom file...")
(b/write-pom opts')
(println "Copying files...")
(b/copy-dir opts')
(println "Creating jar...")
(b/jar opts')))
(defn uberjar
"Create an uberjar file with possible options override
Examples:
clojure -T:build uberjar
clojure -T:build uberjar :uber-file '\"target/app.jar\"'
"
[opts]
(clean nil)
(println "Building with options..." opts)
(let [opts' (build-opts opts)]
(println "Copying files...")
(b/copy-dir opts')
(println "Compiling...")
(b/compile-clj opts')
(println "Creating uberjar...")
(b/uber opts')))