-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.clj
58 lines (52 loc) · 1.86 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
(ns build
(:require
[babashka.fs :refer [copy-tree]]
[babashka.process :refer [shell]]
[clojure.string :as string]
[clojure.tools.build.api :as b])
(:import
[java.nio.file FileAlreadyExistsException]))
(defn build-cljs []
(println "npx shadow-cljs release app...")
(let [{:keys [exit], :as s}
(shell "npx shadow-cljs release app -v")]
(when-not (zero? exit)
(throw (ex-info "could not compile cljs" s)))
(copy-tree "target/classes/cljsbuild/public" "target/classes/public")
(try
(copy-tree "target/classes/public/js" "resources/public/js")
(catch FileAlreadyExistsException e (println e)))))
(def lib 'cwithmichael/what-can-u-eat)
(def main-cls (string/join "." (filter some? [(namespace lib) (name lib) "core"])))
(def version (format "0.0.1-SNAPSHOT"))
(def target-dir "target")
(def class-dir (str target-dir "/" "classes"))
(def uber-file (format "%s/%s-standalone.jar" target-dir (name lib)))
(def basis (b/create-basis {:project "deps.edn"}))
(defn clean
"Delete the build target directory"
[_]
(println (str "Cleaning " target-dir))
(b/delete {:path target-dir}))
(defn prep [_]
(println "Writing Pom...")
(b/write-pom {:class-dir class-dir
:lib lib
:version version
:basis basis
:src-dirs ["src/clj"]})
(b/copy-dir {:src-dirs ["src/clj" "resources" "env/prod/resources" "env/prod/clj"]
:target-dir class-dir}))
(defn uber [_]
(println "Compiling Clojure...")
(b/compile-clj {:basis basis
:src-dirs ["src/clj" "resources" "env/prod/resources" "env/prod/clj"]
:class-dir class-dir})
(build-cljs)
(println "Making uberjar...")
(b/uber {:class-dir class-dir
:uber-file uber-file
:main main-cls
:basis basis}))
(defn all [_]
(do (clean nil) (prep nil) (uber nil)))