Fork me on GitHub
#leiningen
<
2017-10-05
>
nbardy22:10:21

Is there way to get the lein config from project.clj in an arbitrary clojure process started from lein run? For example, So I could do something like (get-in config :source-paths)

nbardy22:10:36

I guess “is there a way” wasn’t the right question, but rather is there a simple user friendly way.

danielcompton22:10:35

Not sure if I understand your question, but lein pprint will print stuff out to the console (pprint is a plugin)

danielcompton22:10:25

Don't know if you can get the project map from within another process, but you can look for the project.clj, it's a resource

danielcompton22:10:48

Something like META-INF/leiningen/your-group/your-artifact/project.clj

danielcompton22:10:12

although there is a distinction between built JARs/Uberjars, and a running project, not sure if all that info is available for running projects

noisesmith23:10:20

the fun thing is that if you look for (io/resource "project.clj") you get the project.clj of a random dep

noisesmith23:10:29

but not likely to be your own project.clj

noisesmith23:10:58

oh wow this is fun

user=> (pprint (enumeration-seq (.getResources (.getContextClassLoader (Thread/currentThread)) "project.clj")))
(#object[java.net.URL 0x5935f386 "jar:file:/Users/justin/.m2/repository/clj-kafka/clj-kafka/0.3.4/clj-kafka-0.3.4.jar!/project.clj"]
 #object[java.net.URL 0x2f92208b "jar:file:/Users/justin/.m2/repository/com/taoensso/timbre/4.10.0/timbre-4.10.0.jar!/project.clj"]
 #object[java.net.URL 0x1704baf2 "jar:file:/Users/justin/.m2/repository/aviary/condor/0.2.46/condor-0.2.46.jar!/project.clj"]
 #object[java.net.URL 0x19800895 "jar:file:/Users/justin/.m2/repository/aleph/aleph/0.4.3/aleph-0.4.3.jar!/project.clj"]
 #object[java.net.URL 0x1af08630 "jar:file:/Users/justin/.m2/repository/io/aleph/dirigiste/0.1.5/dirigiste-0.1.5.jar!/project.clj"]
 #object[java.net.URL 0x24d87b9d "jar:file:/Users/justin/.m2/repository/littlebird-aviary/audubon/0.4.39/audubon-0.4.39.jar!/project.clj"]
 #object[java.net.URL 0x16b986de "jar:file:/Users/justin/.m2/repository/hickory/hickory/0.7.1/hickory-0.7.1.jar!/project.clj"]
 #object[java.net.URL 0xfe4f03c "jar:file:/Users/justin/.m2/repository/geo-clj/geo-clj/0.3.6/geo-clj-0.3.6.jar!/project.clj"]
 #object[java.net.URL 0x113b36f6 "jar:file:/Users/justin/.m2/repository/tigris/tigris/0.1.1/tigris-0.1.1.jar!/project.clj"]
 #object[java.net.URL 0x76d8a3df "jar:file:/Users/justin/.m2/repository/clj-time/clj-time/0.13.0/clj-time-0.13.0.jar!/project.clj"]
 #object[java.net.URL 0x2c0d44ac "jar:file:/Users/justin/.m2/repository/bultitude/bultitude/0.2.2/bultitude-0.2.2.jar!/project.clj"]
 #object[java.net.URL 0x4402401 "jar:file:/Users/justin/.m2/repository/clojurewerkz/support/1.1.0/support-1.1.0.jar!/project.clj"]
 #object[java.net.URL 0x4c043ef9 "jar:file:/Users/justin/.m2/repository/trptcolin/versioneer/0.1.1/versioneer-0.1.1.jar!/project.clj"]
 #object[java.net.URL 0x7ff1aafd "jar:file:/Users/justin/.m2/repository/potemkin/potemkin/0.4.3/potemkin-0.4.3.jar!/project.clj"]
 #object[java.net.URL 0x391fa98b "jar:file:/Users/justin/.m2/repository/manifold/manifold/0.1.6/manifold-0.1.6.jar!/project.clj"]
 #object[java.net.URL 0x3cfaf285 "jar:file:/Users/justin/.m2/repository/com/taoensso/truss/1.5.0/truss-1.5.0.jar!/project.clj"]
...

noisesmith23:10:09

each of those can be slurped