diff --git a/build.clj b/build.clj index 4e3f91c..3959056 100644 --- a/build.clj +++ b/build.clj @@ -1,10 +1,39 @@ (ns build (:require [clojure.tools.build.api :as b])) +(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 [_] + (println "Cleaning target...") + (b/delete {:path "target"})) + +(defn jar [_] + (println "Writing pom.xml...") + (b/write-pom {:class-dir class-dir + :lib lib + :version 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 [_] (let [basis (b/create-basis {:aliases [:test]}) cmds (b/java-command {:basis basis :main 'clojure.main - :main-args ["-m" "cognitect.test-runner"]})] - (b/process cmds))) + :main-args ["-m" "cognitect.test-runner"]}) + {:keys [exit]} (b/process cmds)] + (when-not (zero? exit) + (throw (ex-info "Tests failed" {}))))) + +(defn ci [opts] + (-> opts (run-tests) (clean) (jar))) diff --git a/deps.edn b/deps.edn index 777c7ce..76909b7 100644 --- a/deps.edn +++ b/deps.edn @@ -41,11 +41,8 @@ org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.14.1"}} :jvm-opts ["-Dlog4j2.configurationFile=log4j2-info.properties"] :exec-fn cognitect.test-runner.api/test} - :jar - {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.278"}} - :exec-fn hf.depstar/jar - :exec-args {:jar "next-jdbc.jar" :sync-pom true}} :deploy {:replace-deps {slipset/deps-deploy {:mvn/version "0.1.5"}} :exec-fn deps-deploy.deps-deploy/deploy - :exec-args {:installer :remote :artifact "next-jdbc.jar"}}}} + :exec-args {:installer :remote + :pom-file "target/classes/META-INF/maven/com.github.seancorfield/next.jdbc/pom.xml"}}}}