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

Commit

Permalink
fixes #10 by exposing default functions
Browse files Browse the repository at this point in the history
  • Loading branch information
seancorfield committed Sep 27, 2021
1 parent bd00a4a commit 2ceb95a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log

* v0.4.0 54e39ae -- 2012-09-22
* v0.5.0 -- 2021-09-27
* Address #10 by exposing the four `default-*` functions used to compute `target`, `class-dir`, `basis`, and `jar-file` (`uber-file`).

* v0.4.0 54e39ae -- 2021-09-22
* 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.

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ The following defaults are provided:
* `: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)`.

As of v0.5.0, the four functions that compute those defaults are exposed for use in your own `build.clj` files:
* `(default-target)` -- return the default for `:target`,
* `(default-basis)` -- return the default for `:basis`,
* `(default-class-dir)` -- return the default for `:class-dir`; `(default-class-dir target)` is also available,
* `(default-jar-file lib version)` -- return the default for `:jar-file` or `:uber-file`; `(default-jar-file target lib version)` and `(default-jar-file version)` are also available (the latter defaults `:lib` to `'application`).

For the functions defined in `org.corfield.build`, you can override
the high-level defaults as follows:

Expand Down
51 changes: 36 additions & 15 deletions src/org/corfield/build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,42 @@
[org.corfield.log4j2-conflict-handler
:refer [log4j2-conflict-handler]]))

(defn- default-target
[target]
(or target "target"))

(defn- default-basis
[basis]
(or basis (b/create-basis {})))

(defn- default-class-dir
[class-dir target]
(or class-dir (str (default-target target) "/classes")))

(defn- default-jar-file
[target lib version]
(format "%s/%s-%s.jar" (default-target target) (name (or lib 'application)) version))
(defn default-target
"Return the default target directory name."
{:arglists '([])}
([] (default-target nil))
([target]
(or target "target")))

(defn default-basis
"Return the default basis."
{:arglists '([])}
([] (default-basis nil))
([basis]
(or basis (b/create-basis {}))))

(defn default-class-dir
"Return the default `class-dir`.
May be passed a non-default target directory name."
{:arglists '([] [target])}
([] (default-class-dir nil nil))
([target] (default-class-dir nil target))
([class-dir target]
(or class-dir (str (default-target target) "/classes"))))

(defn default-jar-file
"Given the `lib` and `version`, return the default JAR
filename.
`lib` can be omitted and will default to `'application`
(for uberjar usage).
May be passed a non-default target directory name."
([version] (default-jar-file nil nil version))
([lib version] (default-jar-file nil lib version))
([target lib version]
(format "%s/%s-%s.jar" (default-target target) (name (or lib 'application)) version)))

(defn clean
"Remove the target folder."
Expand Down

0 comments on commit 2ceb95a

Please sign in to comment.