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

adding jar offset rewriting and support for preamble scripts from files #7

Merged
merged 1 commit into from
Jan 16, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject lein-binplus "0.6.3"
(defproject lein-binplus "0.6.4"
:description "A leiningen plugin for generating standalone console
executables for your project."
:url "https://github.com/BrunoBonacci/lein-binplus"
Expand All @@ -10,7 +10,8 @@
:url "http://www.eclipse.org/legal/epl-v10.html"}

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

:deploy-repositories [["releases" :clojars]
Expand Down
29 changes: 17 additions & 12 deletions src/leiningen/bin.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
[clostache.parser :refer [render]]
[leiningen.uberjar :refer [uberjar]]
[me.raynes.fs :as fs]
[clojure.string :as str]))
[clojure.string :as str]
[clj-zip-meta.core :refer [repair-zip-with-preamble-bytes]]))



Expand Down Expand Up @@ -32,11 +33,12 @@


(defn preamble-template
[{:keys [bootclasspath custom-preamble] :as options}]
[{:keys [bootclasspath custom-preamble custom-preamble-script]}]
(cond
custom-preamble-script (slurp custom-preamble-script)
custom-preamble (str custom-preamble "\r\n")
bootclasspath BOOTCLASSPATH-TEMPLATE
:else NORMAL-TEMPLATE))
bootclasspath BOOTCLASSPATH-TEMPLATE
:else NORMAL-TEMPLATE))


(defn render-preamble
Expand All @@ -59,14 +61,15 @@


(defn options [project]
{:project-name (:name project)
:version (:version project)

:main (:main project)
:bootclasspath (get-in project [:bin :bootclasspath] false)
:jvm-opts (jvm-opts project)
:win-jvm-opts (sanitize-jvm-opts-for-win (jvm-opts project))
:custom-preamble (get-in project [:bin :custom-preamble])
{:project-name (:name project)
:version (:version project)

:main (:main project)
:bootclasspath (get-in project [:bin :bootclasspath] false)
:jvm-opts (jvm-opts project)
:win-jvm-opts (sanitize-jvm-opts-for-win (jvm-opts project))
:custom-preamble (get-in project [:bin :custom-preamble])
:custom-preamble-script (get-in project [:bin :custom-preamble-script])
})


Expand Down Expand Up @@ -119,4 +122,6 @@
(str (:name project) "-" (:version project))))
uberjar (uberjar project)]
(writing-bin binfile uberjar (preamble opts))
(println "Re-aligning zip offsets")
(repair-zip-with-preamble-bytes binfile)
(copy-bin project binfile))))