Skip to content

Commit

Permalink
Moved make-auth to leiningen.deps from leiningen.deploy. Modified lei…
Browse files Browse the repository at this point in the history
…ningen.deps/make-deps-task to use make-auth.
  • Loading branch information
drone29a committed Jan 15, 2011
1 parent 48109fa commit 76cc240
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
14 changes: 1 addition & 13 deletions src/leiningen/deploy.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[leiningen.jar :only [jar]]
[leiningen.pom :only [pom]]
[leiningen.util.maven :only [make-model make-artifact]]
[leiningen.deps :only [make-repository]]
[leiningen.deps :only [make-repository make-auth]]
[clojure.java.io :only [file]])
(:import [org.apache.maven.artifact.ant DeployTask Pom Authentication]
[org.apache.maven.project MavenProject]))
Expand All @@ -19,18 +19,6 @@
(let [options (apply hash-map options)]
(zipmap (map keyword (keys options)) (vals options))))

(defn make-auth [url options]
(let [auth (Authentication.)
user-options (when-let [user-opts (resolve 'user/leiningen-auth)]
(get @user-opts url))
{:keys [username password passphrase
private-key]} (merge user-options options)]
(when username (.setUserName auth username))
(when password (.setPassword auth password))
(when passphrase (.setPassphrase auth passphrase))
(when private-key (.setPrivateKey auth private-key))
auth))

(defn make-target-repo [repo-url auth-options]
(let [repo (make-repository ["remote repository" repo-url])]
(when-let [auth (make-auth repo-url auth-options)]
Expand Down
20 changes: 18 additions & 2 deletions src/leiningen/deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@
(.setPassword password))))))
repo))

(defn make-auth [url options]
(let [auth (Authentication.)
user-options (when-let [user-opts (resolve 'user/leiningen-auth)]
(get @user-opts url))
{:keys [username password passphrase
private-key]} (merge user-options options)]
(when username (.setUserName auth username))
(when password (.setPassword auth password))
(when passphrase (.setPassphrase auth passphrase))
(when private-key (.setPrivateKey auth private-key))
auth))

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

Expand Down Expand Up @@ -59,8 +71,12 @@
(.setBasedir lancet/ant-project (:root project))
(.setFilesetId deps-task "dependency.fileset")
(.setPathId deps-task (:name project))
(doseq [r (map make-repository (repositories-for project))]
(.addConfiguredRemoteRepository deps-task r))
(doseq [[id settings] (repositories-for project)]
(let [r (make-repository [id settings])
repo-url (if (string? settings) settings (:url settings))]
(when-let [auth (make-auth repo-url (if (map? settings) settings {}))]
(.addAuthentication r auth))
(.addConfiguredRemoteRepository deps-task r)))
(doseq [dep (project deps-set)]
(.addDependency deps-task (make-dependency dep)))
deps-task))
Expand Down

0 comments on commit 76cc240

Please sign in to comment.