Fix post-AOT cleanup to use package-based deletion heuristic.
We had it so every .class file had to correspond with a .clj file in src/, but sometimes there are outliers that don't match up. So instead we now ensure that there's a directory in src/ that matches the package of each .class file.
This commit is contained in:
parent
b837ebc20a
commit
e66622a8e2
1 changed files with 7 additions and 9 deletions
|
@ -177,21 +177,19 @@
|
|||
"NUL"
|
||||
"/dev/null")))
|
||||
|
||||
(defn- has-corresponding-src?
|
||||
"Test if the given class file path exists in the source folder."
|
||||
(defn- has-source-package?
|
||||
"Test if the class file's package exists as a directory in :source-path."
|
||||
[project f]
|
||||
(.exists (file (:source-path project)
|
||||
(-> (.getAbsolutePath f)
|
||||
(.replaceAll "\\$\\w*\\.class$" ".clj")
|
||||
(.replaceAll "__init\\.class$" ".clj")
|
||||
(.replaceAll "\\.class$" ".clj")
|
||||
(.replace (str (:compile-path project) "/") "")))))
|
||||
(.isDirectory (doto (file (.replace (.getParent f)
|
||||
(:compile-path project)
|
||||
(:source-path project)))
|
||||
println)))
|
||||
|
||||
(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-corresponding-src? project f)))]
|
||||
:when (and (.isFile f) (not (has-source-package? project f)))]
|
||||
(.delete f))))
|
||||
|
||||
(defn- status [code msg]
|
||||
|
|
Loading…
Reference in a new issue