diff --git a/CHANGELOG.md b/CHANGELOG.md index 24724c8..f580499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +* v0.4.0 in progress + * Address #6 by providing `install` task based on `tools.build` (and deprecating `:installer :local` for `deploy` task). + * Update `tools.build` to v0.5.1 21da7d4. + * v0.3.1 996ddfa -- 2021-09-17 * Update `deps-deploy` to 0.2.0 for latest deps and new Maven settings support. diff --git a/README.md b/README.md index b86a3b5..ce56019 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,12 @@ _[Several functions in `clojure.tools.build.api` return `nil` instead]_ * `clean` -- clean the target directory (wraps `delete` from `tools.build`), * `deploy` -- deploy to Clojars (wraps `deploy` from `deps-deploy`), +* `install` -- install the JAR locally (wraps `create-basis` and `install` from `tools.build`), * `jar` -- build the (library) JAR and `pom.xml` files (wraps `create-basis`, `write-pom`, `copy-dir`, and `jar` from `tools.build`), * `uber` -- build the (application) uber JAR, with optional `pom.xml` file creation and/or AOT compilation (wraps `create-basis`, `write-pom`, `copy-dir`, `compile-clj`, and `uber` from `tools.build`), * `run-tests` -- run the project's tests (wraps `create-basis`, `java-command`, and `process` from `tools.build`, to run the `:main-opts` in your `:test` alias). -For `deploy` and `jar`, you must provide at least `:lib` and `:version`. +For `deploy`, `install`, and `jar`, you must provide at least `:lib` and `:version`. For `uber`, you must provide at least `:lib` or `:uber-file` for the name of the JAR file. Everything else has "sane" defaults, but can be overridden. @@ -57,6 +58,11 @@ You might typically have the following tasks in your `build.clj`: (bb/clean) (bb/jar))) +(defn install "Install the JAR locally." [opts] + (-> opts + (assoc :lib lib :version version) + (bb/install))) + (defn deploy "Deploy the JAR to Clojars." [opts] (-> opts (assoc :lib lib :version version) @@ -122,7 +128,7 @@ different dependencies and supply `:main-opts`: :main-opts ["-m" "kaocha.runner"]} ``` -With this `:test` alias, the `run-tests` task above would run your test using Kaocha. +With this `:test` alias, the `run-tests` task above would run your tests using Kaocha. ## Running Additional Programs @@ -182,6 +188,9 @@ the high-level defaults as follows: * `deploy` * Requires: `:lib` and `:version`, * `:target`, `:class-dir`, `:jar-file`, +* `install` + * Requires: `:lib` and `:version`, + * `:target`, `:class-dir`, `:basis`, `:jar-file`, * `jar` * Requires: `:lib` and `:version`, * `:target`, `:class-dir`, `:basis`, `:resource-dirs`, `:scm`, `:src-dirs`, `:tag` (defaults to `(str "v" version)`), `:jar-file`, diff --git a/deps.edn b/deps.edn index 18cfb25..da10142 100644 --- a/deps.edn +++ b/deps.edn @@ -1,4 +1,4 @@ {:deps - {io.github.clojure/tools.build {:git/tag "v0.5.0" :git/sha "7d77952"} + {io.github.clojure/tools.build {:git/tag "v0.5.1" :git/sha "21da7d4"} io.github.seancorfield/build-uber-log4j2-handler {:git/tag "v0.1.0" :git/sha "ab8e499"} slipset/deps-deploy {:mvn/version "0.2.0"}}} diff --git a/src/org/corfield/build.clj b/src/org/corfield/build.clj index e209c94..1dc8da3 100644 --- a/src/org/corfield/build.clj +++ b/src/org/corfield/build.clj @@ -22,6 +22,9 @@ deploy -- req :lib, :version opt :target, :class-dir, :jar-file (see docstring for additional options) + install -- req :lib, :version + opt :target, :class-dir, :basis, :jar-file + (see docstring for additional options) jar -- req :lib, :version opt :target, :class-dir, :basis, :scm, :src-dirs, :resource-dirs, :tag, :jar-file @@ -191,6 +194,26 @@ (b/uber opts)) opts) +(defn install + "Install the JAR to the local Maven repo cache. + + Requires: :lib, :version + + Accepts any options that are accepted by: + * `tools.build/install`" + {:arglists '([{:keys [lib version + basis class-dir classifier jar-file target]}])} + [{:keys [lib version basis class-dir classifier jar-file target] :as opts}] + (assert (and lib version) ":lib and :version are required for install") + (let [target (default-target target)] + (b/install {:basis (default-basis basis) + :lib lib + :classifier classifier + :version version + :jar-file (or jar-file (default-jar-file target lib version)) + :class-dir (default-class-dir class-dir target)}) + opts)) + (defn deploy "Deploy the JAR to Clojars. @@ -205,8 +228,10 @@ or relying on the default value computed for :jar-file)." {:arglists '([{:keys [lib version artifact class-dir installer jar-file pom-file target]}])} - [{:keys [lib version class-dir jar-file target] :as opts}] + [{:keys [lib version class-dir installer jar-file target] :as opts}] (assert (and lib version) ":lib and :version are required for deploy") + (when (and installer (not= :remote installer)) + (println installer ":installer is deprecated -- use install task for local deployment")) (let [target (default-target target) class-dir (default-class-dir class-dir target) jar-file (or jar-file (default-jar-file target lib version))]