Browse files

supports leiningen 2 exit code strategy for tasks

  • Loading branch information...
1 parent a3085f3 commit d31d251c84124a01eda1e51018980b2ed4e8fbab @slagyr slagyr committed Aug 28, 2012
Showing with 14 additions and 5 deletions.
  1. +1 −1 project.clj
  2. +13 −4 src/leiningen/push.clj
View
2 project.clj
@@ -1,3 +1,3 @@
-(defproject lein-clojars "0.9.0"
+(defproject lein-clojars "0.9.1"
:description "Leiningen plugin for interacting with Clojars.org."
:dependencies [[com.jcraft/jsch "0.1.42"]])
View
17 src/leiningen/push.clj
@@ -7,9 +7,9 @@
(let [re-repo #"(?:([^@]+)@)?([^:]+)(?::(\d+))?(?::(.*))?"]
(defn parse-repo [repo]
- (let [[_ user host port path] (re-matches re-repo
+ (let [[_ user host port path] (re-matches re-repo
(or repo "clojars@clojars.org"))]
- [(or user (System/getProperty "user.name"))
+ [(or user (System/getProperty "user.name"))
host
(if port (Integer/parseInt port) 22)
(or path ".")])))
@@ -64,6 +64,13 @@
(.disconnect channel)
(.disconnect session)))))
+(defn- exit [code]
+ (try
+ (require 'leiningen.core.main)
+ ((ns-resolve (the-ns 'leiningen.core.main) 'exit) code)
+ (catch java.io.FileNotFoundException e
+ code)))
+
(defn push
"Push a jar to the Clojars.org repository over scp"
[project & [repo]]
@@ -78,14 +85,16 @@
(jar project)
(try
(scp-send repo pomfile jarfile)
+ (exit 0)
(catch JSchException e
(.printStackTrace e)
(when (= (.getMessage e) "Auth fail")
- (println
+ (println
(str
"\nIf you're having trouble authenticating, try using\n"
"a key generated by 'lein keygen'. lein-clojars doesn't\n"
"work yet with DSA or passphrased keys. I'm working\n"
"on fixing this. You can also push directly with scp:\n\n"
"lein pom\n"
- "scp " pomfile " " jarfile " clojars@clojars.org:" )))))))
+ "scp " pomfile " " jarfile " clojars@clojars.org:" )))
+ (exit -1)))))

0 comments on commit d31d251

Please sign in to comment.