Skip to content

Commit

Permalink
Add library output
Browse files Browse the repository at this point in the history
This allows tailoring the output specifically to the needs of libraries,
such as automatically placing the pom.xml.
  • Loading branch information
SevereOverfl0w committed Dec 7, 2021
1 parent 6461571 commit 9fd4a63
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ It provides:
* AWS Lambda deployment package
* Self-executable jars (Using One-JAR)
* "Skinny" jars (Jars which do not contain their dependencies)
** Library jars
* Library jars

=== What does conflict-less mean?

Expand Down
8 changes: 5 additions & 3 deletions src/juxt/pack/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@
Options
:basis - required, basis to create library from
:path - required, location to output library to"
:path - required, location to output library to
:pom - input pom.xml, if provided will be copied to
META-INF/maven/<group>/<artifact>/pom.xml
:lib - required if :pom supplied, used to create pom.xml path"
[params]
(skinny {:path (:path params)
:path-coerce :jar}))
((requiring-resolve 'juxt.pack.library/library) params))

(defn aws-lambda
"Produce a zip file that can be uploaded to AWS lambda. You will need to AOT
Expand Down
8 changes: 5 additions & 3 deletions src/juxt/pack/cli/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@
Options
:basis - basis to use, if not provided will create a basis without :user
:path - required, location to output library to"
:path - required, location to output library to
:pom - input pom.xml, if provided will be copied to
META-INF/maven/<group>/<artifact>/pom.xml
:lib - required if :pom supplied, used to create pom.xml path"
[{:keys [basis] :as params}]
(skinny {:path (:path params)
:path-coerce :jar}))
(pack/library (assoc params :basis (or basis (create-basis nil)))))

(defn aws-lambda
"Produce a zip file that can be uploaded to AWS lambda. You will need to AOT
Expand Down
28 changes: 28 additions & 0 deletions src/juxt/pack/library.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(ns ^:no-doc juxt.pack.library
(:require
[clojure.java.io :as io]
[juxt.pack.impl.vfs :as vfs]))

(defn write-paths
[basis output-path extra-paths]
(io/make-parents (io/file output-path))
(vfs/write-vfs
{:type :jar
:stream (io/output-stream output-path)}
(concat extra-paths
(mapcat
(fn [path]
(vfs/files-path
(file-seq (io/file path))
(io/file path)))
(keep
#(when (:path-key (val %))
(key %))
(:classpath basis))))))

(defn library
[{:keys [basis path pom lib]}]
(write-paths basis path
(when pom
[{:path ["META-INF" "maven" (namespace lib) (name lib) "pom.xml"]
:input (io/input-stream pom)}])))

0 comments on commit 9fd4a63

Please sign in to comment.