Permalink
Browse files

Support :eval-in-leiningen key in project.clj for plugins.

  • Loading branch information...
1 parent 1551ebc commit f732bfeebf908b7dab96389f5a39c0b6834a829a @technomancy committed Oct 24, 2010
Showing with 40 additions and 28 deletions.
  1. +1 −1 bin/lein
  2. +3 −1 sample.project.clj
  3. +28 −26 src/leiningen/compile.clj
  4. +8 −0 test/test_compile.clj
View
@@ -36,7 +36,7 @@ fi
LEIN_PLUGINS="$(ls -1 lib/dev/*jar 2> /dev/null | tr \\n \:)"
LEIN_USER_PLUGINS="$(ls -1 $LEIN_HOME/plugins/*jar 2> /dev/null | tr \\n \:)"
-CLASSPATH=$LEIN_USER_PLUGINS:$LEIN_PLUGINS:src/:$CLASSPATH
+CLASSPATH=$LEIN_USER_PLUGINS:$LEIN_PLUGINS:test/:src/:$CLASSPATH
LEIN_JAR="$HOME/.m2/repository/leiningen/leiningen/$LEIN_VERSION/leiningen-$LEIN_VERSION-standalone.jar"
# CLOJURE_JAR="$HOME/.m2/repository/org/clojure/clojure/1.2.0/clojure-1.2.0.jar"
NULL_DEVICE=/dev/null
View
@@ -92,4 +92,6 @@
;; Set arbitrary key/value pairs for the jar's manifest.
:manifest {"Project-awesome-level" "super-great"}
;; You can set JVM-level options here.
- :jvm-opts ["-Xmx1g"])
+ :jvm-opts ["-Xmx1g"]
+ ;; If your project is a Leiningen plugin, set this to skip the subprocess step
+ :eval-in-leiningen false)
View
@@ -142,33 +142,35 @@
(compile project)))
(when (empty? (find-lib-jars project))
(deps project))
- (let [java (Java.)
- native-path (or (:native-path project)
- (find-native-lib-path project))]
- (.setProject java lancet/ant-project)
- (.addSysproperty java (doto (Environment$Variable.)
- (.setKey "clojure.compile.path")
- (.setValue (:compile-path project))))
- (when native-path
+ (if (:eval-in-leiningen project)
+ (eval form)
+ (let [java (Java.)
+ native-path (or (:native-path project)
+ (find-native-lib-path project))]
+ (.setProject java lancet/ant-project)
(.addSysproperty java (doto (Environment$Variable.)
- (.setKey "java.library.path")
- (.setValue (cond
- (= java.io.File (class native-path))
- (.getAbsolutePath native-path)
- (fn? native-path) (native-path)
- :default native-path)))))
- (.setClasspath java (apply make-path (get-classpath project)))
- (.setFailonerror java true)
- (.setFork java true)
- (doseq [arg (get-jvm-args project)]
- (when-not (re-matches #"^-Xbootclasspath.+" arg)
- (.setValue (.createJvmarg java) arg)))
- (.setClassname java "clojure.main")
- ;; to allow plugins and other tasks to customize
- (when handler (handler java))
- (.setValue (.createArg java) "-e")
- (.setValue (.createArg java) (get-readable-form java project form init))
- (.executeJava java)))
+ (.setKey "clojure.compile.path")
+ (.setValue (:compile-path project))))
+ (when native-path
+ (.addSysproperty java (doto (Environment$Variable.)
+ (.setKey "java.library.path")
+ (.setValue (cond
+ (= java.io.File (class native-path))
+ (.getAbsolutePath native-path)
+ (fn? native-path) (native-path)
+ :default native-path)))))
+ (.setClasspath java (apply make-path (get-classpath project)))
+ (.setFailonerror java true)
+ (.setFork java true)
+ (doseq [arg (get-jvm-args project)]
+ (when-not (re-matches #"^-Xbootclasspath.+" arg)
+ (.setValue (.createJvmarg java) arg)))
+ (.setClassname java "clojure.main")
+ ;; to allow plugins and other tasks to customize
+ (when handler (handler java))
+ (.setValue (.createArg java) "-e")
+ (.setValue (.createArg java) (get-readable-form java project form init))
+ (.executeJava java))))
(defn- platform-nullsink []
(file (if (= :windows (get-os))
View
@@ -23,3 +23,11 @@
(is (.exists (file "test_projects" "sample"
"classes" "nom" "nom" "nom.class")))
(is (pos? (compile (make-project "test_projects/sample_failing")))))
+
+(deftest test-plugin
+ (is (= (eval-in-project (assoc (make-project "test_projects/sample")
+ :eval-in-leiningen true
+ :main nil)
+ '(do (require 'leiningen.compile)
+ :compiled))
+ :compiled)))

0 comments on commit f732bfe

Please sign in to comment.