Fork me on GitHub
#deps-new
<
2022-01-06
>
dharrigan16:01:07

Ah yes 🙂

dharrigan16:01:17

I'm wondering, would it be an idea to have the templates as a jar? So that instead of having the templates cloned locally, it can fetch and apply? Or perhaps, the templates can also be a pointer to a repo to clone and apply?

seancorfield16:01:03

You can't have templates in a JAR.

seancorfield16:01:02

tools.build requires files on a file system, not resources on the classpath

dharrigan16:01:19

What I'm thinking about is sharing. If I go to the trouble of defining a new template, then it would be nice if the deps-new tool could find those templates for me via some mechanism and clone the repo

dharrigan16:01:34

to like .deps-new/templates/<foo bar> then use that as the basis

dharrigan16:01:36

Right now, I have to do clj-template/clj-template {:local/root "/home/david/development/clojure/clj-template"}}, but would be nice if I could tell deps-new where to clone that repo out locally, then to apply all the goodness that it does

dharrigan16:01:24

clj-template/clj-template {:git/repo ""} something like that

dharrigan16:01:40

then the deps-new would clone that repo to a local folder, and continue onwards.

seancorfield16:01:40

Read the deps-new source. It doesn't currently do anything with fetching dependencies, it doesn't unpack anything.

dharrigan16:01:02

Right, that I understand, but perhaps as a feature request?

seancorfield16:01:50

I don't want to deal with unpacking JARs and maintaining a "cache" tree and staleness and all the other complexity that goes with that.

seancorfield16:01:08

By sticking to local or git deps, t.d.a and the CLI deal with all that for me.

seancorfield17:01:37

This is the entire extent of dealing with the classpath at the moment:

(let [poss-dir (->file template-sym)
        edn-file (str poss-dir "/template.edn")
        paths    (str/split (System/getProperty "java.class.path")
                            (re-pattern (System/getProperty "path.separator")))]
    (some #(let [file (io/file (str % "/" edn-file))]
             (when (.exists file)
               [(.getCanonicalPath (io/file (str % "/" poss-dir)))
                (.getCanonicalPath file)]))
          paths)))

dharrigan17:01:32

it actually does work already!

dharrigan17:01:46

clj-template/clj-template {:git/url ""
                                                     :git/sha "96f0cde2d4b6eab8fb39d0b01cb1d37857660088"}}

seancorfield17:01:12

Yeah, I said git deps work.

seancorfield17:01:04

The README does mention all of this (including the no JAR stuff): The COORDINATES could be something like {:local/root "/path/to/cool-lib"} for a template that exists on the local filesystem, or it could be based on :git/url/:git/sha etc for a template that exists in a git repository. Note: because deps-new is based on tools.build and uses its file copying functions, the template must ultimately live on the filesystem, so :local/root and git-based coordinates are supported, but Maven/Clojars coordinates are not.