Make deps generic. Add draft symlink implementation.
This commit is contained in:
parent
8a687e7c94
commit
0b9fba8395
1 changed files with 32 additions and 3 deletions
|
@ -7,6 +7,34 @@
|
||||||
[org.apache.maven.artifact.ant DependenciesTask RemoteRepository]
|
[org.apache.maven.artifact.ant DependenciesTask RemoteRepository]
|
||||||
[org.apache.tools.ant.util FlatFileNameMapper]))
|
[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
|
;; TODO: unify with pom.clj
|
||||||
|
|
||||||
(defn make-exclusion [excl]
|
(defn make-exclusion [excl]
|
||||||
|
@ -60,7 +88,8 @@ dependencies with the following:
|
||||||
(.addDependency deps-task (make-dependency dep))))
|
(.addDependency deps-task (make-dependency dep))))
|
||||||
(.execute deps-task)
|
(.execute deps-task)
|
||||||
(.mkdirs (file (:library-path project)))
|
(.mkdirs (file (:library-path project)))
|
||||||
(lancet/copy {:todir (:library-path project) :flatten "on"}
|
(copy-dependencies *copy-behavior*
|
||||||
|
(:library-path project) true
|
||||||
(.getReference lancet/ant-project
|
(.getReference lancet/ant-project
|
||||||
(.getFilesetId deps-task)))))
|
(.getFilesetId deps-task)))))
|
||||||
([project] (deps project false)))
|
([project] (deps project false)))
|
||||||
|
|
Loading…
Reference in a new issue