Skip to content

Instantly share code, notes, and snippets.

@andradefil
Created July 23, 2026 11:46
Show Gist options
  • Select an option

  • Save andradefil/8343e2b56c05abbba592a24a382626f7 to your computer and use it in GitHub Desktop.

Select an option

Save andradefil/8343e2b56c05abbba592a24a382626f7 to your computer and use it in GitHub Desktop.
scan transient deps over a directory
(require '[clojure.java.io :as io]
'[clojure.java.shell :as shell]
'[clojure.string :as str]
'[clojure.pprint :as pp]
'[clojure.string :as str])
(set! *print-length* 5)
(def root "/Users/filipe.andrade/dev/datomic/repos")
(defn list-directories
"List all directories in a path."
[path]
(->> (.listFiles (io/file path))
(filter #(.isDirectory %))
(remove #(str/starts-with? (.getName %) "."))
(sort-by #(.getName %))))
(defn detect-project
"Detect the project in a path
Returns a map with the project structure detected
- :path a string with the path for the project
- :build-system a keyword with the identified build system or nil
:deps for deps.edn
:maven for pom.xml"
[path]
{:path path
:build-system (cond
(.exists (io/file path "deps.edn")) :deps
(.exists (io/file path "pom.xml")) :maven
:else nil)})
(defn detect-jetty-deps
"Dectect jetty in classpath for a deps.edn project.
Returns a map with keys:
- :jetty? a boolean true when jetty is present
- :output raw output of the project deps
- :project the project used in detection"
[project]
(let [{:keys [out]} (shell/sh "clojure" "-Stree" :dir (:path project))]
(if (str/includes? out "jetty")
{:jetty? true
#_#_:output out
:project project}
{:jetty? false
:project project})))
(comment
(->> (list-directories root)
(map detect-project)
(map detect-jetty-deps)
(filter :jetty?))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment