Skip to content

Commit

Permalink
Use XDG compliant caching folder
Browse files Browse the repository at this point in the history
Fixes #47
  • Loading branch information
vemv committed Sep 12, 2023
1 parent ae2ee7c commit 23f324a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lein-plugin/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
:abort
;; :pedantic? can be problematic for certain local dev workflows:
false)
:profiles {:test {:dependencies [[leiningen "2.10.0" :exclusions [nrepl]]]}
:profiles {:dev {:source-paths ["../src" "../test"]}
:test {:dependencies [[leiningen "2.10.0" :exclusions [nrepl]]]}
:eastwood {:plugins [[jonase/eastwood "1.4.0"]]
:eastwood {:add-linters [:boxed-math
:performance]}}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(t))))

(def classpath-starts-with
"~/enrich-classpath/lein-plugin/test:~/enrich-classpath/lein-plugin/src:~/enrich-classpath/lein-plugin/resources:~/enrich-classpath/lein-plugin/the-compile-path:~/.m2/repository/clj-time/clj-time/0.11.0/clj-time-0.11.0.jar:~/.m2/repository/org/slf4j/jul-to-slf4j/1.7.20/jul-to-slf4j-1.7.20.jar:~/.m2/repository/com/typesafe/config/1.2.0/config-1.2.0.jar:~/.m2/repository/org/clojure/java.classpath/0.2.2/java.classpath-0.2.2.jar:~/.m2/repository/puppetlabs/typesafe-config/0.1.5/typesafe-config-0.1.5.jar:~/.m2/repository/puppetlabs/trapperkeeper/3.0.0/trapperkeeper-3.0.0.jar:~/.m2/repository/org/clojure/tools.logging/0.4.0/tools.logging-0.4.0.jar:~/.m2/repository/tigris/tigris/0.1.1/tigris-0.1.1.jar:~/.m2/repository/org/eclipse/jetty/jetty-http/9.4.28.v20200408/jetty-http-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/jetty-io/9.4.28.v20200408/jetty-io-9.4.28.v20200408.jar:~/.m2/repository/org/tcrawley/dynapath/0.2.5/dynapath-0.2.5.jar:~/.m2/repository/org/codehaus/janino/janino/3.0.8/janino-3.0.8.jar:~/.m2/repository/ring/ring-servlet/1.5.0/ring-servlet-1.5.0.jar:~/.m2/repository/org/clojure/tools.macro/0.1.5/tools.macro-0.1.5.jar:~/.m2/repository/clj-commons/fs/1.5.1/fs-1.5.1.jar:~/.m2/repository/beckon/beckon/0.1.1/beckon-0.1.1.jar:~/.m2/repository/digest/digest/1.4.3/digest-1.4.3.jar:~/.m2/repository/org/codehaus/janino/commons-compiler/3.0.8/commons-compiler-3.0.8.jar:~/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:~/.m2/repository/ring/ring-codec/1.0.0/ring-codec-1.0.0.jar:~/.m2/repository/org/eclipse/jetty/websocket/websocket-common/9.4.28.v20200408/websocket-common-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/jetty-xml/9.4.28.v20200408/jetty-xml-9.4.28.v20200408.jar:~/.m2/repository/org/clojure/tools.analyzer/0.6.9/tools.analyzer-0.6.9.jar:~/.m2/repository/prismatic/schema/1.1.9/schema-1.1.9.jar:~/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-smile/2.9.0/jackson-dataformat-smile-2.9.0.jar:~/.m2/repository/puppetlabs/trapperkeeper-webserver-jetty9/4.1.0/trapperkeeper-webserver-jetty9-4.1.0.jar:~/.m2/repository/org/gnu/gettext/libintl/0.18.3/libintl-0.18.3.jar:~/.m2/repository/org/eclipse/jetty/jetty-server/9.4.28.v20200408/jetty-server-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/jetty-util/9.4.28.v20200408/jetty-util-9.4.28.v20200408.jar:~/.m2/repository/org/clojure/tools.reader/1.0.0-beta4/tools.reader-1.0.0-beta4.jar:~/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:~/.m2/repository/prismatic/plumbing/0.4.2/plumbing-0.4.2.jar:~/.m2/repository/org/eclipse/jetty/jetty-continuation/9.4.28.v20200408/jetty-continuation-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/jetty-security/9.4.28.v20200408/jetty-security-9.4.28.v20200408.jar:~/.m2/repository/org/clojure/core.memoize/0.5.9/core.memoize-0.5.9.jar:~/.m2/repository/org/clojure/tools.cli/0.3.6/tools.cli-0.3.6.jar:~/.m2/repository/org/flatland/ordered/1.5.7/ordered-1.5.7.jar:~/.m2/repository/org/flatland/useful/0.11.6/useful-0.11.6.jar:~/.m2/repository/org/eclipse/jetty/jetty-jmx/9.4.28.v20200408/jetty-jmx-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/websocket/websocket-servlet/9.4.28.v20200408/websocket-servlet-9.4.28.v20200408.jar:~/.m2/repository/puppetlabs/i18n/0.8.0/i18n-0.8.0.jar:~/.m2/repository/org/eclipse/jetty/jetty-servlet/9.4.28.v20200408/jetty-servlet-9.4.28.v20200408.jar:~/.m2/repository/cheshire/cheshire/5.8.0/cheshire-5.8.0.jar:~/.m2/repository/de/kotka/lazymap/3.1.0/lazymap-3.1.0.jar:~/.m2/repository/org/yaml/snakeyaml/1.24/snakeyaml-1.24.jar:~/.m2/repository/org/ow2/asm/asm-all/4.2/asm-all-4.2.jar:~/.m2/repository/org/clojure/data.priority-map/0.0.7/data.priority-map-0.0.7.jar:~/.m2/repository/cpath-clj/cpath-clj/0.1.2/cpath-clj-0.1.2.jar:~/.m2/repository/org/eclipse/jetty/jetty-client/9.4.28.v20200408/jetty-client-9.4.28.v20200408.jar:~/.m2/repository/puppetlabs/kitchensink/3.0.0/kitchensink-3.0.0.jar:~/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.0/jackson-core-2.9.0.jar:~/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:~/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:~/.m2/repository/clj-commons/clj-yaml/0.7.0/clj-yaml-0.7.0.jar:~/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-cbor/2.9.0/jackson-dataformat-cbor-2.9.0.jar:~/.m2/repository/org/ini4j/ini4j/0.5.2/ini4j-0.5.2.jar:~/.m2/repository/ch/qos/logback/logback-access/1.2.3/logback-access-1.2.3.jar:~/.m2/repository/nrepl/nrepl/1.0.0/nrepl-1.0.0.jar:~/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.20/log4j-over-slf4j-1.7.20.jar:~/.m2/repository/org/eclipse/jetty/websocket/websocket-api/9.4.28.v20200408/websocket-api-9.4.28.v20200408.jar:~/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar:~/.m2/repository/slingshot/slingshot/0.12.2/slingshot-0.12.2.jar:~/.m2/repository/org/apache/commons/commons-compress/1.18/commons-compress-1.18.jar:~/.m2/repository/org/eclipse/jetty/websocket/websocket-client/9.4.28.v20200408/websocket-client-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/jetty-webapp/9.4.28.v20200408/jetty-webapp-9.4.28.v20200408.jar:~/.m2/repository/puppetlabs/ssl-utils/3.0.4/ssl-utils-3.0.4.jar:~/.m2/repository/org/clojure/core.cache/0.6.5/core.cache-0.6.5.jar:~/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:~/.m2/repository/org/clojure/java.jmx/0.3.4/java.jmx-0.3.4.jar:~/.m2/repository/org/clojure/core.async/0.4.490/core.async-0.4.490.jar:~/.m2/repository/org/eclipse/jetty/jetty-proxy/9.4.28.v20200408/jetty-proxy-9.4.28.v20200408.jar:~/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:~/.m2/repository/joda-time/joda-time/2.8.2/joda-time-2.8.2.jar:~/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar:~/.m2/repository/puppetlabs/trapperkeeper-filesystem-watcher/1.2.0/trapperkeeper-filesystem-watcher-1.2.0.jar:~/.m2/repository/org/eclipse/jetty/websocket/websocket-server/9.4.28.v20200408/websocket-server-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/jetty-servlets/9.4.28.v20200408/jetty-servlets-9.4.28.v20200408.jar:~/.m2/repository/org/clojure/tools.analyzer.jvm/0.7.2/tools.analyzer.jvm-0.7.2.jar:~/.m2/repository/org/tukaani/xz/1.8/xz-1.8.jar:~/.mx.cider/enrich-classpath/<shortened>.jar:~/.mx.cider/enrich-classpath/<shortened>.jar:")
"~/enrich-classpath/lein-plugin/test:~/enrich-classpath/lein-plugin/src:~/enrich-classpath/lein-plugin/resources:~/enrich-classpath/lein-plugin/the-compile-path:~/.m2/repository/clj-time/clj-time/0.11.0/clj-time-0.11.0.jar:~/.m2/repository/org/slf4j/jul-to-slf4j/1.7.20/jul-to-slf4j-1.7.20.jar:~/.m2/repository/com/typesafe/config/1.2.0/config-1.2.0.jar:~/.m2/repository/org/clojure/java.classpath/0.2.2/java.classpath-0.2.2.jar:~/.m2/repository/puppetlabs/typesafe-config/0.1.5/typesafe-config-0.1.5.jar:~/.m2/repository/puppetlabs/trapperkeeper/3.0.0/trapperkeeper-3.0.0.jar:~/.m2/repository/org/clojure/tools.logging/0.4.0/tools.logging-0.4.0.jar:~/.m2/repository/tigris/tigris/0.1.1/tigris-0.1.1.jar:~/.m2/repository/org/eclipse/jetty/jetty-http/9.4.28.v20200408/jetty-http-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/jetty-io/9.4.28.v20200408/jetty-io-9.4.28.v20200408.jar:~/.m2/repository/org/tcrawley/dynapath/0.2.5/dynapath-0.2.5.jar:~/.m2/repository/org/codehaus/janino/janino/3.0.8/janino-3.0.8.jar:~/.m2/repository/ring/ring-servlet/1.5.0/ring-servlet-1.5.0.jar:~/.m2/repository/org/clojure/tools.macro/0.1.5/tools.macro-0.1.5.jar:~/.m2/repository/clj-commons/fs/1.5.1/fs-1.5.1.jar:~/.m2/repository/beckon/beckon/0.1.1/beckon-0.1.1.jar:~/.m2/repository/digest/digest/1.4.3/digest-1.4.3.jar:~/.m2/repository/org/codehaus/janino/commons-compiler/3.0.8/commons-compiler-3.0.8.jar:~/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:~/.m2/repository/ring/ring-codec/1.0.0/ring-codec-1.0.0.jar:~/.m2/repository/org/eclipse/jetty/websocket/websocket-common/9.4.28.v20200408/websocket-common-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/jetty-xml/9.4.28.v20200408/jetty-xml-9.4.28.v20200408.jar:~/.m2/repository/org/clojure/tools.analyzer/0.6.9/tools.analyzer-0.6.9.jar:~/.m2/repository/prismatic/schema/1.1.9/schema-1.1.9.jar:~/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-smile/2.9.0/jackson-dataformat-smile-2.9.0.jar:~/.m2/repository/puppetlabs/trapperkeeper-webserver-jetty9/4.1.0/trapperkeeper-webserver-jetty9-4.1.0.jar:~/.m2/repository/org/gnu/gettext/libintl/0.18.3/libintl-0.18.3.jar:~/.m2/repository/org/eclipse/jetty/jetty-server/9.4.28.v20200408/jetty-server-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/jetty-util/9.4.28.v20200408/jetty-util-9.4.28.v20200408.jar:~/.m2/repository/org/clojure/tools.reader/1.0.0-beta4/tools.reader-1.0.0-beta4.jar:~/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:~/.m2/repository/prismatic/plumbing/0.4.2/plumbing-0.4.2.jar:~/.m2/repository/org/eclipse/jetty/jetty-continuation/9.4.28.v20200408/jetty-continuation-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/jetty-security/9.4.28.v20200408/jetty-security-9.4.28.v20200408.jar:~/.m2/repository/org/clojure/core.memoize/0.5.9/core.memoize-0.5.9.jar:~/.m2/repository/org/clojure/tools.cli/0.3.6/tools.cli-0.3.6.jar:~/.m2/repository/org/flatland/ordered/1.5.7/ordered-1.5.7.jar:~/.m2/repository/org/flatland/useful/0.11.6/useful-0.11.6.jar:~/.m2/repository/org/eclipse/jetty/jetty-jmx/9.4.28.v20200408/jetty-jmx-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/websocket/websocket-servlet/9.4.28.v20200408/websocket-servlet-9.4.28.v20200408.jar:~/.m2/repository/puppetlabs/i18n/0.8.0/i18n-0.8.0.jar:~/.m2/repository/org/eclipse/jetty/jetty-servlet/9.4.28.v20200408/jetty-servlet-9.4.28.v20200408.jar:~/.m2/repository/cheshire/cheshire/5.8.0/cheshire-5.8.0.jar:~/.m2/repository/de/kotka/lazymap/3.1.0/lazymap-3.1.0.jar:~/.m2/repository/org/yaml/snakeyaml/1.24/snakeyaml-1.24.jar:~/.m2/repository/org/ow2/asm/asm-all/4.2/asm-all-4.2.jar:~/.m2/repository/org/clojure/data.priority-map/0.0.7/data.priority-map-0.0.7.jar:~/.m2/repository/cpath-clj/cpath-clj/0.1.2/cpath-clj-0.1.2.jar:~/.m2/repository/org/eclipse/jetty/jetty-client/9.4.28.v20200408/jetty-client-9.4.28.v20200408.jar:~/.m2/repository/puppetlabs/kitchensink/3.0.0/kitchensink-3.0.0.jar:~/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.0/jackson-core-2.9.0.jar:~/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:~/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:~/.m2/repository/clj-commons/clj-yaml/0.7.0/clj-yaml-0.7.0.jar:~/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-cbor/2.9.0/jackson-dataformat-cbor-2.9.0.jar:~/.m2/repository/org/ini4j/ini4j/0.5.2/ini4j-0.5.2.jar:~/.m2/repository/ch/qos/logback/logback-access/1.2.3/logback-access-1.2.3.jar:~/.m2/repository/nrepl/nrepl/1.0.0/nrepl-1.0.0.jar:~/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.20/log4j-over-slf4j-1.7.20.jar:~/.m2/repository/org/eclipse/jetty/websocket/websocket-api/9.4.28.v20200408/websocket-api-9.4.28.v20200408.jar:~/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar:~/.m2/repository/slingshot/slingshot/0.12.2/slingshot-0.12.2.jar:~/.m2/repository/org/apache/commons/commons-compress/1.18/commons-compress-1.18.jar:~/.m2/repository/org/eclipse/jetty/websocket/websocket-client/9.4.28.v20200408/websocket-client-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/jetty-webapp/9.4.28.v20200408/jetty-webapp-9.4.28.v20200408.jar:~/.m2/repository/puppetlabs/ssl-utils/3.0.4/ssl-utils-3.0.4.jar:~/.m2/repository/org/clojure/core.cache/0.6.5/core.cache-0.6.5.jar:~/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:~/.m2/repository/org/clojure/java.jmx/0.3.4/java.jmx-0.3.4.jar:~/.m2/repository/org/clojure/core.async/0.4.490/core.async-0.4.490.jar:~/.m2/repository/org/eclipse/jetty/jetty-proxy/9.4.28.v20200408/jetty-proxy-9.4.28.v20200408.jar:~/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:~/.m2/repository/joda-time/joda-time/2.8.2/joda-time-2.8.2.jar:~/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar:~/.m2/repository/puppetlabs/trapperkeeper-filesystem-watcher/1.2.0/trapperkeeper-filesystem-watcher-1.2.0.jar:~/.m2/repository/org/eclipse/jetty/websocket/websocket-server/9.4.28.v20200408/websocket-server-9.4.28.v20200408.jar:~/.m2/repository/org/eclipse/jetty/jetty-servlets/9.4.28.v20200408/jetty-servlets-9.4.28.v20200408.jar:~/.m2/repository/org/clojure/tools.analyzer.jvm/0.7.2/tools.analyzer.jvm-0.7.2.jar:~/.m2/repository/org/tukaani/xz/1.8/xz-1.8.jar:~/.cache/.mx.cider/enrich-classpath/<shortened>.jar:~/.cache/.mx.cider/enrich-classpath/<shortened>.jar:")

(deftest middleware
(let [all (sut/middleware* '{:repl-options {:host "localhost"
Expand Down
4 changes: 2 additions & 2 deletions src/cider/enrich_classpath.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[cider.enrich-classpath.logging :refer [debug info warn]]
[cider.enrich-classpath.source-analysis :refer [bad-source?]]
[cider.enrich-classpath.version :as version]
[cider.enrich-classpath.xdg :as xdg]
[clojure.java.io :as io]
[clojure.string :as string]
[clojure.walk :as walk]
Expand All @@ -21,8 +22,7 @@
(java.util.regex Pattern)))

(def ^String cache-filename
(-> "user.home"
System/getProperty
(-> xdg/cache-root
(File. ".enrich-classpath-cache")
(str)))

Expand Down
4 changes: 2 additions & 2 deletions src/cider/enrich_classpath/jar.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns cider.enrich-classpath.jar
(:require
[cider.enrich-classpath.jdk :as jdk]
[cider.enrich-classpath.xdg :as xdg]
[clojure.java.io :as io]
[clojure.string :as string])
(:import
Expand Down Expand Up @@ -54,8 +55,7 @@ Created-By: mx.cider/enrich-classpath
(seq))]
(let [corpus-crc (-> corpus string/join crc32)
dir-crc (-> "user.dir" System/getProperty crc32)
dir (-> "user.home"
System/getProperty
dir (-> xdg/cache-root
(io/file ".mx.cider" "enrich-classpath" (jdk/digits-str) dir-crc)
(doto .mkdirs))
filename (-> dir
Expand Down
4 changes: 2 additions & 2 deletions src/cider/enrich_classpath/jdk_sources.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[cider.enrich-classpath.jdk :as jdk]
[cider.enrich-classpath.locks :refer [locking-file]]
[cider.enrich-classpath.logging :refer [warn]]
[cider.enrich-classpath.xdg :as xdg]
[clojure.java.io :as io]
[clojure.string :as string])
(:import
Expand Down Expand Up @@ -78,8 +79,7 @@

(defn uncompressed-sources-dir []
(let [id (jdk/digits-str)]
(-> "user.home"
System/getProperty
(-> xdg/cache-root
(io/file base-prefix "unzipped-jdk-sources" id)
str)))

Expand Down
24 changes: 24 additions & 0 deletions src/cider/enrich_classpath/xdg.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(ns cider.enrich-classpath.xdg
(:require
[clojure.string :as string]
[clojure.java.io :as io])
(:import
(java.io File)))

(defn maybe-as-absolute [x]
(try
(let [expanded (-> x (string/replace-first #"^~" (System/getProperty "user.home")))
file (io/file expanded)]
(when (-> file .isAbsolute)
(-> file .mkdirs)
(when (-> file .canWrite)
(-> file .getCanonicalPath))))
(catch Exception _
nil)))

(def cache-root
(or (some-> "XDG_CACHE_HOME"
System/getenv
not-empty
maybe-as-absolute)
(maybe-as-absolute "~/.cache")))

0 comments on commit 23f324a

Please sign in to comment.