Skip to content

Commit

Permalink
move classpath-related functions from compile to classpath module
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Compall authored and technomancy committed Apr 7, 2010
1 parent ba96445 commit 625c5de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
21 changes: 18 additions & 3 deletions src/leiningen/classpath.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
(ns leiningen.classpath
(:use (clojure.contrib [seq-utils :only (flatten)]
[str-utils :only (str-join)])
(leiningen [compile :only (find-lib-jars make-path)])))
(:use (clojure.contrib [java-utils :only (file)]
[seq-utils :only (flatten)]
[str-utils :only (str-join)]))
(:import org.apache.tools.ant.types.Path))

(defn find-lib-jars
"Returns a seq of Files for all the jars in the project's library directory."
[project]
(filter #(.endsWith (.getName %) ".jar")
(file-seq (file (:library-path project)))))

(defn make-path
"Constructs an ant Path object from Files and strings."
[& paths]
(let [ant-path (Path. nil)]
(doseq [path paths]
(.addExisting ant-path (Path. nil (str path))))
ant-path))

(defn get-classpath
"Answer a list of classpath entries for PROJECT."
Expand Down
25 changes: 3 additions & 22 deletions src/leiningen/compile.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
(:use [leiningen.deps :only [deps]]
[leiningen.checkout-deps :only [checkout-deps-paths]]
[leiningen.core :only [ns->path]]
[leiningen.classpath :only [make-path find-lib-jars get-classpath]]
[clojure.contrib.java-utils :only [file]]
[clojure.contrib.find-namespaces :only [find-namespaces-in-dir]])
(:refer-clojure :exclude [compile])
(:import org.apache.tools.ant.taskdefs.Java
java.lang.management.ManagementFactory
(org.apache.tools.ant.types Environment$Variable Path)))
(org.apache.tools.ant.types Environment$Variable)))

(defn compilable-namespaces
"Returns a seq of the namespaces that are compilable, regardless of whether
Expand All @@ -36,12 +37,6 @@
(.replace clj-path "\\.clj" "__init.class"))))))
(compilable-namespaces project)))

(defn find-lib-jars
"Returns a seq of Files for all the jars in the project's library directory."
[project]
(filter #(.endsWith (.getName %) ".jar")
(file-seq (file (:library-path project)))))

(defn get-by-pattern
"Gets a value from map m, but uses the keys as regex patterns,
trying to match against k instead of doing an exact match."
Expand Down Expand Up @@ -89,14 +84,6 @@
(.getInputArguments)
(seq)))

(defn make-path
"Constructs an ant Path object from Files and strings."
[& paths]
(let [ant-path (Path. nil)]
(doseq [path paths]
(.addExisting ant-path (Path. nil (str path))))
ant-path))

(defn eval-in-project
"Executes form in an isolated classloader with the classpath and compile path
set correctly for the project. Pass in a handler function to have it called
Expand All @@ -118,13 +105,7 @@
(.getAbsolutePath native-path)
(fn? native-path) (native-path)
:default native-path)))))
(.setClasspath java (apply make-path
(:source-path project)
(:test-path project)
(:compile-path project)
(:resources-path project)
(concat (find-lib-jars project)
(checkout-deps-paths project))))
(.setClasspath java (apply make-path (get-classpath project)))
(.setFailonerror java true)
(when (or (= :macosx (get-os)) native-path)
(.setFork java true)
Expand Down

0 comments on commit 625c5de

Please sign in to comment.