WARNING: this work is experimental and should be used with caution!
This fork of tools.build
works with babashka. To make it compatible, the
following changes were introduced:
-
The
clojure.tools.deps
library is replaced with tools-deps-native which is used as a pod. -
compile-clj
usesclojure.core/munge
instead ofclojure.lang.Compiler/munge
-
install
uses a helper from tools-deps-native to construct maven objects. -
javac
shells out tojavac
rather than usingjavax.tools.JavaCompiler
Ensure you have babashka 1.0.169 or later.
In your bb.edn
add :paths ["."]
to add build.clj
to your babashka classpath.
Also add this library to bb.edn
:
io.github.babashka/tools.bbuild {:git/sha "<sha>"}
Create a build.clj
:
(ns build
(:require [clojure.tools.build.api :as b]))
(def version "0.1.0")
(def class-dir "target/classes")
(defn basis [_]
(b/create-basis {:project "deps.edn"}))
(defn clean [_]
(b/delete {:path "target"}))
(defn write-pom [{:keys [basis]}]
(b/write-pom
{:basis basis
:src-dirs ["src"]
:class-dir class-dir
:lib 'my/example
:version version}))
(defn jar [{:keys [basis]}]
(b/copy-dir {:src-dirs ["src"]
:target-dir class-dir})
(b/jar
{:basis basis
:src-dirs ["src"]
:class-dir class-dir
:main "example.core"
:jar-file (format "target/example-%s.jar" version)}))
Then run e.g. bb -x build/jar
to produce a jar file.
To run tests, run bb test
. This assumes that the tools-deps-native
pod is on
your PATH.
Here follows the original README.
A library for building artifacts in Clojure projects.
Latest release:
deps.edn dependency information:
As a git dep:
io.github.clojure/tools.build {:git/tag "v0.9.6" :git/sha "8e78bcc"}
As a Maven dep:
io.github.clojure/tools.build {:mvn/version "0.9.6"}
Copyright © 2023 Rich Hickey, Alex Miller, and contributors
All rights reserved. The use and distribution terms for this software are covered by the Eclipse Public License 1.0 which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.