Skip to content

Commit 935c3e1

Browse files
committed
Merge branch 'develop'
2 parents 113eeb9 + 8cb68b7 commit 935c3e1

File tree

46 files changed

+394
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+394
-242
lines changed

.github/workflows/check-links.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
- name: Check links
3636
id: lychee
37-
uses: lycheeverse/lychee-action@v1.10.0
37+
uses: lycheeverse/lychee-action@v2.3.0
3838
with:
3939
fail: true
4040
args: --max-concurrency 1 --cache --no-progress --exclude-all-private './**/*.md'

.github/workflows/heylogs.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,25 @@ name: Heylogs
22

33
on: [ push ]
44

5+
env:
6+
MAVEN_ARGS: "-B -ntp"
7+
58
jobs:
69
badge-job:
710
if: startsWith(github.repository, 'nbbrd/') && startsWith(github.ref, 'refs/heads/develop')
811
runs-on: ubuntu-latest
912
steps:
10-
- name: Checkout source code
11-
uses: actions/checkout@v4
12-
13-
- name: Setup Java
14-
uses: actions/setup-java@v4
15-
with:
16-
distribution: 'temurin'
17-
java-version: 21
18-
cache: 'maven'
19-
13+
- name: Checkout and Setup Maven
14+
15+
2016
- name: Scan changelog
21-
run: mvn -B -ntp -U com.github.nbbrd.heylogs:heylogs-maven-plugin::scan -Dheylogs.output.file=scan.json -Dheylogs.format.id=json
22-
17+
run: mvn -U com.github.nbbrd.heylogs:heylogs-maven-plugin::scan -Dheylogs.output.file=scan.json -Dheylogs.format.id=json
18+
2319
- name: Create badges endpoint json
2420
run: |
2521
mkdir heylogs
2622
jq '{schemaVersion: 1, label: "unreleased changes", message: "#\(.[0].summary.unreleasedChanges)", color: "E05735", logoColor: "white", namedLogo: "keepachangelog"}' scan.json > heylogs/unreleased-changes.json
27-
23+
2824
- name: Deploy badges endpoint json
2925
uses: peaceiris/actions-gh-pages@v4
3026
with:

.github/workflows/java-ea-maven.yml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,42 @@ on:
66
- develop
77
workflow_dispatch:
88

9+
env:
10+
MAVEN_ARGS: "-B -ntp"
11+
912
jobs:
1013
build-and-test-job:
1114
strategy:
1215
fail-fast: false
1316
matrix:
14-
java: [ 21 ]
15-
os: [ ubuntu-latest, macos-latest ]
17+
java: [ 23 ]
18+
os:
19+
- ubuntu-latest # Linux x64
20+
- ubuntu-24.04-arm # Linux arm64
21+
- macos-latest # macOS arm64
1622

1723
name: JDK${{ matrix.java }} on ${{ matrix.os }}
1824
runs-on: ${{ matrix.os }}
1925

2026
steps:
21-
- name: Checkout source code
22-
uses: actions/checkout@v4
23-
with:
24-
submodules: true
25-
fetch-depth: 0
26-
27-
- name: Setup Java
28-
uses: actions/setup-java@v4
27+
- name: Checkout and Setup Maven
28+
2929
with:
30-
distribution: 'temurin'
30+
checkout-submodules: true
31+
checkout-fetch-depth: 0
3132
java-version: ${{ matrix.java }}
32-
cache: 'maven'
3333

34-
- name: Build and (headless) test with Maven
35-
uses: smithki/[email protected]
34+
- name: Pre-download dependencies with Maven
35+
uses: nick-fields/retry@v3
3636
with:
37-
run: mvn -U -B -ntp verify
37+
command: mvn -U dependency:go-offline
38+
max_attempts: 3
39+
timeout_minutes: 5
40+
41+
- name: Build and (headless) test with Maven (Linux)
42+
if: ${{ runner.os == 'Linux' }}
43+
run: xvfb-run mvn verify
44+
45+
- name: Build and (headless) test with Maven (Windows and macOS)
46+
if: ${{ runner.os != 'Linux' }}
47+
run: mvn verify

.github/workflows/java8-maven.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Java8+ with Maven
22

33
on: [ push, pull_request ]
44

5+
env:
6+
MAVEN_ARGS: "-B -ntp"
7+
58
jobs:
69
build-and-test-job:
710
if: github.event_name == 'pull_request' || startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/tags/v')
@@ -24,21 +27,24 @@ jobs:
2427
- name: Setup Java
2528
uses: actions/setup-java@v4
2629
with:
27-
distribution: 'temurin'
30+
distribution: 'zulu'
2831
java-version: ${{ matrix.java }}
2932
cache: 'maven'
3033

3134
- name: Pre-download dependencies with Maven
3235
uses: nick-fields/retry@v3
3336
with:
34-
command: mvn -U -B -ntp dependency:go-offline
37+
command: mvn -U dependency:go-offline
3538
max_attempts: 3
3639
timeout_minutes: 5
3740

38-
- name: Build and (headless) test with Maven
39-
uses: smithki/[email protected]
40-
with:
41-
run: mvn -U -B -ntp verify
41+
- name: Build and (headless) test with Maven (Linux)
42+
if: ${{ runner.os == 'Linux' }}
43+
run: xvfb-run mvn -U verify
44+
45+
- name: Build and (headless) test with Maven (Windows and macOS)
46+
if: ${{ runner.os != 'Linux' }}
47+
run: mvn -U verify
4248

4349
auto-merge-job:
4450
needs: build-and-test-job
@@ -82,20 +88,20 @@ jobs:
8288
- name: Setup Java
8389
uses: actions/setup-java@v4
8490
with:
85-
distribution: 'temurin'
91+
distribution: 'zulu'
8692
java-version: ${{ matrix.java }}
8793
cache: 'maven'
8894

8995
- name: Deploy snapshot with Maven if settings defined
90-
run: test ! -f ci.settings.xml || mvn -B -ntp deploy -DskipTests -s ci.settings.xml -P base-deploy,snapshot-deploy,!non-deployable-modules
96+
run: test ! -f ci.settings.xml || mvn deploy -DskipTests -s ci.settings.xml -P base-deploy,snapshot-deploy,!non-deployable-modules
9197
env:
9298
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
9399
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
94100
SIGN_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
95101
SIGN_KEY_PASS: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
96102

97103
- name: Dryrun release assets with Maven
98-
run: mvn -B -ntp install -DskipTests -P full-release -Djreleaser.output.directory=$PWD/out/jreleaser -Djreleaser.dry.run
104+
run: mvn install -DskipTests -P full-release -Djreleaser.output.directory=$PWD/out/jreleaser -Djreleaser.dry.run
99105
env:
100106
JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }}
101107
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.MAVEN_GPG_PUBLIC_KEY }}
@@ -132,12 +138,12 @@ jobs:
132138
- name: Setup Java
133139
uses: actions/setup-java@v4
134140
with:
135-
distribution: 'temurin'
141+
distribution: 'zulu'
136142
java-version: ${{ matrix.java }}
137143
cache: 'maven'
138144

139145
- name: Deploy with Maven if settings defined
140-
run: test ! -f ci.settings.xml || mvn -B -ntp deploy -DskipTests -s ci.settings.xml -P base-deploy,release-deploy,!non-deployable-modules
146+
run: test ! -f ci.settings.xml || mvn deploy -DskipTests -s ci.settings.xml -P base-deploy,release-deploy,!non-deployable-modules
141147
env:
142148
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
143149
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
@@ -147,7 +153,7 @@ jobs:
147153
MAVEN_OPTS: "--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED"
148154

149155
- name: Release assets with Maven
150-
run: mvn -B -ntp install -DskipTests -P full-release -Djreleaser.output.directory=$PWD/out/jreleaser
156+
run: mvn install -DskipTests -P full-release -Djreleaser.output.directory=$PWD/out/jreleaser
151157
env:
152158
JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }}
153159
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.MAVEN_GPG_PUBLIC_KEY }}

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
## [0.0.33] - 2025-03-06
11+
12+
### Added
13+
14+
- Add static factory shortcuts to Picocsv parser/formatter
15+
- Add path shortcuts to CScriptWrapper and PowerShellWrapper
16+
- Add process shortcut to TextParser
17+
18+
### Changed
19+
20+
- Modernize use of NIO API
21+
1022
## [0.0.32] - 2024-09-25
1123

1224
### Fixed
@@ -280,7 +292,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
280292

281293
- Initial release
282294

283-
[Unreleased]: https://github.com/nbbrd/java-io-util/compare/v0.0.32...HEAD
295+
[Unreleased]: https://github.com/nbbrd/java-io-util/compare/v0.0.33...HEAD
296+
[0.0.33]: https://github.com/nbbrd/java-io-util/compare/v0.0.32...v0.0.33
284297
[0.0.32]: https://github.com/nbbrd/java-io-util/compare/v0.0.31...v0.0.32
285298
[0.0.31]: https://github.com/nbbrd/java-io-util/compare/v0.0.30...v0.0.31
286299
[0.0.30]: https://github.com/nbbrd/java-io-util/compare/v0.0.29...v0.0.30

java-io-base/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.github.nbbrd.java-io-util</groupId>
77
<artifactId>java-io-parent</artifactId>
8-
<version>0.0.32</version>
8+
<version>0.0.33</version>
99
</parent>
1010

1111
<artifactId>java-io-base</artifactId>

java-io-base/src/main/java/internal/io/InternalResource.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package internal.io;
22

3-
import java.io.ByteArrayOutputStream;
4-
import java.io.IOException;
5-
import java.io.InputStream;
6-
import java.io.OutputStream;
3+
import nbbrd.io.function.IOSupplier;
4+
5+
import java.io.*;
76

87
@lombok.experimental.UtilityClass
98
public class InternalResource {
@@ -23,4 +22,19 @@ public static void transferTo(InputStream input, OutputStream output) throws IOE
2322
output.write(buffer, 0, read);
2423
}
2524
}
25+
26+
public static InputStream openInputStream(IOSupplier<? extends InputStream> source) throws IOException {
27+
return checkResource(source.getWithIO(), "Missing InputStream");
28+
}
29+
30+
public static OutputStream openOutputStream(IOSupplier<? extends OutputStream> source) throws IOException {
31+
return checkResource(source.getWithIO(), "Missing OutputStream");
32+
}
33+
34+
public static <T extends Closeable> T checkResource(T resource, String message) throws IOException {
35+
if (resource == null) {
36+
throw new IOException(message);
37+
}
38+
return resource;
39+
}
2640
}

java-io-base/src/main/java/internal/io/LockingFileFormatter.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import nbbrd.io.function.IOSupplier;
77

88
import java.io.File;
9-
import java.io.FileOutputStream;
109
import java.io.IOException;
1110
import java.io.OutputStream;
1211
import java.nio.channels.Channels;
1312
import java.nio.channels.FileChannel;
1413
import java.nio.channels.FileLock;
1514
import java.nio.channels.OverlappingFileLockException;
15+
import java.nio.file.InvalidPathException;
1616
import java.nio.file.Path;
1717
import java.nio.file.StandardOpenOption;
1818

@@ -25,12 +25,10 @@ public final class LockingFileFormatter<T> implements FileFormatter<T> {
2525

2626
@Override
2727
public void formatFile(@NonNull T value, @NonNull File target) throws IOException {
28-
try (FileOutputStream stream = new FileOutputStream(checkTarget(target))) {
29-
try (FileLock ignore = stream.getChannel().lock()) {
30-
delegate.formatStream(value, stream);
31-
} catch (OverlappingFileLockException ex) {
32-
throw WrappedIOException.wrap(ex);
33-
}
28+
try {
29+
formatPath(value, target.toPath());
30+
} catch (InvalidPathException ex) {
31+
throw WrappedIOException.wrap(ex);
3432
}
3533
}
3634

java-io-base/src/main/java/internal/io/LockingFileParser.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import nbbrd.io.function.IOSupplier;
77

88
import java.io.File;
9-
import java.io.FileInputStream;
109
import java.io.IOException;
1110
import java.io.InputStream;
1211
import java.nio.channels.Channels;
1312
import java.nio.channels.FileChannel;
1413
import java.nio.channels.FileLock;
1514
import java.nio.channels.OverlappingFileLockException;
15+
import java.nio.file.InvalidPathException;
1616
import java.nio.file.Path;
1717
import java.nio.file.StandardOpenOption;
1818

@@ -25,12 +25,10 @@ public final class LockingFileParser<T> implements FileParser<T> {
2525

2626
@Override
2727
public @NonNull T parseFile(@NonNull File source) throws IOException {
28-
try (FileInputStream stream = new FileInputStream(checkSource(source))) {
29-
try (FileLock ignore = stream.getChannel().lock(0, Long.MAX_VALUE, true)) {
30-
return delegate.parseStream(stream);
31-
} catch (OverlappingFileLockException ex) {
32-
throw WrappedIOException.wrap(ex);
33-
}
28+
try {
29+
return parsePath(source.toPath());
30+
} catch (InvalidPathException ex) {
31+
throw WrappedIOException.wrap(ex);
3432
}
3533
}
3634

java-io-base/src/main/java/internal/io/text/BufferedInputStreamWithFile.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)