Clojure SDK for Pocketenv
at main 73 lines 2.6 kB view raw
1(ns build 2 (:refer-clojure :exclude [test]) 3 (:require [clojure.tools.build.api :as b] 4 [deps-deploy.deps-deploy :as dd])) 5 6(def lib 'io.pocketenv/pocketenv) 7(def version "0.1.4-SNAPSHOT") 8#_ ; alternatively, use MAJOR.MINOR.COMMITS: 9 (def version (format "1.0.%s" (b/git-count-revs nil))) 10(def class-dir "target/classes") 11 12(defn test "Run all the tests." [opts] 13 (let [basis (b/create-basis {:aliases [:test]}) 14 cmds (b/java-command 15 {:basis basis 16 :main 'clojure.main 17 :main-args ["-m" "cognitect.test-runner"]}) 18 {:keys [exit]} (b/process cmds)] 19 (when-not (zero? exit) (throw (ex-info "Tests failed" {})))) 20 opts) 21 22(defn- pom-template [version] 23 [[:description "Clojure SDK for the Pocketenv sandbox platform. Create and manage sandboxes, execute commands, and more from your Clojure code."] 24 [:url "https://github.com/pocketenv-io/pocketenv-clojure"] 25 [:licenses 26 [:license 27 [:name "MIT License"] 28 [:url "https://opensource.org/licenses/MIT"]]] 29 [:developers 30 [:developer 31 [:name "Tsiry Sandratraina"]]] 32 [:scm 33 [:url "https://github.com/pocketenv-io/pocketenv-clojure"] 34 [:connection "scm:git:https://github.com/pocketenv-io/pocketenv-clojure.git"] 35 [:developerConnection "scm:git:ssh:git@github.com:pocketenv-io/pocketenv-clojure.git"] 36 [:tag (str "v" version)]]]) 37 38(defn- jar-opts [opts] 39 (assoc opts 40 :lib lib :version version 41 :jar-file (format "target/%s-%s.jar" lib version) 42 :basis (b/create-basis {}) 43 :class-dir class-dir 44 :target "target" 45 :src-dirs ["src"] 46 :pom-data (pom-template version))) 47 48(defn ci "Run the CI pipeline of tests (and build the JAR)." [opts] 49 (test opts) 50 (b/delete {:path "target"}) 51 (let [opts (jar-opts opts)] 52 (println "\nWriting pom.xml...") 53 (b/write-pom opts) 54 (println "\nCopying source...") 55 (b/copy-dir {:src-dirs ["resources" "src"] :target-dir class-dir}) 56 (println "\nBuilding JAR..." (:jar-file opts)) 57 (b/jar opts)) 58 opts) 59 60(defn install "Install the JAR locally." [opts] 61 (b/delete {:path "target"}) 62 (let [opts (jar-opts opts)] 63 (b/write-pom opts) 64 (b/copy-dir {:src-dirs ["resources" "src"] :target-dir class-dir}) 65 (b/jar opts) 66 (b/install opts)) 67 opts) 68 69(defn deploy "Deploy the JAR to Clojars." [opts] 70 (let [{:keys [jar-file] :as opts} (jar-opts opts)] 71 (dd/deploy {:installer :remote :artifact (b/resolve-path jar-file) 72 :pom-file (b/pom-path (select-keys opts [:lib :class-dir]))})) 73 opts)