Permalink
Browse files

Update for lein 2.

  • Loading branch information...
1 parent 53cbe5b commit 6539d893226551dac8752719aee1896204b95782 @Raynes committed Mar 26, 2012
Showing with 7 additions and 8 deletions.
  1. +2 −3 project.clj
  2. +5 −5 src/leiningen/bin.clj
View
@@ -1,4 +1,3 @@
-(defproject lein-bin "0.1.2"
+(defproject lein-bin "0.2.0"
:description "A leiningen plugin for generating standalone console executables for your project."
- :dependencies [[org.clojure/clojure "1.3.0"]]
- :eval-in-project true)
+ :eval-in-leiningen true)
View
@@ -2,29 +2,29 @@
"Create a standalone executable for your project."
(:use [clojure.java.io :only [copy file]]
[clojure.string :only [join]]
- [leiningen.jar :only [get-default-uberjar-name]]
+ [leiningen.jar :only [get-jar-filename]]
[leiningen.uberjar :only [uberjar]])
(:import java.io.FileOutputStream))
(defn- jvm-options [{:keys [jvm-opts name version] :or {jvm-opts []}}]
(join " " (conj jvm-opts (format "-D%s.version=%s" name version))))
-(defn ^{:help-arglists '([])} bin
+(defn bin
"Create a standalone console executable for your project.
Add :main to your project.clj to specify the namespace that contains your
-main function."
[project]
(if (:main project)
(let [opts (jvm-options project)
- target (file (:target-dir project))
+ target (file (:target-path project))
binfile (file target (:or (:executable-name project)
(str (:name project) "-" (:version project))))]
(uberjar project)
(println "Creating standalone executable:" (.getPath binfile))
(with-open [bin (FileOutputStream. binfile)]
(.write bin (.getBytes (format ":;exec java %s -jar $0 \"$@\"\n" opts)))
(.write bin (.getBytes (format "@echo off\r\njava %s -jar %%1 \"%%~f0\" %%*\r\ngoto :eof\r\n" opts)))
- (copy (file target (get-default-uberjar-name project)) bin))
+ (copy (file (get-jar-filename project :uberjar)) bin))
(.setExecutable binfile true))
- (println "Cannot create bin without :main namespace in project.clj")))
+ (println "Cannot create bin without :main namespace in project.clj")))

0 comments on commit 6539d89

Please sign in to comment.