(ns build "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" (:require [clojure.tools.build.api :as b] [clojure.tools.deps.alpha :as t])) (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)) (defn clean "Remove the target folder." [_] (println "\nCleaning target...") (b/delete {:path "target"})) (defn jar "Build the library JAR file." [_] (println "\nWriting pom.xml...") (b/write-pom {:class-dir class-dir :lib lib :version version :scm {:tag (str "v" version)} :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})) (defn run-tests "Run regular tests." [_] (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"]}) {:keys [exit]} (b/process cmds)] (when-not (zero? exit) (throw (ex-info "Tests failed" {}))))) (defn ci "Run the CI pipeline of tests (and build the JAR)." [opts] (-> opts (run-tests) (clean) (jar)))