|
1 |
| -;;;; The following code allows to add the JDK sources without `dynapath` being present. |
2 |
| - |
3 |
| -(require '[clojure.java.io :as io]) |
4 |
| - |
5 |
| -(import '[java.util.zip ZipInputStream] |
6 |
| - '[java.io FileOutputStream]) |
7 |
| - |
8 |
| -(defmacro while-let [[sym expr] & body] |
9 |
| - `(loop [~sym ~expr] |
10 |
| - (when ~sym |
11 |
| - ~@body |
12 |
| - (recur ~expr)))) |
13 |
| - |
14 |
| -(defn jdk-find [f] |
15 |
| - (let [home (io/file (System/getProperty "java.home")) |
16 |
| - parent (.getParentFile home) |
17 |
| - paths [(io/file home f) |
18 |
| - (io/file home "lib" f) |
19 |
| - (io/file parent f) |
20 |
| - (io/file parent "lib" f)]] |
21 |
| - (->> paths (filter #(.canRead ^java.io.File %)) first str))) |
22 |
| - |
23 |
| -(def jdk-sources |
24 |
| - (let [java-path->zip-path (fn [path] |
25 |
| - (some-> (io/resource path) |
26 |
| - ^java.net.JarURLConnection (. openConnection) |
27 |
| - (. getJarFileURL) |
28 |
| - io/as-file |
29 |
| - str))] |
30 |
| - (or (java-path->zip-path "java.base/java/lang/Object.java") ; JDK9+ |
31 |
| - (java-path->zip-path "java/lang/Object.java") ; JDK8- |
32 |
| - (jdk-find "src.zip")))) |
33 |
| - |
34 |
| -(defn uncompress [path target] |
35 |
| - (let [zis (-> target io/input-stream ZipInputStream.)] |
36 |
| - (while-let [entry (-> zis .getNextEntry)] |
37 |
| - (let [size (-> entry .getSize) |
38 |
| - bytes (byte-array 1024) |
39 |
| - dest (->> entry .getName (io/file path)) |
40 |
| - dir (-> entry .getName (clojure.string/split #"/") butlast) |
41 |
| - _ (->> (clojure.string/join "/" dir) (java.io.File. path) .mkdirs) |
42 |
| - output (FileOutputStream. dest)] |
43 |
| - (loop [len (-> zis (.read bytes))] |
44 |
| - (when (pos? len) |
45 |
| - (-> output (.write bytes 0 len)) |
46 |
| - (recur (-> zis (.read bytes))))) |
47 |
| - (-> output .close))))) |
48 |
| - |
49 |
| -(defn unzipped-jdk-source [] |
50 |
| - (when-not (-> "unzipped-jdk-source" io/file .exists) |
51 |
| - (let [choice jdk-sources] |
52 |
| - (-> "unzipped-jdk-source" io/file .mkdirs) |
53 |
| - ;; For some reason simply adding a .zip to the classpath doesn't work, so one has to uncompress the contents: |
54 |
| - (uncompress "./unzipped-jdk-source/" choice))) |
55 |
| - "unzipped-jdk-source") |
56 |
| - |
57 | 1 | (def jdk8? (->> "java.version" System/getProperty (re-find #"^1.8.")))
|
58 | 2 |
|
59 |
| -;;;; Project definition |
60 |
| - |
61 | 3 | (defproject cider/orchard "0.7.3"
|
62 | 4 | :description "A fertile ground for Clojure tooling"
|
63 | 5 | :url "https://github.com/clojure-emacs/orchard"
|
64 | 6 | :license {:name "Eclipse Public License"
|
65 | 7 | :url "http://www.eclipse.org/legal/epl-v10.html"}
|
66 | 8 | :scm {:name "git" :url "https://github.com/clojure-emacs/orchard"}
|
67 | 9 |
|
68 |
| - :dependencies [[org.tcrawley/dynapath "1.1.0"] |
69 |
| - [org.clojure/clojurescript "1.10.520"]] |
| 10 | + :dependencies [[org.clojure/clojurescript "1.10.520"]] |
70 | 11 | :exclusions [org.clojure/clojure] ; see versions matrix below
|
71 | 12 |
|
72 | 13 | :aliases {"bump-version" ["change" "version" "leiningen.release/bump-version"]}
|
|
83 | 24 | :password :env/clojars_password
|
84 | 25 | :sign-releases false}]]
|
85 | 26 |
|
86 |
| - :jvm-opts ["-Dorchard.use-dynapath=true" |
87 |
| - "-Dclojure.main.report=stderr"] |
| 27 | + :jvm-opts ["-Dclojure.main.report=stderr"] |
88 | 28 |
|
89 | 29 | :source-paths ["src" "src-jdk8" "src-newer-jdks"]
|
90 | 30 | :test-paths ~(cond-> ["test"]
|
|
110 | 50 | :resource-paths ["test-resources"
|
111 | 51 | "not-a.jar"
|
112 | 52 | "does-not-exist.jar"]
|
| 53 | + :java-source-paths ["test-java"] |
113 | 54 | ;; Initialize the cache verbosely, as usual, so that possible issues can be more easily diagnosed:
|
114 | 55 | :jvm-opts ["-Dorchard.initialize-cache.silent=false"
|
115 |
| - "-Dorchard.internal.test-suite-running=true"]} |
| 56 | + "-Dorchard.internal.test-suite-running=true" |
| 57 | + "-Dorchard.internal.has-enriched-classpath=false"]} |
116 | 58 |
|
117 |
| - :no-dynapath {:jvm-opts ["-Dorchard.use-dynapath=false"] |
118 |
| - :resource-paths [~(unzipped-jdk-source)] |
119 |
| - :plugins ~(if jdk8? |
120 |
| - '[[lein-jdk-tools "0.1.1"]] |
121 |
| - [])} |
| 59 | + :enrich-classpath {:plugins [[mx.cider/enrich-classpath "1.5.0"]] |
| 60 | + :middleware [cider.enrich-classpath/middleware] |
| 61 | + :jvm-opts ["-Dorchard.internal.has-enriched-classpath=true"]} |
122 | 62 |
|
123 | 63 | ;; Development tools
|
124 | 64 | :dev {:dependencies [[org.clojure/tools.namespace "1.1.0"]]
|
|
132 | 72 | letfn [[:block 1] [:inner 2]]}}}
|
133 | 73 |
|
134 | 74 | :clj-kondo [:test
|
135 |
| - {:dependencies [[clj-kondo "2021.10.19"]]}] |
136 |
| - |
137 |
| - :eastwood {:plugins [[jonase/eastwood "0.9.9"]] |
138 |
| - :eastwood {:exclude-namespaces [~(if jdk8? |
139 |
| - 'orchard.java.parser |
140 |
| - 'orchard.java.legacy-parser)]}}}) |
| 75 | + {:dependencies [[clj-kondo "2021.12.01"]]}] |
| 76 | + |
| 77 | + :eastwood {:plugins [[jonase/eastwood "1.0.0"]] |
| 78 | + :eastwood {:exclude-namespaces ~(cond-> [] |
| 79 | + jdk8? |
| 80 | + (conj 'orchard.java.parser) |
| 81 | + |
| 82 | + (or (not jdk8?) |
| 83 | + (not (-> "TEST_PROFILES" |
| 84 | + System/getenv |
| 85 | + (doto assert) |
| 86 | + (.contains "enrich-classpath")))) |
| 87 | + (conj 'orchard.java.legacy-parser))}}}) |
0 commit comments