clojure-emacs / enrich-classpath

Enriches Lein/deps.edn dependency trees with Java sources, JDK sources, javadocs, etc
Eclipse Public License 2.0
32 stars 9 forks source link

deps.edn story #2

Closed vemv closed 2 years ago

vemv commented 3 years ago

This library is decoupled from Lein but currently lacks deps.edn examples, integration tests etc.

vemv commented 3 years ago

deps.edn doesn't feature anything plugin-like that affects how deps.edn itself works. IOW, one cannot make it resolve more dependencies, or add more stuff to the classpath, or run custom code as part of its resolution process, etc. Especially from third-party tooling (as opposed to simply writing a deps.edn modification by hand - which is something users do - not us).

So, one would have to craft a script (possibly distributed under the https://github.com/clojure/tools.tools approach) and instruct people to point to that script, replacing clojure: https://github.com/clojure-emacs/cider/blob/5aaaa3a01310f5f9118465f5371a75dfea35b856/cider.el#L146 . The script would be written in .clj and launched with clojure, for simplicity and cross-OS portability.

(note that's for cider.el purposes, it replaces clojure while expecting clojure to run it... funny, but not complex)

The script would do something like this:

(let [clojure "clojure"
      normal-classpath (sh clojure "Spath") ;; obtain a 'base' classpath by using `clojure` normally
      enriched-classpath (... ;; invoke enrich-classpath here and obtain a classpath to be appended
                          )
      final-classpath (str normal-classpath
                           ":"
                           ;; important! the enriched classpath must go at tail position
                           enriched-classpath)]
  (sh clojure "-Scp" final-classpath ARGS))