-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.clj
54 lines (47 loc) · 1.6 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
(ns build
(:refer-clojure :exclude [test])
(:require [clojure.string :as str]
[clojure.tools.build.api :as b]
clojure.tools.build.tasks.write-pom
[org.corfield.build :as bb]))
(defmacro opts+ []
`(assoc ~'opts
:lib 'com.clojure-goes-fast/event-passport
:version "0.1.0"
:resource-dirs ["res" "vendor"]
:src-pom "res/pom-template.xml"))
(defn javac [opts]
(b/javac (assoc (#'bb/jar-opts (opts+))
:javac-opts ["-source" "8" "-target" "8"])))
;; Hack to propagate scope into pom.
(alter-var-root
#'clojure.tools.build.tasks.write-pom/to-dep
(fn [f]
(fn [[_ {:keys [mvn/scope]} :as arg]]
(let [res (f arg)
alias (some-> res first namespace)]
(cond-> res
(and alias scope) (conj [(keyword alias "scope") scope]))))))
(defn test "Run all the tests." [opts]
(bb/clean opts)
(javac (assoc opts :src-dirs ["src" "test"]))
(bb/run-tests (cond-> opts
(:clj opts) (assoc :aliases [(:clj opts)])))
opts)
(defn jar
"Compile and package the JAR."
[opts]
(bb/clean opts)
(javac opts)
(let [{:keys [class-dir src+dirs] :as opts} (#'bb/jar-opts (opts+))]
(b/write-pom opts)
(b/copy-dir {:src-dirs src+dirs
:target-dir class-dir
:include "**"
:ignores [#"pom-template.xml" #".+\.java"]})
(println "Building jar...")
(b/jar opts)))
(defn deploy "Deploy the JAR to Clojars." [opts]
(bb/deploy (opts+)))
;; To recompile Java class at runtime:
;; ((requiring-resolve 'virgil/compile-java) ["src"])