-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include bin scripts in generated jars when specified in :shell-wrapper.
- Loading branch information
1 parent
0966229
commit 8012a50
Showing
5 changed files
with
95 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ lib/ | |
leiningen*.jar | ||
lein-swank/lein-swank*.jar | ||
autodoc/ | ||
/sample/pom.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
(ns test-jar | ||
(:use [clojure.test] | ||
[leiningen.core :only [defproject]] | ||
[leiningen.jar])) | ||
[clojure.contrib.io :only [slurp*]] | ||
[leiningen.core :only [defproject read-project]] | ||
[leiningen.jar]) | ||
(:import [java.util.jar JarFile])) | ||
|
||
(defproject mock-project "1.0" :main foo.one-two.three-four.bar) | ||
(defproject mock-project "1.0" :main foo.one-two.three-four.bar | ||
:manifest {"hello" "world"}) | ||
|
||
(deftest test-manifest | ||
(let [manifest (manifest-map (make-manifest mock-project))] | ||
(is (= {"Main-Class" "foo.one_two.three_four.bar", "hello" "world"} | ||
(select-keys manifest ["hello" "Main-Class"]))))) | ||
|
||
(def sample-project (binding [*ns* (the-ns 'leiningen.core)] | ||
(read-project "sample/project.clj"))) | ||
|
||
(deftest test-jar | ||
(is (= "foo.one_two.three_four.bar" | ||
(.getValue (.getMainAttributes (make-manifest mock-project)) | ||
"Main-Class")))) | ||
(let [jar-file (JarFile. (jar sample-project)) | ||
manifest (manifest-map (.getManifest jar-file)) | ||
bin (slurp* (.getInputStream jar-file (.getEntry jar-file "bin/nom")))] | ||
(is (= "bin/nom" (manifest "Leiningen-shell-wrapper"))) | ||
(is (re-find #"org/clojure/clojure/1.1.0-master-SNAPSHOT/" bin)) | ||
(is (re-find #"use 'nom\.nom\.nom\)\(apply -main .command-line-args." bin)) | ||
(is (re-find #"\$HOME/\.m2/repository/rome/rome/0.9/rome-0\.9\.jar" bin)))) | ||
|
||
(deftest test-no-bin-jar | ||
(let [jar-file (JarFile. (jar (dissoc sample-project :shell-wrapper))) | ||
manifest (manifest-map (.getManifest jar-file))] | ||
(is (nil? (.getEntry jar-file "bin/nom"))) | ||
(is (nil? (manifest "Leiningen-shell-wrapper"))))) |