Skip to content

Commit

Permalink
add clojure 1.12 alpha 2; remove old add-libs stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
seancorfield committed Apr 14, 2023
1 parent 6f973a4 commit b343b84
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 51 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

This is my personal `.clojure/deps.edn` file providing useful `clj` aliases drawn from a variety of projects. It is published to GitHub so I can keep all my computers sync'd up -- and to provide a range of examples that folks new to the Clojure CLI might find helpful.

**Several git dependencies here assume you have at least Clojure CLI 1.10.3.933!**
**Several git dependencies here assume you have at least Clojure CLI 1.11.1.1273!**

In addition, my `.clojure/tools/` folder is also here, containing the tools that I've installed globally, via the latest Clojure CLI (was 1.11.1.1129 when I last updated this) -- see [Tool installation and invocation](https://clojure.org/reference/deps_and_cli#tool_install) in the Deps and CLI Reference. As I add global tools, I am removing them as aliases.
In addition, my `.clojure/tools/` folder is also here, containing the tools that I've installed globally, via the latest Clojure CLI (was 1.11.1.1273 when I last updated this) -- see [Tool installation and invocation](https://clojure.org/reference/deps_and_cli#tool_install) in the Deps and CLI Reference. As I add global tools, I am removing them as aliases.

The main alias I use here is `:dev/repl` which starts various combinations of REPL tooling. See [**The `:dev/repl` Alias**](#the-devrepl-alias) below for more details.

Expand Down Expand Up @@ -73,7 +73,7 @@ There are aliases to pull in various useful testing and debugging tools:
* `:bench` -- pulls in the latest stable release of [Criterium](https://github.com/hugoduncan/criterium/) for benchmarking your code

There are aliases to pull in and start various REPL-related tools:
* `:dev/repl` -- depending on what is on your classpath, start Rebel Readline, with a Socket REPL (if requested -- note that "port 0" will dynamically select an available port and print it out), but `SOCKET_REPL_PORT` env var and `socket-repl-port` property override, saves port to `.socket-repl-port` file for next time);
* `:dev/repl` -- depending on what is on your classpath, start Rebel Readline, with a Socket REPL (if requested -- note that "port 0" will dynamically select an available port and print it out), but `SOCKET_REPL_PORT` env var and `socket-repl-port` property override, saves port to `.socket-repl-port` file for next time;
* usage:
* `clj -M:portal:dev/repl` -- basic REPL with Portal or
* `clojure -M:rebel:dev/repl` -- Rebel Readline REPL or
Expand All @@ -98,7 +98,7 @@ There are aliases to pull in and start various REPL-related tools:

There are aliases to pull in specific versions of Clojure:
* `:master` -- Clojure 1.12.0-master-SNAPSHOT
* `:1.12` -- Clojure 1.12.0-alpha1
* `:1.12` -- Clojure 1.12.0-alpha2
* `:1.11` -- Clojure 1.11.1 -- see [changes to Clojure in version 1.11.1](https://github.com/clojure/clojure/blob/master/changes.md)
* `:1.11.0` -- Clojure 1.11.0
* `:1.10` -- Clojure 1.10.3
Expand All @@ -109,8 +109,7 @@ There are aliases to pull in specific versions of Clojure:
* `:1.8` -- Clojure 1.8.0
* ... back to `:1.0` (note: `:1.5` is actually Clojure 1.5.1 to avoid a bug in Clojure 1.5.0, and `:1.2` is 1.2.1)

For the _EXPERIMENTAL_ `add-libs` function (`clojure.tools.deps.alpha.repl/add-libs`):
* `:add-libs` -- pulls in the `add-lib3` branch of [org.clojure/tools.deps.alpha](https://github.com/clojure/tools.deps.alpha); see the example `load-master` function in the comments in my `deps.edn`; this was previously called `:deps` but I realized that conflicted with the default `:deps` alias in the Clojure CLI install; be aware that `add-libs` is unsupported and likely to break or go away as `tools.deps.alpha` and Clojure both evolve. _[recently renamed from `:add-lib` to `:add-libs` to reflect the name change in the `add-lib3` branch!]_
> Note: the _EXPERIMENTAL_ `:add-libs` alias has been removed -- use the [`clojure.repl.deps`](https://clojure.github.io/clojure/branch-master/clojure.repl-api.html#clojure.repl.deps) in Clojure 1.12.0 Alpha 2 or later instead!
## The `:dev/repl` Alias

Expand Down Expand Up @@ -142,6 +141,6 @@ Connect to the Socket REPL, write your code as `.cljc` files, and you'll have th

# License

Copyright © 2018-2022 Sean Corfield
Copyright © 2018-2023 Sean Corfield

Distributed under the Apache Software License version 2.0.
36 changes: 5 additions & 31 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -105,35 +105,9 @@
;; latest 1.11 is 1.11.1 but you can ask for earlier versions:
:1.11 {:override-deps {org.clojure/clojure {:mvn/version "1.11.1"}}}
:1.11.0 {:override-deps {org.clojure/clojure {:mvn/version "1.11.0"}}}
;; current 1.12 release is Alpha 1:
:1.12 {:override-deps {org.clojure/clojure {:mvn/version "1.12.0-alpha1"}}}
;; current 1.12 release is Alpha 2:
;; - the functionality formerly requiring the :add-libs alias for the
;; branch of tools.deps.alpha is now a part of clojure itself!
:1.12 {:override-deps {org.clojure/clojure {:mvn/version "1.12.0-alpha2"}}}
;; master is currently 1.12:
:master {:override-deps {org.clojure/clojure {:mvn/version "1.12.0-master-SNAPSHOT"}}}

:add-libs ; to get access to clojure.tools.deps.alpha.repl/add-libs
;; IMPORTANT NOTE: this is the new add-lib3 branch but is still a work
;; in progress and likely to break/change as the core team's work
;; continues on integrating some add-lib-like functionality officially
;; into either t.d.a or perhaps Clojure itself; in addition, the default
;; install of the Clojure CLI includes a :deps alias to the version of
;; t.d.a that is included in the install, so I renamed :deps to :add-lib!
;; CAVEAT: since this is a git dependency, it doesn't bring in any of
;; the compiled Java code so S3 Maven repos are not accessible via this
;; alias (which the released t.d.a provides).
;; - now you can add new deps to a running REPL:
;; (require '[clojure.tools.deps.alpha.repl :refer [add-libs]])
;; (add-libs '{some/library {:mvn/version "RELEASE"}})
;; - and you can git deps too; here's how to get the master version of a lib:
;; (require '[clojure.tools.gitlibs :as gitlibs])
;; (defn load-master [lib]
;; (let [git (str "https://github.com/" lib ".git")]
;; (add-libs {lib {:git/url git :sha (gitlibs/resolve git "master")}})))
;; - e.g., using the GitHub path (not the usual Maven group/artifact):
;; (load-master 'clojure/tools.trace)
{:extra-deps {org.clojure/tools.deps.alpha ; add-lib3 branch
{:git/url "https://github.com/clojure/tools.deps.alpha"
:sha "e4fb92eef724fa39e29b39cc2b1a850567d490dd"}}
;; this ensures we have a DynamicClassLoader, which is needed for
;; add-libs to work, if we're starting other processes via aliases
;; such as a socket REPL or Cognitect's REBL etc
:main-opts ["-e" "(->>(Thread/currentThread)(.getContextClassLoader)(clojure.lang.DynamicClassLoader.)(.setContextClassLoader,(Thread/currentThread)))"]}}}
:master {:override-deps {org.clojure/clojure {:mvn/version "1.12.0-master-SNAPSHOT"}}}}}
14 changes: 1 addition & 13 deletions src/org/corfield/dev/repl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
(catch Throwable _)))))

(defn- start-repl
"Ensures we have a DynamicClassLoader, in case we want to use
add-libs from the add-lib3 branch of clojure.tools.deps.alpha (to
load new libraries at runtime).
If Jedi Time is on the classpath, require it (so that Java Time
"If Jedi Time is on the classpath, require it (so that Java Time
objects will support datafy/nav).
If Datomic Dev Datafy is on the classpath, require it (so that
Expand All @@ -57,14 +53,6 @@
* if Rebel Readline is on the classpath then start that, else
* start a plain ol' Clojure REPL."
[]
;; set up the DCL:
(try
(let [cl (.getContextClassLoader (Thread/currentThread))]
(.setContextClassLoader (Thread/currentThread) (clojure.lang.DynamicClassLoader. cl)))
(catch Throwable t
(println "Unable to establish a DynamicClassLoader!")
(println (ex-message t))))

;; jedi-time?
(try
(require 'jedi-time.core)
Expand Down

0 comments on commit b343b84

Please sign in to comment.