From fb1181100235fb61c378e5ae319292bea8d72cfd Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Thu, 16 Sep 2021 12:46:16 -0700 Subject: [PATCH] prep for v0.3.0; updates tools.build Also makes :lib optional for uber if :uber-file is passed. --- CHANGELOG.md | 4 ++++ README.md | 10 +++++----- deps.edn | 2 +- src/org/corfield/build.clj | 28 ++++++++++++++-------------- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8f5414..f7b6087 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +* v0.3.0 -- 2021-09-16 + * `:lib` is now optional for `uber` if you pass in `:uber-file`. + * Update `tools.build` to v0.5.0 7d77952 (default basis is now "repro" without user `deps.edn`). + * v0.2.2 5a12a1a -- 2021-09-15 * Address #3 by adding an `uber` task which includes the log4j2 plugins cache conflict handler. * Added support for many more options that `tools.build` tasks accept. diff --git a/README.md b/README.md index 6b4082c..6045f4b 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ your `:build` alias can just be: ```clojure :build {:deps {io.github.seancorfield/build-clj - {:git/tag "v0.2.2" :git/sha "5a12a1a"}} + {:git/tag "v0.3.0" :git/sha "..."}} :ns-default build} ``` @@ -40,7 +40,7 @@ _[Several functions in `clojure.tools.build.api` return `nil` instead]_ * `run-tests` -- run the project's tests. For `deploy` and `jar`, you must provide at least `:lib` and `:version`. -For `uber`, you must provide at least `:lib` for the name of the JAR file. +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. You might typically have the following tasks in your `build.clj`: @@ -121,7 +121,7 @@ Or you could just make it part of your `ci` pipeline without adding that functio The following defaults are provided: * `:target` -- `"target"`, -* `:basis` -- `(create-basis {:project "deps.edn"}`, +* `:basis` -- `(b/create-basis {})` -- this is a reproducible basis, i.e., it ignores the user `deps.edn` file -- if you want your user `deps.edn` included, you will need to explicitly pass `:basis (b/create-basis {:user :standard})` into tasks, * `:class-dir` -- `(str target "/classes")`, * `:jar-file` -- `(format \"%s/%s-%s.jar\" target lib version)`, * `:uber-file` -- `(format \"%s/%s-%s.jar\" target lib version)` if `:version` is provided, else `(format \"%s/%s-standalone.jar\" target lib)`. @@ -138,8 +138,8 @@ the high-level defaults as follows: * Requires: `:lib` and `:version`, * `:target`, `:class-dir`, `:basis`, `:resource-dirs`, `:scm`, `:src-dirs`, `:tag` (defaults to `(str "v" version)`), `:jar-file`, * `uber` - * Requires: `:lib`, - * `:target`, `:class-dir`, `:basis`, `:compile-opts`, `:main`, `:ns-compile`, `:resource-dirs`, `:scm`, `:src-dirs`, `:tag` (defaults to `(str "v" version)` if `:version` provided), `:uber-file`, `:version` + * Requires: `:lib` or `:uber-file`, + * `:target`, `:class-dir`, `:basis`, `:compile-opts`, `:main`, `:ns-compile`, `:resource-dirs`, `:scm`, `:src-dirs`, `:tag` (defaults to `(str "v" version)` if `:version` provided), `:version` * `run-tests` * `:aliases` -- for any additional aliases beyond `:test` which is always added, * Also accepts any options that `run-task` accepts. diff --git a/deps.edn b/deps.edn index 16a7917..5d8185a 100644 --- a/deps.edn +++ b/deps.edn @@ -1,4 +1,4 @@ {:deps - {io.github.clojure/tools.build {:git/tag "v0.4.0" :git/sha "801a22f"} + {io.github.clojure/tools.build {:git/tag "v0.5.0" :git/sha "7d77952"} io.github.seancorfield/build-uber-log4j2-handler {:git/tag "v0.1.0" :git/sha "ab8e499"} io.github.slipset/deps-deploy {:sha "b4359c5d67ca002d9ed0c4b41b710d7e5a82e3bf"}}} diff --git a/src/org/corfield/build.clj b/src/org/corfield/build.clj index 6be82cb..3f154b1 100644 --- a/src/org/corfield/build.clj +++ b/src/org/corfield/build.clj @@ -26,9 +26,9 @@ opt :target, :class-dir, :basis, :scm, :src-dirs, :resource-dirs, :tag, :jar-file (see docstring for additional options) - uber -- req :lib + uber -- req :lib or :uber-file opt :target, :class-dir, :basis, :scm, :src-dirs, - :resource-dirs, :tag, :uber-file, :version + :resource-dirs, :tag, :version (see docstring for additional options) run-task -- [opts aliases] opt :java-opts -- defaults to :jvm-opts from aliases @@ -74,7 +74,7 @@ (defn- default-basis [basis] - (or basis (b/create-basis {:project "deps.edn"}))) + (or basis (b/create-basis {}))) (defn- default-class-dir [class-dir target] @@ -82,7 +82,7 @@ (defn- default-jar-file [target lib version] - (format "%s/%s-%s.jar" (default-target target) (name lib) version)) + (format "%s/%s-%s.jar" (default-target target) (name (or lib 'application)) version)) (defn clean "Remove the target folder." @@ -149,15 +149,15 @@ (defn uber "Build the application uber JAR file. - Requires: :lib + Requires: :lib or :uber-file Accepts any options that are accepted by: * `tools.build/write-pom` * `tools.build/compile-clj` * `tools.build/uber` - The uber JAR filename is derived from :lib, - and :version if provided. + The uber JAR filename is derived from :lib + and :version if provided, else from :uber-file. If :version is provided, writes pom.xml into META-INF in the :class-dir, then @@ -165,20 +165,20 @@ Compiles :src-dirs into :class-dir, then copies :src-dirs and :resource-dirs into :class-dir, then builds :uber-file into :target (directory)." - {:argslists '([{:keys [lib + {:argslists '([{:keys [lib uber-file basis class-dir compile-opts filter-nses ns-compile repos resource-dirs scm sort - src-dirs src-pom tag target uber-file version]}])} - [{:keys [lib] :as opts}] - (assert lib ":lib is required for uber") - (let [{:keys [class-dir ns-compile sort src-dirs src+dirs uber-file version] + src-dirs src-pom tag target version]}])} + [{:keys [lib uber-file] :as opts}] + (assert (or lib uber-file) ":lib or :uber-file is required for uber") + (let [{:keys [class-dir lib ns-compile sort src-dirs src+dirs uber-file version] :as opts} (jar-opts opts)] - (if version + (if (and lib version) (do (println "\nWriting pom.xml...") (b/write-pom opts)) - (println "\nSkipping pom.xml because :version was omitted...")) + (println "\nSkipping pom.xml because :lib and/or :version were omitted...")) (println "Copying" (str (str/join ", " src+dirs) "...")) (b/copy-dir {:src-dirs src+dirs :target-dir class-dir})