Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Commit

Permalink
addresses #6 by adding install task
Browse files Browse the repository at this point in the history
  • Loading branch information
seancorfield committed Sep 23, 2021
1 parent 19c1d31 commit 6054c0c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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`,
Expand Down
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
@@ -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"}}}
27 changes: 26 additions & 1 deletion src/org/corfield/build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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))]
Expand Down

0 comments on commit 6054c0c

Please sign in to comment.