Skip to content

Commit cfc6ee9

Browse files
Merge pull request #625 from clj-commons/minimal-deps-edn
Add minimal tools.deps support
2 parents 54efaf3 + a4a9a7c commit cfc6ee9

File tree

10 files changed

+141
-1
lines changed

10 files changed

+141
-1
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,7 @@ jobs:
3737
- ~/.m2
3838
key: v1-dependencies-{{ checksum "project.clj" }}
3939

40+
- run: deps/ensure-deps-up-to-date
41+
4042
# run tests!
4143
- run: lein do clean, test

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
* @arnaudgeiser @kingmob
1+
* @arnaudgeiser @kingmob @dergutemoritz
2+
/deps/ @dergutemoritz

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Leiningen:
1313
deps.edn:
1414
```clojure
1515
aleph/aleph {:mvn/version "0.5.0"}
16+
;; alternatively
17+
io.github.clj-commons/aleph {:git/sha "..."}
1618
```
1719

1820
### HTTP
@@ -123,6 +125,12 @@ Where incoming packets will have a `:message` that is a byte-array, which can be
123125

124126
To learn more, [read the documentation](http://aleph.io/examples/literate.html).
125127

128+
### Development
129+
130+
Aleph uses [Leiningen](https://leiningen.org/) for managing dependencies, running REPLs and tests, and building the code.
131+
132+
Minimal [`tools.deps`](https://github.com/clojure/tools.deps.alpha) support is available in the form of a `deps.edn` file which is generated from `project.clj`. It provides just enough to be able to use Aleph as a git or `:local/root` dependency. When committing changes to `project.clj`, run `deps/lein-to-deps` and commit the resulting changes, too.
133+
126134
### License
127135

128136
Copyright © 2010-2020 Zachary Tellman

deps.edn

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
;; DO NOT EDIT MANUALLY - generated from project.clj via deps/lein-to-deps
2+
{:paths ["src/" "target/classes/"],
3+
:deps
4+
{org.clojure/tools.logging
5+
{:mvn/version "1.1.0", :exclusions [org.clojure/clojure]},
6+
io.netty/netty-handler-proxy {:mvn/version "4.1.79.Final"},
7+
manifold/manifold {:mvn/version "0.2.4"},
8+
io.netty/netty-codec {:mvn/version "4.1.79.Final"},
9+
io.netty/netty-transport-native-epoll$linux-aarch_64
10+
{:mvn/version "4.1.79.Final"},
11+
org.clj-commons/dirigiste {:mvn/version "1.0.1"},
12+
io.netty/netty-handler {:mvn/version "4.1.79.Final"},
13+
org.clj-commons/primitive-math {:mvn/version "1.0.0"},
14+
io.netty/netty-transport-native-epoll$linux-x86_64
15+
{:mvn/version "4.1.79.Final"},
16+
io.netty/netty-transport {:mvn/version "4.1.79.Final"},
17+
org.clj-commons/byte-streams {:mvn/version "0.3.1"},
18+
io.netty/netty-codec-http {:mvn/version "4.1.79.Final"},
19+
potemkin/potemkin {:mvn/version "0.4.5"},
20+
io.netty/netty-resolver {:mvn/version "4.1.79.Final"},
21+
io.netty/netty-resolver-dns {:mvn/version "4.1.79.Final"}},
22+
:aliases
23+
{:build
24+
{:paths ["deps"],
25+
:deps
26+
{io.github.clojure/tools.build
27+
{:git/sha "cde5adf5d56fe7238de509339e63627f438e5d4b",
28+
:git/url "https://github.com/clojure/tools.build.git"}},
29+
:ns-default aleph.build}},
30+
:deps/prep-lib
31+
{:ensure "target/classes/", :alias :build, :fn compile-java}}

deps/aleph/build.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(ns aleph.build
2+
(:require [clojure.tools.build.api :as b]))
3+
4+
;; WARNING: This is *not* Aleph's official build process. It merely
5+
;; replicates a subset of the official Leiningen-based build process
6+
;; to allow Aleph to be used as a git or local root dependency.
7+
8+
(def basis (b/create-basis {:project "deps.edn"}))
9+
(def build-edn (read-string (slurp "deps/aleph/build.edn")))
10+
11+
(defn compile-java [_]
12+
(b/javac (assoc (:javac build-edn) :basis basis)))

deps/aleph/build.edn

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
;; DO NOT EDIT MANUALLY - generated from project.clj via deps/lein-to-deps
2+
{:javac
3+
{:src-dirs ["src/aleph/utils/"],
4+
:class-dir "target/classes/",
5+
:javac-opts ["-target" "1.8" "-source" "1.8"]}}

deps/aleph/lein_to_deps.clj

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
(ns aleph.lein-to-deps
2+
(:require
3+
[clojure.java.io :as io]
4+
[clojure.pprint :as pp]))
5+
6+
(defn convert-lein-deps [deps]
7+
(into {}
8+
(map (fn [[name version & {:keys [classifier exclusions]}]]
9+
(let [name (if classifier
10+
(symbol (str name "$" classifier))
11+
name)
12+
params (cond-> {:mvn/version version}
13+
(seq exclusions)
14+
(assoc :exclusions (mapv first exclusions)))]
15+
[name params])))
16+
deps))
17+
18+
(defn relativize-path [p]
19+
(-> (System/getProperty "user.dir")
20+
io/file
21+
.toURI
22+
(.relativize (-> p io/file .toURI))
23+
.getPath))
24+
25+
(defn write-edn-file [path data]
26+
(binding [*print-namespace-maps* false]
27+
(with-open [w (io/writer (io/file path))]
28+
(binding [*out* w]
29+
(println ";; DO NOT EDIT MANUALLY - generated from project.clj via deps/lein-to-deps")
30+
(pp/pprint data)))))
31+
32+
(defn run []
33+
(let [pprinted-project-clj (read-string (slurp *in*))
34+
deps (convert-lein-deps (:dependencies pprinted-project-clj))
35+
class-dir (relativize-path (:compile-path pprinted-project-clj))
36+
source-paths (conj (mapv relativize-path (:source-paths pprinted-project-clj))
37+
class-dir)
38+
java-source-dirs (mapv relativize-path (:java-source-paths pprinted-project-clj))]
39+
(write-edn-file "deps.edn"
40+
{:paths source-paths
41+
:deps deps
42+
:aliases
43+
{:build
44+
{:paths ["deps"]
45+
:deps
46+
{'io.github.clojure/tools.build
47+
{:git/sha "cde5adf5d56fe7238de509339e63627f438e5d4b"
48+
:git/url "https://github.com/clojure/tools.build.git"}},
49+
:ns-default 'aleph.build}}
50+
:deps/prep-lib
51+
{:ensure class-dir
52+
:alias :build
53+
:fn 'compile-java}})
54+
(write-edn-file "deps/aleph/build.edn"
55+
{:javac {:src-dirs java-source-dirs
56+
:class-dir class-dir
57+
:javac-opts (:javac-options pprinted-project-clj)}})))

deps/ensure-deps-up-to-date

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
DEPS_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
6+
7+
"${DEPS_DIR}/lein-to-deps"
8+
9+
for f in deps.edn deps/aleph/build.edn; do
10+
if ! git diff --exit-code "$f"; then
11+
echo >&2
12+
echo "ERROR: ${f} needs to be re-generated via deps/lein-to-deps" >&2
13+
exit 1
14+
fi
15+
done

deps/lein-to-deps

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
cd "$(dirname -- "${BASH_SOURCE[0]}")/.."
6+
7+
lein with-profiles -default pprint | lein with-profiles +lein-to-deps run -m aleph.lein-to-deps/run

project.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
[com.cognitect/transit-clj "1.0.324"]
2929
[spootnik/signal "0.2.4"]
3030
[me.mourjo/dynamic-redef "0.1.0"]]}
31+
:lein-to-deps {:source-paths ["deps"]}
3132
;; This is for self-generating certs for testing ONLY:
3233
:test {:dependencies [[org.bouncycastle/bcprov-jdk15on "1.69"]
3334
[org.bouncycastle/bcpkix-jdk15on "1.69"]]
@@ -43,6 +44,7 @@
4344
:plugins [[lein-codox "0.10.7"]
4445
[lein-jammin "0.1.1"]
4546
[lein-marginalia "0.9.1"]
47+
[lein-pprint "1.3.2"]
4648
[ztellman/lein-cljfmt "0.1.10"]]
4749
:java-source-paths ["src/aleph/utils"]
4850
:cljfmt {:indents {#".*" [[:inner 0]]}}

0 commit comments

Comments
 (0)