Skip to content

Commit

Permalink
Switch to using bb as the task runner and doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
axvr committed Oct 22, 2024
1 parent 5317f90 commit e0f2b14
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
java temurin-11
clojure latest
babashka latest
clj-kondo latest
cljfmt latest
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ com.kroo/typeset.logback {:mvn/version "0.7"}
[com.kroo/typeset.logback "0.7"]
```

> **Note**<br>
> [!NOTE]
> While this library is designed for and written in Clojure, it still works in
> other JVM languages. To use it, add [Clojars](https://clojars.org/) as a Maven repository.
Expand Down
20 changes: 20 additions & 0 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{:tasks
{:init (do (defn sh [& args]
(binding [*out* *err*]
(apply println "+" args))
(apply shell args))
(def clj (partial sh "clojure")))
check {:doc "Run all pre-commit checks."
:depends [lint fmt test]}
lint {:doc "Lint code."
:task (sh "clj-kondo" "--lint" "src:test")}
fmt {:doc "Format code."
:task (sh "cljfmt" "fix")}
test {:doc "Run test suite."
:task (do
(clj "-T:build" "compile")
(apply clj "-X:test" *command-line-args*))}
build {:doc "Run build functions."
:task (apply clj "-T:build" *command-line-args*)}
outdated {:doc "Check for outdated dependencies."
:task (clj "-T:antq" "outdated")}}}
19 changes: 11 additions & 8 deletions build/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
# Common development actions

> [!TIP]
> Install all external tools automatically with [`asdf`](https://asdf-vm.com/) or [`mise`](https://mise.jdx.dev/). All tool versions are listed in the `.tool-versions` file.
## Lint/format/etc.

```shell
clojure -M:lint # Lint
clojure -T:cljfmt fix # Fix formatting
clojure -T:antq outdated # List outdated deps
bb lint # Lint
bb fmt # Fix formatting
bb outdated # List outdated deps
```

## Test

Run tests by executing the following commands.

```shell
clj -T:build compile
clj -X:test
bb build compile
bb test
```

## Build

> **Warning**<br>
> [!WARNING]
> If you have any local changes that haven't been committed, they will be included in the built jar file.
Build and install the jar with these commands.

```shell
clojure -T:build jar
clojure -T:build install
bb build jar
bb build install
```

If there was no Git tag pointing to the commit, the jar will have the version: `local`.
Expand Down
2 changes: 1 addition & 1 deletion build/build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
:ns-compile ['com.kroo.typeset.logback.JsonLayout]
:bindings {#'clojure.core/*assert* false
#'clojure.core/*warn-on-reflection* true}})
;; Remove unintentionally transitive compiled classes.
;; NOTE: Removes unintentionally transitive compiled classes.
(b/delete {:path (str class-dir "/jsonista")}))

(defn jar
Expand Down
8 changes: 4 additions & 4 deletions build/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ pushd "deploy-$version"

(
set -e
clojure -T:build compile
clojure -X:test
clojure -T:build jar
clojure -T:build deploy
bb build compile
bb test
bb build jar
bb build deploy
)

popd
Expand Down
8 changes: 2 additions & 6 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{:paths ["src" "target/classes"]
;; NOTE: if adding more Clojure libs, make sure to exclude them from the
;; packaged Typeset.logback Jar (see `build/build.clj`).
:deps {org.clojure/clojure {:mvn/version "1.12.0"}
ch.qos.logback/logback-classic {:mvn/version "1.5.11"}
metosin/jsonista {:mvn/version "0.3.11"}}
Expand All @@ -18,12 +20,6 @@
:deps {io.github.clojure/tools.build {:git/tag "v0.10.5", :git/sha "2a21b7a"}
slipset/deps-deploy {:mvn/version "0.2.2"}}
:ns-default build}
;; clj -M:lint
:lint {:replace-deps {clj-kondo/clj-kondo {:mvn/version "RELEASE"}}
:main-opts ["-m" "clj-kondo.main" "--parallel" "--lint" "src" "test"]}
;; clj -T:cljfmt fix
:cljfmt {:deps {io.github.weavejester/cljfmt {:git/tag "0.13.0", :git/sha "f0230c3"}}
:ns-default cljfmt.tool}
;; clj -T:antq outdated
:antq {:deps {com.github.liquidz/antq {:mvn/version "RELEASE"}
org.slf4j/slf4j-nop {:mvn/version "RELEASE"}}
Expand Down
3 changes: 3 additions & 0 deletions src/com/kroo/typeset/logback/JsonLayout.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
[setIncludeExData [Boolean] void]
[setJacksonModules [String] void]]))

;; NOTE: since this class is AOT compiled, be careful not to use any anonymous
;; functions or vars that have gensymed names.

;; Record providing fast access to JsonLayout options in lieu of fields.
(defrecord JsonLayoutOpts [append-newline
include-logger-ctx
Expand Down

0 comments on commit e0f2b14

Please sign in to comment.