    (.getPackaging model)
    nil))
 
+(defn bin-path []
+  (doto (file (home-dir) "bin") .mkdirs))
+
+(defn install-shell-wrapper [jarfile]
+  (when-let [bin-name ((manifest-map (.getManifest jarfile))
+                       "Leiningen-shell-wrapper")]
+    (let [bin-file (file (bin-path) (last (.split bin-name "/")))]
+      (println "Installing shell wrapper to" (.getAbsolutePath bin-file))
+      (copy (.getInputStream jarfile (.getEntry jarfile bin-name)) bin-file)
+      (.setExecutable bin-file true))))
+
 (defn install
   "Install the project and its dependencies in your local repository."
   [project]

(ns leiningen.install
  "Install the project and its dependencies in your local repository."
  (:use [leiningen.jar :only [jar]]
        [leiningen.pom :only [pom make-model]]
        [clojure.java.io :only [file]])
  (:import [org.apache.maven.artifact.installer ArtifactInstaller]
           [org.apache.maven.project.artifact ProjectArtifactMetadata]
           [org.apache.maven.settings MavenSettingsBuilder]

    ;; generated and installed in local repo
    (if (not= "pom" (.getPackaging model))
      (add-metadata artifact (file (pom project))))
    (install-shell-wrapper (JarFile. jarfile))
    (.install installer jarfile artifact local-repo)))

