diff --git a/build.clj b/build.clj index afb009e..92feb29 100644 --- a/build.clj +++ b/build.clj @@ -10,78 +10,31 @@ clojure -A:deps -T:build help/doc" (:require [clojure.tools.build.api :as b] - [clojure.tools.deps.alpha :as t] - [deps-deploy.deps-deploy :as dd])) + [org.corfield.build :as bb])) (def lib 'com.github.seancorfield/honeysql) (def version (format "2.0.%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 readme "Run the README tests." [opts] + (-> opts (bb/run-task [:readme]))) -(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-task - [aliases] - (println "\nRunning task for:" aliases) - (let [basis (b/create-basis {:aliases aliases}) - combined (t/combine-aliases basis aliases) - cmds (b/java-command {:basis basis - :java-opts (:jvm-opts combined) - :main 'clojure.main - :main-args (:main-opts combined)}) - {:keys [exit]} (b/process cmds)] - (when-not (zero? exit) - (throw (ex-info (str "Task failed for: " aliases) {}))))) - -(defn readme "Run the README tests." [opts] (run-task [:readme]) opts) - -(defn eastwood "Run Eastwood." [opts] (run-task [:eastwood]) opts) - -(defn run-tests - "Run regular tests. - - Optionally specify :aliases: - [:1.9] -- test against Clojure 1.9 (the default) - [:1.10] -- test against Clojure 1.10.3 - [:master] -- test against Clojure 1.11 master snapshot - [:cljs] -- test against ClojureScript" - [{:keys [aliases] :as opts}] - (run-task (into [:test] aliases)) - opts) +(defn eastwood "Run Eastwood." [opts] + (-> opts (bb/run-task [:eastwood]))) (defn ci "Run the CI pipeline of tests (and build the JAR)." [opts] (-> opts + (assoc :lib lib :version version) (readme) (eastwood) (as-> opts (reduce (fn [opts alias] - (run-tests (assoc opts :aliases (cond-> [alias] - (not= :cljs alias) - (conj :runner))))) + (bb/run-tests (assoc opts :aliases [alias]))) opts [:cljs :1.9 :1.10 :master])) - (clean) - (jar))) + (bb/clean) + (bb/jar))) (defn deploy "Deploy the JAR to Clojars." [opts] - (dd/deploy (merge {:installer :remote :artifact jar-file - :pom-file (b/pom-path {:lib lib :class-dir class-dir})} - opts))) + (-> opts + (assoc :lib lib :version version) + (bb/deploy))) diff --git a/deps.edn b/deps.edn index 965e1f6..e1e97de 100644 --- a/deps.edn +++ b/deps.edn @@ -3,8 +3,8 @@ :deps {org.clojure/clojure {:mvn/version "1.9.0"}} :aliases {;; for help: clojure -A:deps -T:build help/doc - :build {:deps {io.github.clojure/tools.build {:git/tag "v0.1.9" :git/sha "6736c83"} - io.github.slipset/deps-deploy {:sha "b4359c5d67ca002d9ed0c4b41b710d7e5a82e3bf"}} + :build {:deps {io.github.seancorfield/build-clj + {:git/tag "v0.1.0" :git/sha "fe2d586"}} :ns-default build} ;; versions to test against: @@ -20,8 +20,6 @@ :exec-fn cognitect.test-runner.api/test} ;; various "runners" for tests/CI: - :runner - {:main-opts ["-m" "cognitect.test-runner"]} :cljs {:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}} :main-opts ["-m" "cljs-test-runner.main"]} :readme {:extra-deps {seancorfield/readme {:mvn/version "1.0.16"}}