Skip to content

Commit

Permalink
Get lein partially working under Java 9
Browse files Browse the repository at this point in the history
This includes three changes:

* Exclude the dynapath that comes in from bultitude and pomegranate, and
  depend directly on a newer version that operates properly under Java 9
* Ensure we have a modifiable classloader before asking pomegranate to
  modify it. Before Java 9, the AppClassLoader was a URLClassLoader, and
  therefore modifiable. This is no longer the case with Java 9.
* Remove duplicated classpath init code from `eval-in :leiningen`, and
  replace it with a call to `project/init-lein-classpath`. This required
  making the latter function public.

These changes allow some lein functionality to work under Java 9 - there
is a Java 9 issue with data.xml that needs to be fixed before lein's
tests can all pass (http://dev.clojure.org/jira/browse/DXML-32).
  • Loading branch information
tobias committed May 27, 2016
1 parent 66c7f9a commit 0bf4ffe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions leiningen-core/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
:url "http://www.eclipse.org/legal/epl-v10.html"}
:description "Library for core functionality of Leiningen."
:dependencies [[org.clojure/clojure "1.8.0"]
[bultitude "0.2.8"]
[bultitude "0.2.8" :exclusions [org.tcrawley/dynapath]]
[classlojure "0.6.6"]
[robert/hooke "1.3.0"]
[com.cemerick/pomegranate "0.3.1"]
[com.cemerick/pomegranate "0.3.1" :exclusions [org.tcrawley/dynapath]]
[org.tcrawley/dynapath "0.2.4"]
[org.apache.maven.wagon/wagon-http "2.10"]
[com.hypirion/io "0.3.1"]
[pedantic "0.2.0"]]
Expand Down
4 changes: 1 addition & 3 deletions leiningen-core/src/leiningen/core/eval.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
(:require [classlojure.core :as cl]
[clojure.java.io :as io]
[clojure.string :as string]
[cemerick.pomegranate :as pomegranate]
[cemerick.pomegranate.aether :as aether]
[leiningen.core.project :as project]
[leiningen.core.main :as main]
Expand Down Expand Up @@ -340,8 +339,7 @@
(System/setProperty "clojure.debug" "true"))
;; :dependencies are loaded the same way as plugins in eval-in-leiningen
(project/load-plugins project :dependencies)
(doseq [path (classpath/get-classpath project)]
(pomegranate/add-classpath path))
(project/init-lein-classpath project)
(doseq [opt (get-jvm-args project)
:when (.startsWith opt "-D")
:let [[_ k v] (re-find #"^-D(.*?)=(.*)$" opt)]]
Expand Down
3 changes: 2 additions & 1 deletion leiningen-core/src/leiningen/core/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -878,10 +878,11 @@
(remove (set profiles) included-profiles)
(concat excluded-profiles profiles))))

(defn- init-lein-classpath
(defn init-lein-classpath
"Adds dependencies to Leiningen's classpath if required."
[project]
(when (= :leiningen (:eval-in project))
(ensure-dynamic-classloader)
(doseq [path (classpath/get-classpath project)]
(pomegranate/add-classpath path))))

Expand Down

0 comments on commit 0bf4ffe

Please sign in to comment.