Skip to content

Commit

Permalink
Make deps generic. Add draft symlink implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
rnewman authored and technomancy committed Mar 17, 2010
1 parent 8a687e7 commit 0b9fba8
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions src/leiningen/deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,34 @@
[org.apache.maven.artifact.ant DependenciesTask RemoteRepository]
[org.apache.tools.ant.util FlatFileNameMapper]))

;; Add symlinking to Lancet's toolbox.
(lancet/define-ant-task symlink symlink)

;; Set this to one of :symlink or :copy to decide how dependencies are added to
;; the library path."
(def *copy-behavior* :copy)

(defmulti copy-dependencies (fn [k destination flatten? fileset] k))

(defmethod copy-dependencies :copy [k destination flatten? fileset]
(lancet/copy {:todir destination :flatten (if flatten? "on" "off")}
fileset))

(defmethod copy-dependencies :symlink [k destination flatten? fileset]
(let [files (.getIncludedFiles (.getDirectoryScanner fileset lancet/ant-project))
dir (.getDir fileset)]

;; In principle, this should work... but it doesn't.
;; Instead we link each file in turn.
#_
(symlink {:action "record" :linkfilename destination}
fileset))

(doseq [f files]
(symlink {:link destination
:resource (.getCanonicalPath (java.io.File. dir f))})))


;; TODO: unify with pom.clj

(defn make-exclusion [excl]
Expand Down Expand Up @@ -60,7 +88,8 @@ dependencies with the following:
(.addDependency deps-task (make-dependency dep))))
(.execute deps-task)
(.mkdirs (file (:library-path project)))
(lancet/copy {:todir (:library-path project) :flatten "on"}
(.getReference lancet/ant-project
(.getFilesetId deps-task)))))
(copy-dependencies *copy-behavior*
(:library-path project) true
(.getReference lancet/ant-project
(.getFilesetId deps-task)))))
([project] (deps project false)))

0 comments on commit 0b9fba8

Please sign in to comment.