-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.clj
74 lines (59 loc) · 2.58 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
(ns build
(:require
[clojure.pprint :as pprint]
[clojure.tools.build.api :as build-api]))
;; ---------------------------------------------------------
;; Build configuration
(def project-config
"Project configuration to support all tasks"
(let [library-name 'practicalli/random-clojure-function
version (format "1.0.%s" (build-api/git-count-revs nil))]
{:library-name library-name
:main-namespace library-name
:project-version version
:class-directory "target/classes"
:project-basis (build-api/create-basis)
:jar-file (format "target/%s-%s.jar" (name library-name) version)
:uberjar-file (format "target/%s-%s-standalone.jar" (name library-name) version)}))
;; End of Build configuration
;; ---------------------------------------------------------
;; ---------------------------------------------------------
;; Build tasks
(defn clean
"Remove a directory
- `:path '\"directory-name\"'` for a specific directory
- `nil` (or no command line arguments) to delete `target` directory
`target` is the default directory for build artefacts"
[directory]
(build-api/delete {:path (or (:path directory) "target")}))
(defn jar
"Create a build of the project, cleaning existing build assets first"
[_]
(let [{:keys [class-directory jar-file library-name project-basis project-version]} project-config]
(clean nil)
(pprint/pprint project-config)
(build-api/write-pom {:class-dir class-directory
:lib library-name
:version project-version
:basis project-basis
:src-dirs ["src"]})
(build-api/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-directory})
(build-api/jar {:class-dir class-directory
:jar-file jar-file})))
(defn uberjar
"Create an archive containing Clojure and the build of the project"
[_]
(let [{:keys [class-directory main-namespace project-basis uberjar-file]} project-config]
(clean nil)
(build-api/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-directory})
(build-api/compile-clj {:basis project-basis
:src-dirs ["src"]
:class-dir class-directory})
(build-api/uber {:class-dir class-directory
:uber-file uberjar-file
:basis project-basis
:main main-namespace})))
;; End of Build tasks
;; ---------------------------------------------------------