Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supports leiningen 2 exit code strategy for tasks #13

Merged
merged 2 commits into from Aug 28, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -9,11 +9,11 @@ Setup

Add lein-clojars as a Leiningen (1.x) plugin:

lein plugin install lein-clojars 0.9.0
lein plugin install lein-clojars 0.9.1

Or for Leiningen 2 add it to ~/.lein/profiles.clj:

{:user {:plugins [[lein-clojars "0.9.0"]]}}
{:user {:plugins [[lein-clojars "0.9.1"]]}}

Create a Clojars account and paste your SSH public key into your [profile] [1].
If you don't have ssh-keygen available -- perhaps you're using Windows --
Expand Down
2 changes: 1 addition & 1 deletion 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"]])
17 changes: 13 additions & 4 deletions src/leiningen/push.clj
Expand Up @@ -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 ".")])))
Expand Down Expand Up @@ -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]]
Expand All @@ -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)))))