Skip to content

Commit 59e8a25

Browse files
committed
adding jar offset rewriting and support for custom preamble scripts
1 parent 7a10a69 commit 59e8a25

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

project.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject lein-binplus "0.6.3"
1+
(defproject lein-binplus "0.6.4"
22
:description "A leiningen plugin for generating standalone console
33
executables for your project."
44
:url "https://github.com/BrunoBonacci/lein-binplus"
@@ -10,7 +10,8 @@
1010
:url "http://www.eclipse.org/legal/epl-v10.html"}
1111

1212
:dependencies [[me.raynes/fs "1.4.6"]
13-
[de.ubercode.clostache/clostache "1.4.0"]]
13+
[de.ubercode.clostache/clostache "1.4.0"]
14+
[clj-zip-meta/clj-zip-meta "0.1.2" :exclusions [org.clojure/clojure]]]
1415
:eval-in-leiningen true
1516

1617
:deploy-repositories [["releases" :clojars]

src/leiningen/bin.clj

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
[clostache.parser :refer [render]]
55
[leiningen.uberjar :refer [uberjar]]
66
[me.raynes.fs :as fs]
7-
[clojure.string :as str]))
7+
[clojure.string :as str]
8+
[clj-zip-meta.core :refer [repair-zip-with-preamble-bytes]]))
89

910

1011

@@ -32,11 +33,12 @@
3233

3334

3435
(defn preamble-template
35-
[{:keys [bootclasspath custom-preamble] :as options}]
36+
[{:keys [bootclasspath custom-preamble custom-preamble-script]}]
3637
(cond
38+
custom-preamble-script (slurp custom-preamble-script)
3739
custom-preamble (str custom-preamble "\r\n")
38-
bootclasspath BOOTCLASSPATH-TEMPLATE
39-
:else NORMAL-TEMPLATE))
40+
bootclasspath BOOTCLASSPATH-TEMPLATE
41+
:else NORMAL-TEMPLATE))
4042

4143

4244
(defn render-preamble
@@ -59,14 +61,15 @@
5961

6062

6163
(defn options [project]
62-
{:project-name (:name project)
63-
:version (:version project)
64-
65-
:main (:main project)
66-
:bootclasspath (get-in project [:bin :bootclasspath] false)
67-
:jvm-opts (jvm-opts project)
68-
:win-jvm-opts (sanitize-jvm-opts-for-win (jvm-opts project))
69-
:custom-preamble (get-in project [:bin :custom-preamble])
64+
{:project-name (:name project)
65+
:version (:version project)
66+
67+
:main (:main project)
68+
:bootclasspath (get-in project [:bin :bootclasspath] false)
69+
:jvm-opts (jvm-opts project)
70+
:win-jvm-opts (sanitize-jvm-opts-for-win (jvm-opts project))
71+
:custom-preamble (get-in project [:bin :custom-preamble])
72+
:custom-preamble-script (get-in project [:bin :custom-preamble-script])
7073
})
7174

7275

@@ -119,4 +122,6 @@
119122
(str (:name project) "-" (:version project))))
120123
uberjar (uberjar project)]
121124
(writing-bin binfile uberjar (preamble opts))
125+
(println "Re-aligning zip offsets")
126+
(repair-zip-with-preamble-bytes binfile)
122127
(copy-bin project binfile))))

0 commit comments

Comments
 (0)