Skip to content

Commit 9fd4a63

Browse files
Add library output
This allows tailoring the output specifically to the needs of libraries, such as automatically placing the pom.xml.
1 parent 6461571 commit 9fd4a63

4 files changed

Lines changed: 39 additions & 7 deletions

File tree

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ It provides:
4141
* AWS Lambda deployment package
4242
* Self-executable jars (Using One-JAR)
4343
* "Skinny" jars (Jars which do not contain their dependencies)
44-
** Library jars
44+
* Library jars
4545

4646
=== What does conflict-less mean?
4747

src/juxt/pack/api.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@
6060
6161
Options
6262
:basis - required, basis to create library from
63-
:path - required, location to output library to"
63+
:path - required, location to output library to
64+
:pom - input pom.xml, if provided will be copied to
65+
META-INF/maven/<group>/<artifact>/pom.xml
66+
:lib - required if :pom supplied, used to create pom.xml path"
6467
[params]
65-
(skinny {:path (:path params)
66-
:path-coerce :jar}))
68+
((requiring-resolve 'juxt.pack.library/library) params))
6769

6870
(defn aws-lambda
6971
"Produce a zip file that can be uploaded to AWS lambda. You will need to AOT

src/juxt/pack/cli/api.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@
6868
6969
Options
7070
:basis - basis to use, if not provided will create a basis without :user
71-
:path - required, location to output library to"
71+
:path - required, location to output library to
72+
:pom - input pom.xml, if provided will be copied to
73+
META-INF/maven/<group>/<artifact>/pom.xml
74+
:lib - required if :pom supplied, used to create pom.xml path"
7275
[{:keys [basis] :as params}]
73-
(skinny {:path (:path params)
74-
:path-coerce :jar}))
76+
(pack/library (assoc params :basis (or basis (create-basis nil)))))
7577

7678
(defn aws-lambda
7779
"Produce a zip file that can be uploaded to AWS lambda. You will need to AOT

src/juxt/pack/library.clj

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
(ns ^:no-doc juxt.pack.library
2+
(:require
3+
[clojure.java.io :as io]
4+
[juxt.pack.impl.vfs :as vfs]))
5+
6+
(defn write-paths
7+
[basis output-path extra-paths]
8+
(io/make-parents (io/file output-path))
9+
(vfs/write-vfs
10+
{:type :jar
11+
:stream (io/output-stream output-path)}
12+
(concat extra-paths
13+
(mapcat
14+
(fn [path]
15+
(vfs/files-path
16+
(file-seq (io/file path))
17+
(io/file path)))
18+
(keep
19+
#(when (:path-key (val %))
20+
(key %))
21+
(:classpath basis))))))
22+
23+
(defn library
24+
[{:keys [basis path pom lib]}]
25+
(write-paths basis path
26+
(when pom
27+
[{:path ["META-INF" "maven" (namespace lib) (name lib) "pom.xml"]
28+
:input (io/input-stream pom)}])))

0 commit comments

Comments
 (0)