Permalink
Browse files

Fix relative path issues.

  • Loading branch information...
technomancy committed Jul 3, 2012
1 parent d27ecee commit e97e711c6f1b0acd425534ded637fcf1d708cb6d
Showing with 13 additions and 9 deletions.
  1. +2 −1 .gitignore
  2. +11 −8 src/leiningen/clean_m2.clj
View
@@ -7,4 +7,5 @@ pom.xml
*.class
.lein-deps-sum
.lein-failures
-.lein-plugins
+.lein-plugins
+/pom.xml.asc
View
@@ -6,7 +6,10 @@
(defn- coords [local-repo-path f]
(rest (re-find #"([^\/]+)/([^\/]+)/([^\/]+)/"
- (.replace (str f) local-repo-path ""))))
+ (.replace (.getAbsolutePath f) local-repo-path ""))))
+
+;; TODO: pom artifacts can be required to calculate dependencies but
+;; not show up in the final dependencies listing
(defn clean-m2
"Wipe local repository of all artifacts not required for project.
@@ -15,10 +18,10 @@ Don't use this in a user account unless it's only used for a single project."
[project & [dry-run?]]
(let [artifacts (concat (cp/resolve-dependencies :plugins project)
(cp/resolve-dependencies :dependencies project))
- local-repo (:local-repo project local-repo)
- used? (set (map (partial coords (str local-repo)) artifacts))]
- (doseq [f (file-seq (io/file local-repo))]
- (when (and (not (used? (coords (str local-repo) f))) (.isFile f))
- (println "Unused:" (str f))
- (when-not dry-run?
- (io/delete-file f))))))
+ local-repo (.getAbsolutePath (io/file (:local-repo project local-repo)))
+ used? (set (map (partial coords local-repo) artifacts))]
+ (doseq [f (file-seq (io/file local-repo))
+ :when (and (not (used? (coords local-repo f))) (.isFile f))]
+ (println "Unused:" (str f))
+ (when-not dry-run?
+ (io/delete-file f)))))

0 comments on commit e97e711

Please sign in to comment.