2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -20,7 +20,7 @@ install-deps: install-base
install-plugin: install-base
cd lein-plugin; lein with-profile -user install

# Usage: PROJECT_VERSION=1.18.2 make install
# Usage: PROJECT_VERSION=1.18.4 make install
# PROJECT_VERSION is needed because it's not computed dynamically
install: install-base install-deps install-plugin

Expand Down
2 changes: 1 addition & 1 deletion examples/Makefile
Expand Up @@ -30,7 +30,7 @@ DEPS_MAIN_OPTS ?= "-M:dev:test"

# The enrich-classpath version to be injected.
# Feel free to upgrade this.
ENRICH_CLASSPATH_VERSION="1.18.2"
ENRICH_CLASSPATH_VERSION="1.18.4"

# Create and cache a `java` command. project.clj is mandatory; the others are optional but are taken into account for cache recomputation.
# It's important not to silence with step with @ syntax, so that Enrich progress can be seen as it resolves dependencies.
Expand Down
2 changes: 1 addition & 1 deletion lein-plugin/Makefile
Expand Up @@ -27,7 +27,7 @@ DEPS_MAIN_OPTS ?= "-M:dev:test"

# The enrich-classpath version to be injected.
# Feel free to upgrade this.
ENRICH_CLASSPATH_VERSION="1.18.2"
ENRICH_CLASSPATH_VERSION="1.18.4"

# Create and cache a `java` command. project.clj is mandatory; the others are optional but are taken into account for cache recomputation.
# It's important not to silence with step with @ syntax, so that Enrich progress can be seen as it resolves dependencies.
Expand Down
2 changes: 1 addition & 1 deletion tools.deps/Makefile
Expand Up @@ -27,7 +27,7 @@ DEPS_MAIN_OPTS ?= "-M:dev:test"

# The enrich-classpath version to be injected.
# Feel free to upgrade this.
ENRICH_CLASSPATH_VERSION="1.18.2"
ENRICH_CLASSPATH_VERSION="1.18.4"

# Create and cache a `java` command. project.clj is mandatory; the others are optional but are taken into account for cache recomputation.
# It's important not to silence with step with @ syntax, so that Enrich progress can be seen as it resolves dependencies.
Expand Down
8 changes: 6 additions & 2 deletions tools.deps/src/cider/enrich_classpath/clojure.clj
Expand Up @@ -49,8 +49,8 @@
deps-filename (str (io/file pwd deps-edn-filename))
{original-deps :deps
:keys [paths libs :mvn/repos]
calculated-jvm-opts :jvm-opts
{:keys [extra-paths main-opts classpath-overrides]} :argmap
{:keys [extra-paths main-opts classpath-overrides]
calculated-jvm-opts :jvm-opts} :argmap
:as basis} (with-dir deps-dir
;; `with-dir` allows us to use relative directories unrelated to the JVM's CWD.
(tools.deps/create-basis {:aliases aliases
Expand Down Expand Up @@ -208,6 +208,10 @@
(jdk/jdk8?))
[]
[(str "-J" jdk/javac-code-opens)]))
(into (if-not main
[]
(mapv (partial str "-J")
calculated-jvm-opts)))
(into (if (seq main-opts)
main-opts
[]))
Expand Down
2 changes: 1 addition & 1 deletion tools.deps/src/cider/enrich_classpath/clojure.sh
Expand Up @@ -37,7 +37,7 @@ else
cd "$there"

# enrich-classpath will emit a command starting by "clojure", or print a stacktrace:
output=$(2>&1 "$clojure" -Sforce -Srepro -J-XX:-OmitStackTraceInFastThrow -J-Dclojure.main.report=stderr -Sdeps '{:deps {mx.cider/tools.deps.enrich-classpath {:mvn/version "1.18.2"}}}' -M -m cider.enrich-classpath.clojure "$clojure" "$here" "true" "$@")
output=$(2>&1 "$clojure" -Sforce -Srepro -J-XX:-OmitStackTraceInFastThrow -J-Dclojure.main.report=stderr -Sdeps '{:deps {mx.cider/tools.deps.enrich-classpath {:mvn/version "1.18.4"}}}' -M -m cider.enrich-classpath.clojure "$clojure" "$here" "true" "$@")
cmd=$(tail -n1 <(echo "$output"))

cd "$here"
Expand Down
2 changes: 2 additions & 0 deletions tools.deps/test-resources/jvm-opts/deps.edn
@@ -0,0 +1,2 @@
{:aliases {:foo {:jvm-opts ["--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"
"-XstartOnFirstThread"]}}}
26 changes: 26 additions & 0 deletions tools.deps/test/integration/cider/enrich_classpath/clojure.clj
Expand Up @@ -150,3 +150,29 @@
false)]
(is (string/includes? cp "-e \"(println \\\"foo\\\")\"")
"Escapes the -e value")))

(when-not (jdk/jdk8?)
(deftest jvm-opts
(testing "https://github.com/clojure-emacs/enrich-classpath/issues/56"
(let [cp (sut/impl "clojure"
"deps.edn"
(str (io/file (System/getProperty "user.dir") "test-resources" "jvm-opts"))
["-M:foo"]
false)]
(is (not (string/includes? cp "-M"))
"Removes -M")

(assert (pos? (long (string/index-of cp "-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"))))
(is (= (string/index-of cp "-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED")
(string/last-index-of cp "-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"))
"Doesn't add this flag twice")

(assert (pos? (long (string/index-of cp "-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED"))))
(is (= (string/index-of cp "-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED")
(string/last-index-of cp "-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED"))
"Doesn't add this flag twice")

(is (string/ends-with? cp (str "-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED "
"-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED "
"-J-XstartOnFirstThread"))
"Adds -J-XstartOnFirstThread as derived from -M, using the same format as other -J options")))))