Separate :snapshots and :releases repository URLs in project.clj.
Plane commit; woo!
This commit is contained in:
parent
48109fa593
commit
0cf1ddf024
3 changed files with 29 additions and 21 deletions
|
@ -90,9 +90,10 @@
|
|||
:username "milgrim"
|
||||
:password "locative.1"}}
|
||||
;; Remote repository to which to deploy. (http:// or file://)
|
||||
:deploy-to ["http://blueant.com/archiva/repository/snapshots"
|
||||
:deploy-to {:snapshots "http://blueant.com/archiva/repository/snapshots"
|
||||
:releases "http://blueant.com/archiva/repository/internal"
|
||||
;; Also supports :private-key and :passphrase.
|
||||
:username "milgrim" :password "locative.1"]
|
||||
:username "milgrim" :password "locative.1"}
|
||||
;; If you'd rather use a different directory structure, you can set these.
|
||||
:source-path "src/main/clojure"
|
||||
:library-path "target/dependency"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
(:require [lancet])
|
||||
(:use [leiningen.core :only [abort]]
|
||||
[leiningen.jar :only [jar]]
|
||||
[leiningen.pom :only [pom]]
|
||||
[leiningen.pom :only [pom snapshot?]]
|
||||
[leiningen.util.maven :only [make-model make-artifact]]
|
||||
[leiningen.deps :only [make-repository]]
|
||||
[clojure.java.io :only [file]])
|
||||
|
@ -31,26 +31,31 @@
|
|||
(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)]
|
||||
(defn make-target-repo [project options]
|
||||
(let [deploy-opts (merge (:deploy-to project) options)
|
||||
repo-url (if (snapshot? project)
|
||||
(:snapshots deploy-opts)
|
||||
(:releases deploy-opts))
|
||||
repo (make-repository ["remote repository" repo-url])]
|
||||
(when-let [auth (make-auth repo-url options)]
|
||||
(.addAuthentication repo auth))
|
||||
repo))
|
||||
|
||||
(defn deploy
|
||||
"Build and deploy jar to remote repository. Takes target repository
|
||||
URL as an argument or set :deploy-to in project.clj to a URL or auth vector:
|
||||
"Build and deploy jar to remote repository. Set :deploy-to in project.clj:
|
||||
|
||||
[\"http://secret.com/archiva/repository/snapshots/\"
|
||||
:username \"durin\" :password \"mellon\"].
|
||||
{:snapshots \"http://secret.com/archiva/repository/snapshots\"
|
||||
:releases \"http://secret.com/archiva/repository/internal\"
|
||||
:username \"durin\" :password \"mellon\"}
|
||||
|
||||
Also supported are :private-key and :passphrase. You can set
|
||||
authentication options in ~/.lein/init.clj as well to avoid checking
|
||||
sensitive information into source control:
|
||||
SNAPSHOT versions will be deployed to :snapshots repository, releases go to
|
||||
:releases. Also supported are :private-key and :passphrase. You can
|
||||
set authentication options keyed by repository URL in ~/.lein/init.clj
|
||||
to avoid checking sensitive information into source control:
|
||||
|
||||
(def leiningen-auth {\"http://secr.et/repo\" {:password \"reindeerflotilla\"}
|
||||
\"file:///var/repo {:passphrase \"vorpalbunny\"}})"
|
||||
([project repo-url & auth]
|
||||
([project & opts]
|
||||
(doto (DeployTask.)
|
||||
(.setProject lancet/ant-project)
|
||||
(.getSupportedProtocols) ;; see note re: exceptions in deps.clj
|
||||
|
@ -58,11 +63,10 @@ sensitive information into source control:
|
|||
(.addPom (doto (Pom.)
|
||||
(.setMavenProject (make-maven-project project))
|
||||
(.setFile (file (pom project)))))
|
||||
(.addRemoteRepository (make-target-repo repo-url (keywordize-opts auth)))
|
||||
(.addRemoteRepository (make-target-repo project (keywordize-opts opts)))
|
||||
(.execute)))
|
||||
([project]
|
||||
(when-not (:deploy-to project)
|
||||
(abort "Can't deploy without :deploy-to set in project.clj."))
|
||||
(if (string? (:deploy-to project))
|
||||
(deploy project (:deploy-to project))
|
||||
(apply project (:deploy-to project)))))
|
||||
(if-let [target (:deploy-to project)]
|
||||
(deploy target)
|
||||
(do (println "Either set :deploy-to in project.clj or"
|
||||
"provide deploy target options.") 1))))
|
||||
|
|
|
@ -13,8 +13,11 @@
|
|||
It should not be considered canonical data. For more information see
|
||||
https://github.com/technomancy/leiningen -->\n")
|
||||
|
||||
(defn snapshot? [project]
|
||||
(re-find #"SNAPSHOT" (:version project)))
|
||||
|
||||
(defn check-for-snapshot-deps [project]
|
||||
(when (and (not (re-find #"SNAPSHOT" (:version project)))
|
||||
(when (and (not (snapshot? project))
|
||||
(not (System/getenv "LEIN_SNAPSHOTS_IN_RELEASE"))
|
||||
(some #(re-find #"SNAPSHOT" (second %)) (:dependencies project)))
|
||||
(throw (Exception. (str "Release versions may not depend upon snapshots."
|
||||
|
|
Loading…
Reference in a new issue