From 619262621a3904a4996c3763e78d684ad907600b Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Tue, 23 Nov 2010 20:24:48 -0800 Subject: [PATCH] Turns out has-source-package is not a good enough keep-class? heuristic. Fixes #139. --- src/leiningen/compile.clj | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/leiningen/compile.clj b/src/leiningen/compile.clj index 1da62e7c..871a18dd 100644 --- a/src/leiningen/compile.clj +++ b/src/leiningen/compile.clj @@ -205,16 +205,23 @@ (defn- has-source-package? "Test if the class file's package exists as a directory in :source-path." - [project f] - (.isDirectory (file (.replace (.getParent f) - (:compile-path project) - (:source-path project))))) + [project f source-path] + (and source-path (.isDirectory (file (.replace (.getParent f) + (:compile-path project) + source-path))))) + +(defn- keep-class? [project f] + (or (has-source-package? project f (:source-path project)) + (has-source-package? project f (:java-source-path project)) + (.exists (file (str (.replace (.getParent f) + (:compile-path project) + (:source-path project)) ".clj"))))) (defn delete-non-project-classes [project] (when (and (not= :all (:aot project)) (not (:keep-non-project-classes project))) (doseq [f (file-seq (file (:compile-path project))) - :when (and (.isFile f) (not (has-source-package? project f)))] + :when (and (.isFile f) (not (keep-class? project f)))] (.delete f)))) (defn- status [code msg]