-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.clj
64 lines (56 loc) · 1.97 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
(ns build
(:refer-clojure :exclude [test])
(:require [clojure.tools.build.api :as b]
[clojure.tools.build.tasks.write-pom]
[deps-deploy.deps-deploy :as dd]))
(def default-opts
(let [url "https://github.com/clojure-goes-fast/clj-java-decompiler"
version "0.3.6"]
{;; Pom section
:lib 'com.clojure-goes-fast/clj-java-decompiler
:version version
:scm {:url url, :tag version}
:pom-data [[:description "Integrated Clojure-to-Java decompiler"]
[:url url]
[:licenses
[:license
[:name "Eclipse Public License"]
[:url "http://www.eclipse.org/legal/epl-v10.html"]]]]
;; Build section
:basis (b/create-basis {})
:target "target"
:class-dir "target/classes"}))
(defmacro opts+ [& body]
`(let [~'opts (merge default-opts ~'opts)]
~@body
~'opts))
(defn- jar-file [{:keys [target lib version]}]
(format "%s/%s-%s.jar" target (name lib) version))
(defn clean [opts] (b/delete {:path (:target (opts+))}))
;; 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 jar
"Compile and package the JAR."
[opts]
(opts+
(doto opts clean b/write-pom)
(let [{:keys [class-dir basis]} opts
jar (jar-file opts)]
(println (format "Building %s..." jar))
(b/copy-dir {:src-dirs (:paths basis)
:target-dir class-dir
:include "**"
:ignores [#".+\.java"]})
(b/jar (assoc opts :jar-file jar)))))
(defn deploy "Deploy the JAR to Clojars." [opts]
(opts+
(dd/deploy {:installer :remote
:artifact (b/resolve-path (jar-file opts))
:pom-file (b/pom-path opts)})))