Skip to content

Commit

Permalink
Merge remote branch 'mattrepl/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Jan 21, 2011
2 parents 30e197f + 33ef2ca commit 3c738ce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
16 changes: 2 additions & 14 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 snapshot?]]
[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 [project options]
(let [deploy-opts (merge (:deploy-to project) options)
repo-url (if (snapshot? project)
Expand Down Expand Up @@ -67,6 +55,6 @@ to avoid checking sensitive information into source control:
(.execute)))
([project]
(if-let [target (:deploy-to project)]
(deploy target)
(apply deploy project target)
(do (println "Either set :deploy-to in project.clj or"
"provide deploy target options.") 1))))
20 changes: 18 additions & 2 deletions src/leiningen/deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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 @@ -60,8 +72,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 3c738ce

Please sign in to comment.