2021-08-01 23:21:31 +00:00
|
|
|
(ns build
|
2021-08-13 02:43:04 +00:00
|
|
|
"next.jdbc's build script.
|
|
|
|
|
|
|
|
|
|
clojure -T:build run-tests
|
|
|
|
|
|
|
|
|
|
clojure -T:build ci
|
|
|
|
|
|
|
|
|
|
For more information, run:
|
|
|
|
|
|
|
|
|
|
clojure -A:deps -T:build help/doc"
|
2021-08-03 03:41:43 +00:00
|
|
|
(:require [clojure.tools.build.api :as b]
|
|
|
|
|
[clojure.tools.deps.alpha :as t]))
|
2021-08-01 23:21:31 +00:00
|
|
|
|
2021-08-03 03:23:24 +00:00
|
|
|
(def lib 'com.github.seancorfield/next.jdbc)
|
|
|
|
|
(def version (format "1.2.%s" (b/git-count-revs nil)))
|
|
|
|
|
(def class-dir "target/classes")
|
|
|
|
|
(def basis (b/create-basis {:project "deps.edn"}))
|
|
|
|
|
(def jar-file (format "target/%s-%s.jar" (name lib) version))
|
|
|
|
|
|
2021-08-13 02:43:04 +00:00
|
|
|
(defn clean "Remove the target folder." [_]
|
2021-08-03 03:41:43 +00:00
|
|
|
(println "\nCleaning target...")
|
2021-08-03 03:23:24 +00:00
|
|
|
(b/delete {:path "target"}))
|
|
|
|
|
|
2021-08-13 02:43:04 +00:00
|
|
|
(defn jar "Build the library JAR file." [_]
|
2021-08-03 03:41:43 +00:00
|
|
|
(println "\nWriting pom.xml...")
|
2021-08-03 03:23:24 +00:00
|
|
|
(b/write-pom {:class-dir class-dir
|
|
|
|
|
:lib lib
|
|
|
|
|
:version version
|
2021-08-13 23:10:59 +00:00
|
|
|
:scm {:tag (str "v" version)}
|
2021-08-03 03:23:24 +00:00
|
|
|
:basis basis
|
|
|
|
|
:src-dirs ["src"]})
|
|
|
|
|
(println "Copying src...")
|
|
|
|
|
(b/copy-dir {:src-dirs ["src"]
|
|
|
|
|
:target-dir class-dir})
|
|
|
|
|
(println (str "Building jar " jar-file "..."))
|
|
|
|
|
(b/jar {:class-dir class-dir
|
|
|
|
|
:jar-file jar-file}))
|
|
|
|
|
|
2021-08-13 02:43:04 +00:00
|
|
|
(defn run-tests "Run regular tests." [_]
|
2021-08-03 03:41:43 +00:00
|
|
|
(let [basis (b/create-basis {:aliases [:test]})
|
|
|
|
|
combined (t/combine-aliases basis [:test])
|
|
|
|
|
cmds (b/java-command {:basis basis
|
|
|
|
|
:java-opts (:jvm-opts combined)
|
|
|
|
|
:main 'clojure.main
|
|
|
|
|
:main-args ["-m" "cognitect.test-runner"]})
|
2021-08-03 03:23:24 +00:00
|
|
|
{:keys [exit]} (b/process cmds)]
|
|
|
|
|
(when-not (zero? exit)
|
|
|
|
|
(throw (ex-info "Tests failed" {})))))
|
|
|
|
|
|
2021-08-13 02:43:04 +00:00
|
|
|
(defn ci "Run the CI pipeline of tests (and build the JAR)." [opts]
|
2021-08-03 03:23:24 +00:00
|
|
|
(-> opts (run-tests) (clean) (jar)))
|