Skip to content

Commit c6af8dd

Browse files
committed
Automatically merge data_readers.clj and META-INF/plexus/components.xml, Support custom mergers, tools.deps updated to 0.9.763 (closes #1)
1 parent 52b5090 commit c6af8dd

File tree

27 files changed

+463
-112
lines changed

27 files changed

+463
-112
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ pom.xml.asc
1111
.hg/
1212
*.sublime-workspace
1313
.DS_Store
14-
.cpcache
14+
.cpcache
15+
!test_projects/mergers/project_c.jar

CHANGELOG.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
### 1.0.0 - Aug 19, 2020
2+
3+
- Automatically merge `data_readers.clj` and `META-INF/plexus/components.xml`
4+
- Support custom mergers #1
5+
- tools.deps updated to 0.9.763
6+
7+
### 0.1.11 - Aug 5, 2020
8+
9+
- Concat all `META-INF/services/**` files with matching names #2 #27 thx @jdf-id-au
10+
11+
### 0.1.10 - Mar 31, 2020
12+
13+
- tools.deps updated to 0.8.677
14+
15+
### 0.1.9 - Mar 31, 2020
16+
17+
- `--multi-release` / `:multi-release?` added #22 #23 thx @gavinkflam
18+
19+
### 0.1.8 - Jan 13, 2020
20+
21+
- Resolve `:paths` relative to `deps.edn` location
22+
23+
### 0.1.7 - Dec 20, 2019
24+
25+
- `--main-class` / `:main-class` option added #13 #18 thx @gnarroway
26+
- tools.deps updated to 0.8.599
27+
28+
### 0.1.6 - Oct 4, 2019
29+
30+
- Replace `\` with `/` when building on Windows #16 #17 thx @gnarroway
31+
32+
### 0.1.5 - Oct 4, 2019
33+
34+
- Ignore non-jar dependencies #14 #15
35+
36+
### 0.1.4 - June 5, 2019
37+
38+
- Package paths before jars so that local files take priority over deps #9
39+
40+
### 0.1.3 - May 30, 2019
41+
42+
- Fixed NPE when target is located in current dir #7
43+
44+
### 0.1.2 - May 27, 2019
45+
46+
- Make target dirs if don’t exist #4
47+
48+
### 0.1.1 - May 3, 2019
49+
50+
- Normalize dependencies without namespaces #3
51+
52+
### 0.1.0 - April 29, 2019
53+
54+
- Initial version

README.md

+34-38
Original file line numberDiff line numberDiff line change
@@ -216,56 +216,52 @@ Supported command-line options are:
216216
(uberdeps/package deps "target/uber.jar" {:aliases #{:uberjar}})))
217217
```
218218

219-
## Changelog
219+
## Merging
220220

221-
### 0.1.11 - Aug 5, 2020
221+
Sometimes assembling uberjar requires combining multiple files with the same name (coming from different libraries, for example) into a single file. Uberdeps does that automatically for these:
222222

223-
- Concat all `META-INF/services/**` files with matching names #2 #27 thx @jdf-id-au
224-
225-
### 0.1.10 - Mar 31, 2020
226-
227-
- tools.deps updated to 0.8.677
228-
229-
### 0.1.9 - Mar 31, 2020
230-
231-
- `--multi-release` / `:multi-release?` added #22 #23 thx @gavinkflam
232-
233-
### 0.1.8 - Jan 13, 2020
234-
235-
- Resolve `:paths` relative to `deps.edn` location
236-
237-
### 0.1.7 - Dec 20, 2019
238-
239-
- `--main-class` / `:main-class` option added #13 #18 thx @gnarroway
240-
- tools.deps updated to 0.8.599
241-
242-
### 0.1.6 - Oct 4, 2019
243-
244-
- Replace `\` with `/` when building on Windows #16 #17 thx @gnarroway
245-
246-
### 0.1.5 - Oct 4, 2019
247-
248-
- Ignore non-jar dependencies #14 #15
223+
```clojure
224+
META-INF/plexus/components.xml uberdeps.api/components-merger
225+
#"META-INF/services/.*" uberdeps.api/services-merger
226+
#"data_readers.clj[cs]?" uberdeps.api/clojure-maps-merger
227+
```
249228

250-
### 0.1.4 - June 5, 2019
229+
You can provide your own merger by passing a merge function to `uberdeps.api/package`:
251230

252-
- Package paths before jars so that local files take priority over deps #9
231+
```clojure
232+
(def readme-merger
233+
{:collect
234+
(fn [acc content]
235+
(conj (or acc []) (str/upper-case content)))
236+
:combine
237+
(fn [acc]
238+
(str/join "\n" acc))})
239+
```
253240

254-
### 0.1.3 - May 30, 2019
241+
Merger is a map with two keys: `:collect` and `:combine`. Collect accumulates values as they come. It takes an accumulator and a next file content, and must return the new accumulator:
255242

256-
- Fixed NPE when target is located in current dir #7
243+
```
244+
((:collect readme-merger) acc content) -> acc'
245+
```
257246

258-
### 0.1.2 - May 27, 2019
247+
File content is always a string. Accumulator can be any data structure you find useful for storing merged files. In `readme-merger` accumulator is a string, in `clojure-maps-merger` it is a clojure map, etc. On a first call to your merger accumulator will be `nil`.
259248

260-
- Make target dirs if don’t exist #4
249+
Combine is called when all files with the same name have been processed and it is time to write the resulting single merged file to the jar. It will be called with your accumulator and must return a string with file content:
261250

262-
### 0.1.1 - May 3, 2019
251+
```
252+
((:combine readme-merger) acc) -> content'
253+
```
263254

264-
- Normalize dependencies without namespaces #3
255+
Custom mergers can be passed to `uberdeps.api/package` in `:mergers` option along with file path regexp:
265256

266-
### 0.1.0 - April 29, 2019
257+
```
258+
(uberdeps.api/package
259+
deps
260+
"target/project.jar"
261+
{:mergers {#"(?i)README(\.md|\.txt)?" readme-merger}})
262+
```
267263

268-
- Initial version
264+
Passing custom mergers does not remove the default ones, but you can override them.
269265

270266
## License
271267

deps.edn

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{:deps
22
{org.clojure/clojure {:mvn/version "1.10.1"}
3-
org.clojure/tools.deps.alpha {:mvn/version "0.8.677"}}}
3+
org.clojure/tools.deps.alpha {:mvn/version "0.9.763"}}
4+
5+
:aliases
6+
{:test {:extra-paths ["test"]}}}

project.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
:url "https://github.com/tonsky/uberdeps"
55
:dependencies
66
[[org.clojure/clojure "1.10.1"]
7-
[org.clojure/tools.deps.alpha "0.8.677"]])
7+
[org.clojure/tools.deps.alpha "0.9.763"]])

script/test.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/zsh -euo pipefail
2+
3+
cd "`dirname $0`/.."
4+
5+
clj -A:test -m uberdeps.test

0 commit comments

Comments
 (0)