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

Commit

Permalink
prep for v0.8.5 tag
Browse files Browse the repository at this point in the history
  • Loading branch information
seancorfield committed Nov 29, 2022
1 parent 7081997 commit de693d0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 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.8.5 -- 2022-11-29
* Modify calls to `compile-clj` and `java-command` to default `:java-cmd` based on the `JAVA_CMD` and/or `JAVA_HOME` environment variables, if set. This won't be necessary when [TBUILD-34](https://clojure.atlassian.net/browse/TBUILD-34) is addressed.
* Update `tools.build` to v0.8.5.

* v0.8.3 7ac1f8d -- 2022-06-28
* Fix [#23](https://github.com/seancorfield/build-clj/issues/23) by propagating `:exclusions` in `lifted-basis` (for `:transitive true`).
* Update `tools.build` to v0.8.3 for `data_readers` fixes.
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ your `:build` alias can just be:

```clojure
:build {:deps {io.github.seancorfield/build-clj
{:git/tag "v0.8.3" :git/sha "7ac1f8d"}}
{:git/tag "v0.8.5" :git/sha "7ac1f8d"}}
:ns-default build}
```

Expand All @@ -37,7 +37,7 @@ not building JAR files at all) -- then you can specify a "slim" entry point to

```clojure
:build {:deps {io.github.seancorfield/build-clj
{:git/tag "v0.8.3" :git/sha "7ac1f8d"
{:git/tag "v0.8.5" :git/sha "7ac1f8d"
;; omits deps-deploy dependency:
:deps/root "slim"}}
:ns-default build}
Expand Down Expand Up @@ -245,6 +245,8 @@ 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)`.

* `:java-cmd` -- as of v0.8.5, this defaults to the value of the `JAVA_CMD` environment variable (if set) or the value of `${JAVA_HOME}/bin/java` (if `JAVA_HOME` is set), so that `java-command` (in `run-task` and therefore `run-tests`) and `compile-clj` (in `uber`) should pick up the same `java` version as the Clojure CLI overall.

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`,
Expand Down Expand Up @@ -314,6 +316,6 @@ You can see how `build-clj` is used to reduce boilerplate in the

# License

Copyright © 2021 Sean Corfield
Copyright © 2021-2022 Sean Corfield

Distributed under the Apache Software License version 2.0.
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.8.3" :git/sha "0d20256"}
{io.github.clojure/tools.build {:git/tag "v0.8.5" :git/sha "9c738da"}
io.github.seancorfield/build-uber-log4j2-handler {:git/tag "v0.1.5" :git/sha "55fb6f6"}
slipset/deps-deploy {:mvn/version "0.2.0"}}}
2 changes: 1 addition & 1 deletion slim/deps.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{:deps
{io.github.seancorfield/build-clj-slim {:local/root "../"
:exclusions [slipset/deps-deploy]}
io.github.clojure/tools.build {:git/tag "v0.8.3" :git/sha "0d20256"}
io.github.clojure/tools.build {:git/tag "v0.8.5" :git/sha "9c738da"}
io.github.seancorfield/build-uber-log4j2-handler {:git/tag "v0.1.5" :git/sha "55fb6f6"}}}
20 changes: 15 additions & 5 deletions src/org/corfield/build.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; copyright (c) 2021 sean corfield, all rights reserved.
;; copyright (c) 2021-2022 sean corfield, all rights reserved.

(ns org.corfield.build
"Common build utilities.
Expand Down Expand Up @@ -64,7 +64,8 @@
defaulted as noted above and the latter defaulted
to [\"resources\"] just for the copying but otherwise
has no default (for `tools.build/write-pom`)."
(:require [clojure.string :as str]
(:require [clojure.java.io :as io]
[clojure.string :as str]
[clojure.tools.build.api :as b]
[clojure.tools.deps.alpha :as t]
[org.corfield.log4j2-conflict-handler
Expand Down Expand Up @@ -205,6 +206,14 @@
(b/jar opts))
opts)

(defn- find-java []
(let [java-cmd (or (System/getenv "JAVA_CMD")
(when-let [home (System/getenv "JAVA_HOME")]
(str home "/bin/java")))]
(if (and java-cmd (.exists (io/file java-cmd)))
java-cmd
"java")))

(defn uber
"Build the application uber JAR file.
Expand All @@ -230,7 +239,7 @@
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]
(let [{:keys [class-dir java-cmd lib ns-compile sort src-dirs src+dirs uber-file version]
:as opts}
(jar-opts opts)]
(if (and lib version)
Expand All @@ -244,7 +253,7 @@
(if (or ns-compile sort)
(do
(println "Compiling" (str (str/join ", " (or ns-compile src-dirs)) "..."))
(b/compile-clj opts))
(b/compile-clj (assoc opts :java-cmd (or java-cmd (find-java)))))
(println "Skipping compilation because :main, :ns-compile, and :sort were omitted..."))
(println "Building uberjar" (str uber-file "..."))
(b/uber opts))
Expand Down Expand Up @@ -304,13 +313,14 @@
If :main-args is not provided and no :main-opts are found
in the aliases, default to the Cognitect Labs' test-runner."
[{:keys [java-opts jvm-opts main main-args main-opts] :as opts} aliases]
[{:keys [java-cmd java-opts jvm-opts main main-args main-opts] :as opts} aliases]
(let [task (str/join ", " (map name aliases))
_ (println "\nRunning task for:" task)
basis (b/create-basis {:aliases aliases})
combined (t/combine-aliases basis aliases)
cmds (b/java-command
{:basis basis
:java-cmd (or java-cmd (find-java))
:java-opts (into (or java-opts (:jvm-opts combined))
jvm-opts)
:main (or 'clojure.main main)
Expand Down

0 comments on commit de693d0

Please sign in to comment.