Skip to content

Sync upstream #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 37 commits into from
Closed
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c3e9143
README
borkdude Nov 13, 2021
81a49b5
README
borkdude Nov 13, 2021
2aa7f18
README
borkdude Nov 13, 2021
3c65ff8
Make tasks compatible with babashka (#1)
hugoduncan Nov 13, 2021
4803c45
babashka tooling to run tests (#2)
hugoduncan Nov 13, 2021
73c2659
Update to latest babashka/tools.namespace sha (#4)
hugoduncan Nov 13, 2021
7fb61e0
Add instructions to README (#3)
hugoduncan Nov 13, 2021
b8c6290
README
borkdude Nov 13, 2021
ae11b6c
README [skip ci]
borkdude Nov 13, 2021
e6f0187
README [skip ci]
borkdude Nov 13, 2021
418b6d9
README [skip ci]
borkdude Nov 13, 2021
c0d538b
README [skip ci]
borkdude Nov 13, 2021
784a760
README [skip ci]
borkdude Nov 13, 2021
097cbac
README [skip ci]
borkdude Nov 13, 2021
8ec9c75
[#5] Fix install by moving it to pod side (#6)
borkdude Nov 14, 2021
3c1b7ac
Install test
borkdude Nov 14, 2021
e5488da
Merge branch 'master' into babashka
borkdude Nov 14, 2021
af73f5a
Fix install by passing through project-root
borkdude Nov 14, 2021
2f8e9d4
.gitignore
borkdude Nov 14, 2021
b832a55
separate bb-specific requires
borkdude Nov 14, 2021
90aa50a
Windows
borkdude Nov 28, 2021
9f12c95
windows
borkdude Nov 28, 2021
248577b
windows
borkdude Nov 28, 2021
bfb5c69
Make tests Windows compatible (#7)
borkdude Nov 28, 2021
77368a8
Support running local native
borkdude Nov 28, 2021
70f432f
java-cmd debug
borkdude Nov 28, 2021
0c1b815
Merge branch 'master' into babashka
borkdude Nov 28, 2021
d0a08c7
remove debug
borkdude Nov 28, 2021
0a4959d
deps.edn
borkdude Nov 28, 2021
0ea155f
update README
borkdude Nov 28, 2021
eac3ebb
v0.0.5
borkdude Nov 28, 2021
c7931f7
Revert "Make tests Windows compatible (#7)"
borkdude Nov 29, 2021
931e226
Merge branch 'master' into babashka
borkdude Nov 29, 2021
a3c0723
Update to tools build 0.9.0 (#9)
borkdude Jan 5, 2023
73e4d0a
Use tools-deps-native 0.1.1
borkdude Jul 27, 2023
c218869
Use pod 0.1.2
borkdude Sep 16, 2023
4d3303b
Sync with upstream master
borkdude Sep 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/bb.yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: bb tests

on: [push, pull_request]

jobs:

clojure:

strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v3

# It is important to install java before installing clojure tools which needs java
# exclusions: babashka, clj-kondo and cljstyle
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'

- name: Install clojure tools
uses: DeLaGuardo/setup-clojure@10.1
with:
# Install just one or all simultaneously
# The value must indicate a particular version of the tool, or use 'latest'
# to always provision the latest version
bb: latest

# Optional step:
- name: Cache clojure dependencies
uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.gitlibs
~/.deps.clj
# List all files containing dependencies:
key: cljdeps-${{ hashFiles('deps.edn') }}
# key: cljdeps-${{ hashFiles('deps.edn', 'bb.edn') }}
# key: cljdeps-${{ hashFiles('project.clj') }}
# key: cljdeps-${{ hashFiles('build.boot') }}
restore-keys: cljdeps-

- name: Run bb tests
run: bb test
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Tests
on: [push]

jobs:
test:
strategy:
matrix:
java-version: ["8", "11", "17"]
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Prepare java
uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: ${{ matrix.java-version }}

- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@3.6
with:
cli: 1.10.3.1040

- name: Checkout
uses: actions/checkout@v2-beta

- name: Run tests not Windows
if: ${{ matrix.os != 'windows-latest' }}
run: clojure -X:test
shell: bash

- name: Run tests on Windows
if: ${{ matrix.os == 'windows-latest' }}
run: clojure -X:test
shell: powershell
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -11,3 +11,6 @@ test-out
.clj-kondo/.cache
.vscode
.lsp
tools-deps-native
.vscode
.lsp
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Changelog
===========

<<<<<<< HEAD
* next
* uber - fix exlcusions and conflict handling when including local deps on windows
* v0.9.5 24f2894 on Aug 11, 2023
80 changes: 78 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,82 @@
tools.build
tools.bbuild
========================================

## Babashka maintained fork of tools.build

> 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](https://github.com/borkdude/tools-deps-native-experiment)
which is used as a [pod](https://github.com/babashka/pods).

- `compile-clj` uses `clojure.core/munge` instead of `clojure.lang.Compiler/munge`

- `install` uses a helper from
[tools-deps-native](https://github.com/borkdude/tools-deps-native-experiment)
to construct maven objects.

- `javac` shells out to `javac` rather than using `javax.tools.JavaCompiler`

## Usage

Ensure you have [babashka](https://github.com/babashka/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`:

``` clojure
io.github.babashka/tools.bbuild {:git/sha "<sha>"}
```

Create a `build.clj`:

``` clojure
(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.

## Tests

To run tests, run `bb test`. This assumes that the `tools-deps-native` pod is on
your PATH.

Here follows the original README.

<hr>


A library for building artifacts in Clojure projects.

## Docs
@@ -18,7 +94,7 @@ As a git dep:

```clojure
io.github.clojure/tools.build {:git/tag "v0.9.5" :git/sha "24f2894"}
```
```

As a Maven dep:

12 changes: 12 additions & 0 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{:paths ["bb"]
:deps {io.github.babashka/tools.bbuild {:local/root "."}}
:tasks {test {:doc "Run test with cognitect test runner"
:extra-paths ["src/test/clojure"]
:extra-deps
{io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "48c3c67"}}
:requires ([cognitect.test-runner :as tr])
:task (apply tr/-main
"-d" "src/test/clojure"
"-r" ".*test-.*"
*command-line-args*)}}}
31 changes: 31 additions & 0 deletions bb/build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
;; This is a test build.clj, referenced in the README

(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)}))
6 changes: 4 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -6,8 +6,10 @@
;org.clojure/tools.deps {:git/url "https://github.com/clojure/tools.deps.git"
; :git/sha "459222ca6e4fce91cf5838435589a028cedbc784"}
org.clojure/tools.namespace {:mvn/version "1.4.4"}
org.slf4j/slf4j-nop {:mvn/version "1.7.36"}}

org.slf4j/slf4j-nop {:mvn/version "1.7.36"}
babashka/fs {:mvn/version "0.2.12"}
babashka/babashka.pods {:mvn/version "0.2.0"}
}
:aliases
{;; Run all tests
;; clj -X:test
2 changes: 1 addition & 1 deletion docs/clojure.tools.build.api.html
Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@
Options:
:java-cmd - Java command, default = $JAVA_CMD or 'java' on $PATH, or $JAVA_HOME/bin/java
:cp - coll of string classpath entries, used first (if provided)
:basis - runtime basis used for classpath, used last (if provided)
:basis - runtime basis used for classpath and jvm opts from aliases, used last (if provided)
:java-opts - coll of string jvm opts
:main - required, main class symbol
:main-args - coll of main class args
15 changes: 15 additions & 0 deletions examples/jar/bb.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{:paths ["."]
:deps {io.github.babashka/tools.bbuild {:local/root "../.."}
borkdude/spartan.spec
{:git/url "https://github.com/borkdude/spartan.spec"
:sha "12947185b4f8b8ff8ee3bc0f19c98dbde54d4c90"}}
:tasks {:requires ([load_babashka-deps]
[build :as b])
basis {:task (b/basis {})}
clean {:task (b/clean {})}
write-pom {:depends [basis]
:task (b/write-pom {:basis basis})}
jar {:depends [basis write-pom]
:task (b/jar {:basis basis})}
install {:depends [jar]
:task (b/install {:basis basis})}}}
38 changes: 38 additions & 0 deletions examples/jar/build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(ns build
(:require [clojure.tools.build.api :as b]))

(def version "0.1.0")
(def class-dir "target/classes")
(def jar-file (format "target/example-%s.jar" version))
(def lib 'my/example)

(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 lib
: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 jar-file}))

(defn install [{:keys [basis]}]
(b/install {:basis basis
:class-dir class-dir
:jar-file jar-file
:lib lib
:version version}))
9 changes: 9 additions & 0 deletions examples/jar/load_babashka_deps.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(ns load-babashka-deps)

(require '[babashka.pods :as pods])
;; Load tools-deps-native pod which defines clojure.tools.deps.alpha.
;; This assumes the binar tools-deps-native is on your PATH
;; You can change the call to load from an absolute or relative path instead.
(pods/load-pod "tools-deps-native")

(require '[spartan.spec]) ;; defines clojure.spec.alpha
Loading
Oops, something went wrong.