|
10 | 10 |
|
11 | 11 | clojure -A:deps -T:build help/doc"
|
12 | 12 | (:refer-clojure :exclude [test])
|
13 |
| - (:require [clojure.tools.build.api :as b] |
14 |
| - [org.corfield.build :as bb])) |
| 13 | + (:require [clojure.string :as str] |
| 14 | + [clojure.tools.build.api :as b] |
| 15 | + [clojure.tools.deps :as t] |
| 16 | + [deps-deploy.deps-deploy :as dd])) |
15 | 17 |
|
16 | 18 | (def lib 'com.github.seancorfield/expectations)
|
17 | 19 | (defn- the-version [patch] (format "2.0.%s" patch))
|
18 | 20 | (def version (the-version (b/git-count-revs nil)))
|
19 | 21 | (def snapshot (the-version "999-SNAPSHOT"))
|
| 22 | +(def class-dir "target/classes") |
20 | 23 |
|
21 | 24 | (defn run-tests "Run the tests."
|
22 | 25 | [{:keys [aliases] :as opts}]
|
23 |
| - (-> opts |
24 |
| - (cond-> |
25 |
| - (some #{:humane :cljs} aliases) |
26 |
| - (assoc :main-opts ["-e" ":negative"])) |
27 |
| - (bb/run-tests))) |
| 26 | + (println "\nRunning tests for" (str/join ", " (map name aliases)) "...") |
| 27 | + (let [basis (b/create-basis {:aliases (into [:test] aliases)}) |
| 28 | + combined (t/combine-aliases basis (into [:test] aliases)) |
| 29 | + cmds (b/java-command |
| 30 | + {:basis basis |
| 31 | + :main 'clojure.main |
| 32 | + :main-args (cond-> (:main-opts combined) |
| 33 | + (some #{:humane :cljs} aliases) |
| 34 | + (into ["-e" ":negative"]))}) |
| 35 | + {:keys [exit]} (b/process cmds)] |
| 36 | + (when-not (zero? exit) (throw (ex-info "Tests failed" {})))) |
| 37 | + opts) |
28 | 38 |
|
29 | 39 | (defn test "Run all the tests." [opts]
|
30 | 40 | (reduce (fn [opts alias]
|
31 | 41 | (run-tests (assoc opts :aliases [alias])))
|
32 | 42 | opts
|
33 |
| - (cond-> [:1.9 :1.10 :master :humane] |
| 43 | + (cond-> [:1.9 :1.10 :1.11 :master :humane] |
34 | 44 | (:cljs opts)
|
35 | 45 | (conj :cljs)))
|
36 | 46 | opts)
|
37 | 47 |
|
38 |
| -(defn ci |
39 |
| - "Run the CI pipeline of tests (and build the JAR). |
| 48 | +(defn- jar-opts [opts] |
| 49 | + (let [version (if (:snapshot opts) snapshot version)] |
| 50 | + (assoc opts |
| 51 | + :lib lib :version version |
| 52 | + :jar-file (format "target/%s-%s.jar" lib version) |
| 53 | + :scm {:tag (str "v" version)} |
| 54 | + :basis (b/create-basis {}) |
| 55 | + :class-dir class-dir |
| 56 | + :target "target" |
| 57 | + :src-dirs ["src"] |
| 58 | + :src-pom "template/pom.xml"))) |
40 | 59 |
|
41 |
| - Specify :cljs true to run the ClojureScript tests as well." |
42 |
| - [opts] |
43 |
| - (-> opts |
44 |
| - (assoc :lib lib :version (if (:snapshot opts) snapshot version)) |
45 |
| - (test) |
46 |
| - (bb/clean) |
47 |
| - (assoc :src-pom "template/pom.xml") |
48 |
| - (bb/jar))) |
| 60 | +(defn ci "Run the CI pipeline of tests (and build the JAR)." [opts] |
| 61 | + (test opts) |
| 62 | + (b/delete {:path "target"}) |
| 63 | + (let [opts (jar-opts opts)] |
| 64 | + (println "\nWriting pom.xml...") |
| 65 | + (b/write-pom opts) |
| 66 | + (println "\nCopying source...") |
| 67 | + (b/copy-dir {:src-dirs ["resources" "src"] :target-dir class-dir}) |
| 68 | + (println "\nBuilding JAR...") |
| 69 | + (b/jar opts)) |
| 70 | + opts) |
49 | 71 |
|
50 | 72 | (defn deploy "Deploy the JAR to Clojars." [opts]
|
51 |
| - (-> opts |
52 |
| - (assoc :lib lib :version (if (:snapshot opts) snapshot version)) |
53 |
| - (bb/deploy))) |
| 73 | + (let [{:keys [jar-file] :as opts} (jar-opts opts)] |
| 74 | + (dd/deploy {:installer :remote :artifact (b/resolve-path jar-file) |
| 75 | + :pom-file (b/pom-path (select-keys opts [:lib :class-dir]))})) |
| 76 | + opts) |
0 commit comments