From 76cc24050d6681fbd513ad2f8deb3cb7d1badca0 Mon Sep 17 00:00:00 2001 From: Matt Revelle Date: Sat, 15 Jan 2011 18:56:26 -0500 Subject: [PATCH 1/2] Moved make-auth to leiningen.deps from leiningen.deploy. Modified leiningen.deps/make-deps-task to use make-auth. --- src/leiningen/deploy.clj | 14 +------------- src/leiningen/deps.clj | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/leiningen/deploy.clj b/src/leiningen/deploy.clj index ed2876480..32de1b42e 100644 --- a/src/leiningen/deploy.clj +++ b/src/leiningen/deploy.clj @@ -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])) @@ -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)] diff --git a/src/leiningen/deps.clj b/src/leiningen/deps.clj index f5f653b9c..57747547a 100644 --- a/src/leiningen/deps.clj +++ b/src/leiningen/deps.clj @@ -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) @@ -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)) From 33ef2ca981bb879397d508a611d32bc96b43422f Mon Sep 17 00:00:00 2001 From: Matt Revelle Date: Thu, 20 Jan 2011 22:44:07 -0500 Subject: [PATCH 2/2] Fix case of not finding :deploy-to when no options are provided. --- src/leiningen/deploy.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/leiningen/deploy.clj b/src/leiningen/deploy.clj index d79679c72..50e2c8e3c 100644 --- a/src/leiningen/deploy.clj +++ b/src/leiningen/deploy.clj @@ -55,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))))