drop use of build-clj

This commit is contained in:
Sean Corfield 2023-01-23 23:29:52 -08:00
parent 22f259e897
commit 6ab8c6452b
2 changed files with 64 additions and 35 deletions

View file

@ -13,19 +13,36 @@
clojure -A:deps -T:build help/doc" clojure -A:deps -T:build help/doc"
(:refer-clojure :exclude [test]) (:refer-clojure :exclude [test])
(:require [clojure.tools.build.api :as b] (:require [clojure.string :as str]
[org.corfield.build :as bb])) [clojure.tools.build.api :as b]
[clojure.tools.deps :as t]
[deps-deploy.deps-deploy :as dd]))
(def lib 'com.github.seancorfield/honeysql) (def lib 'com.github.seancorfield/honeysql)
(defn- the-version [patch] (format "2.4.%s" patch)) (defn- the-version [patch] (format "2.4.%s" patch))
(def version (the-version (b/git-count-revs nil))) (def version (the-version (b/git-count-revs nil)))
(def snapshot (the-version "999-SNAPSHOT")) (def snapshot (the-version "999-SNAPSHOT"))
(def class-dir "target/classes")
(defn- run-task [aliases]
(println "\nRunning task for" (str/join "," (map name 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 "Task failed"))))
(defn eastwood "Run Eastwood." [opts] (defn eastwood "Run Eastwood." [opts]
(-> opts (bb/run-task [:eastwood]))) (run-task [:eastwood])
opts)
(defn gen-doc-tests "Generate tests from doc code blocks." [opts] (defn gen-doc-tests "Generate tests from doc code blocks." [opts]
(-> opts (bb/run-task [:gen-doc-tests]))) (run-task [:gen-doc-tests])
opts)
(defn run-doc-tests (defn run-doc-tests
"Generate and run doc tests. "Generate and run doc tests.
@ -38,18 +55,28 @@
[:cljs] -- test against ClojureScript" [:cljs] -- test against ClojureScript"
[{:keys [aliases] :as opts}] [{:keys [aliases] :as opts}]
(gen-doc-tests opts) (gen-doc-tests opts)
(bb/run-tests (assoc opts :aliases (run-task (-> [:test :test-doc]
(-> [:test-doc]
(into aliases) (into aliases)
(into (if (some #{:cljs} aliases) (into (if (some #{:cljs} aliases)
[:test-doc-cljs] [:test-doc-cljs]
[:test-doc-clj]))))) [:test-doc-clj]))))
opts) opts)
(defn test "Run basic tests." [opts] (defn test "Run basic tests." [opts]
(-> opts (run-task [:test :1.11])
(update :aliases (fnil conj []) :1.11) opts)
(bb/run-tests)))
(defn- jar-opts [opts]
(let [version (if (:snapshot opts) snapshot version)]
(assoc opts
:lib lib :version version
:jar-file (format "target/%s-%s.jar" lib version)
:scm {:tag (str "v" version)}
:basis (b/create-basis {})
:class-dir class-dir
:target "target"
:src-dirs ["src"]
:src-pom "template/pom.xml")))
(defn ci (defn ci
"Run the CI pipeline of tests (and build the JAR). "Run the CI pipeline of tests (and build the JAR).
@ -57,25 +84,25 @@
Default Clojure version is 1.9.0 (:1.9) so :elide Default Clojure version is 1.9.0 (:1.9) so :elide
tests for #409 on that version." tests for #409 on that version."
[opts] [opts]
(-> opts (let [aliases [:cljs :elide :1.10 :1.11 :master]
(bb/clean) opts (jar-opts opts)]
(assoc :lib lib :version (if (:snapshot opts) snapshot version)) (b/delete {:path "target"})
(as-> opts (doseq [alias aliases]
(reduce (fn [opts alias] (run-doc-tests {:aliases [alias]}))
(run-doc-tests (assoc opts :aliases [alias]))) (eastwood opts)
opts (doseq [alias aliases]
[:cljs :elide :1.10 :1.11 :master])) (run-task [:test alias]))
(eastwood) (b/delete {:path "target"})
(as-> opts (println "\nWriting pom.xml...")
(reduce (fn [opts alias] (b/write-pom opts)
(bb/run-tests (assoc opts :aliases [alias]))) (println "\nCopying source...")
opts (b/copy-dir {:src-dirs ["src"] :target-dir class-dir})
[:cljs :elide :1.10 :1.11 :master])) (println "\nBuilding JAR...")
(bb/clean) (b/jar opts))
(assoc :src-pom "template/pom.xml") opts)
(bb/jar)))
(defn deploy "Deploy the JAR to Clojars." [opts] (defn deploy "Deploy the JAR to Clojars." [opts]
(-> opts (let [{:keys [jar-file] :as opts} (jar-opts opts)]
(assoc :lib lib :version (if (:snapshot opts) snapshot version)) (dd/deploy {:installer :remote :artifact (b/resolve-path jar-file)
(bb/deploy))) :pom-file (b/pom-path (select-keys opts [:lib :class-dir]))}))
opts)

View file

@ -3,8 +3,9 @@
:deps {org.clojure/clojure {:mvn/version "1.9.0"}} :deps {org.clojure/clojure {:mvn/version "1.9.0"}}
:aliases :aliases
{;; for help: clojure -A:deps -T:build help/doc {;; for help: clojure -A:deps -T:build help/doc
:build {:deps {io.github.seancorfield/build-clj :build {:deps {io.github.clojure/tools.build
{:git/tag "v0.9.1" :git/sha "831c70f"}} {:git/tag "v0.9.2" :git/sha "fe6b140"}
slipset/deps-deploy {:mvn/version "0.2.0"}}
:ns-default build} :ns-default build}
;; versions to test against: ;; versions to test against:
@ -22,6 +23,7 @@
:extra-deps {io.github.cognitect-labs/test-runner :extra-deps {io.github.cognitect-labs/test-runner
{:git/tag "v0.5.1" :git/sha "dfb30dd"} {:git/tag "v0.5.1" :git/sha "dfb30dd"}
org.clojure/core.cache {:mvn/version "RELEASE"}} org.clojure/core.cache {:mvn/version "RELEASE"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test} :exec-fn cognitect.test-runner.api/test}
;; various "runners" for tests/CI: ;; various "runners" for tests/CI: