From b381c460a549d606923539eeb257a3f909b37238 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Sun, 8 Nov 2009 22:08:20 -0800 Subject: [PATCH] Use with-ns so defproject works unqualified. Bind *compile-path* explicitly. Not sure why explicit *compile-path* is required, but it was getting reset somehow. --- src/leiningen/core.clj | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/leiningen/core.clj b/src/leiningen/core.clj index d362c7d6..ca6db14c 100644 --- a/src/leiningen/core.clj +++ b/src/leiningen/core.clj @@ -1,6 +1,5 @@ (ns leiningen.core - (:require [leiningen deps test compile] - [clojure.contrib.with-ns]) + (:use [clojure.contrib.with-ns]) (:gen-class)) (def project nil) @@ -15,15 +14,22 @@ :root ~(.getParent (java.io.File. *file*))))) (def ~project-name project))) +;; So it doesn't need to be fully-qualified in project.clj +(with-ns 'user (use ['leiningen.core :only ['defproject]])) + (defn read-project ([file] (load-file file) project) ([] (read-project "project.clj"))) (defn -main [command & args] - (let [action (ns-resolve (symbol (str "leiningen." command)) - (symbol command))] - ;; TODO: ensure tasks run only once - (apply action (read-project) args) - ;; In case tests or some other task started any: - (shutdown-agents))) \ No newline at end of file + (let [action-ns (symbol (str "leiningen." command)) + _ (require action-ns) + action (ns-resolve action-ns (symbol command)) + project (read-project)] + (binding [*compile-path* (or (:compile-path project) + (str (:root project) "/classes/"))] + ;; TODO: ensure tasks run only once + (apply action project args) + ;; In case tests or some other task started any: + (shutdown-agents)))) \ No newline at end of file