Skip to content

Commit a7577c2

Browse files
committed
Fixes
1 parent 6e812b9 commit a7577c2

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

shared/src/main/java/eu/maveniverse/maven/toolbox/shared/internal/ToolboxCommandoImpl.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,11 @@
4141
import eu.maveniverse.maven.toolbox.shared.ToolboxSearchApi;
4242
import eu.maveniverse.maven.toolbox.shared.output.Output;
4343
import java.io.ByteArrayOutputStream;
44-
import java.io.FileInputStream;
4544
import java.io.IOException;
4645
import java.io.InputStream;
4746
import java.nio.charset.StandardCharsets;
4847
import java.nio.file.Files;
4948
import java.nio.file.Path;
50-
import java.nio.file.Paths;
5149
import java.security.MessageDigest;
5250
import java.security.NoSuchAlgorithmException;
5351
import java.text.CharacterIterator;
@@ -632,10 +630,9 @@ public Result<Path> localRepository() throws Exception {
632630
public Result<Path> artifactPath(Artifact artifact, RemoteRepository repository) throws Exception {
633631
Result<Path> result;
634632
if (repository == null) {
635-
result =
636-
Result.success(Paths.get(session.getLocalRepositoryManager().getPathForLocalArtifact(artifact)));
633+
result = Result.success(Path.of(session.getLocalRepositoryManager().getPathForLocalArtifact(artifact)));
637634
} else {
638-
result = Result.success(Paths.get(
635+
result = Result.success(Path.of(
639636
session.getLocalRepositoryManager().getPathForRemoteArtifact(artifact, repository, "toolbox")));
640637
}
641638
result.getData().ifPresent(path -> output.tell(path.toString()));
@@ -646,10 +643,9 @@ public Result<Path> artifactPath(Artifact artifact, RemoteRepository repository)
646643
public Result<Path> metadataPath(Metadata metadata, RemoteRepository repository) throws Exception {
647644
Result<Path> result;
648645
if (repository == null) {
649-
result =
650-
Result.success(Paths.get(session.getLocalRepositoryManager().getPathForLocalMetadata(metadata)));
646+
result = Result.success(Path.of(session.getLocalRepositoryManager().getPathForLocalMetadata(metadata)));
651647
} else {
652-
result = Result.success(Paths.get(
648+
result = Result.success(Path.of(
653649
session.getLocalRepositoryManager().getPathForRemoteMetadata(metadata, repository, "toolbox")));
654650
}
655651
result.getData().ifPresent(path -> output.tell(path.toString()));
@@ -1084,13 +1080,13 @@ public Result<Map<String, Artifact>> identify(
10841080
RemoteRepository remoteRepository, Collection<String> targets, boolean decorated) throws IOException {
10851081
HashMap<String, String> sha1s = new HashMap<>();
10861082
for (String target : targets) {
1087-
if (Files.exists(Paths.get(target))) {
1083+
if (Files.exists(Path.of(target))) {
10881084
try {
10891085
output.tell("Calculating SHA1 of file {}", target);
10901086
MessageDigest sha1md = MessageDigest.getInstance("SHA-1");
10911087
byte[] buf = new byte[8192];
10921088
int read;
1093-
try (FileInputStream fis = new FileInputStream(target)) {
1089+
try (InputStream fis = Files.newInputStream(Path.of(target))) {
10941090
read = fis.read(buf);
10951091
while (read != -1) {
10961092
sha1md.update(buf, 0, read);

shared/src/test/java/eu/maveniverse/maven/toolbox/shared/internal/ArtifactSinksTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import eu.maveniverse.maven.mima.context.Runtimes;
1717
import eu.maveniverse.maven.toolbox.shared.Sink;
1818
import eu.maveniverse.maven.toolbox.shared.output.NopOutput;
19-
import java.nio.file.Paths;
19+
import java.nio.file.Path;
2020
import java.util.HashMap;
2121
import org.eclipse.aether.artifact.Artifact;
2222
import org.eclipse.aether.repository.RemoteRepository;
@@ -27,7 +27,7 @@ public class ArtifactSinksTest {
2727
void parse() {
2828
Runtime runtime = Runtimes.INSTANCE.getRuntime();
2929
try (Context context = runtime.create(ContextOverrides.create()
30-
.withBasedirOverride(Paths.get("target").toAbsolutePath())
30+
.withBasedirOverride(Path.of("target").toAbsolutePath())
3131
.build())) {
3232
ToolboxCommandoImpl tc = new ToolboxCommandoImpl(NopOutput.INSTANCE, context);
3333

shared/src/test/java/eu/maveniverse/maven/toolbox/shared/internal/ToolboxCommandoImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import eu.maveniverse.maven.mima.context.Runtimes;
1414
import eu.maveniverse.maven.toolbox.shared.output.NopOutput;
1515
import java.io.IOException;
16-
import java.nio.file.Paths;
16+
import java.nio.file.Path;
1717
import org.junit.jupiter.api.Disabled;
1818
import org.junit.jupiter.api.Test;
1919

@@ -24,7 +24,7 @@ public class ToolboxCommandoImplTest {
2424
void search() throws IOException {
2525
Runtime runtime = Runtimes.INSTANCE.getRuntime();
2626
try (Context context = runtime.create(ContextOverrides.create()
27-
.withBasedirOverride(Paths.get("target").toAbsolutePath())
27+
.withBasedirOverride(Path.of("target").toAbsolutePath())
2828
.build())) {
2929
ToolboxCommandoImpl tc = new ToolboxCommandoImpl(NopOutput.INSTANCE, context);
3030

toolbox/src/main/java/eu/maveniverse/maven/toolbox/plugin/GavMojoSupport.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.nio.file.Files;
1414
import java.nio.file.InvalidPathException;
1515
import java.nio.file.Path;
16-
import java.nio.file.Paths;
1716
import java.util.Arrays;
1817
import java.util.Collection;
1918
import java.util.Collections;
@@ -40,7 +39,7 @@ protected Collection<String> slurp(String csv) throws IOException {
4039
return Collections.emptyList();
4140
}
4241
try {
43-
Path target = Paths.get(csv).toAbsolutePath();
42+
Path target = Path.of(csv).toAbsolutePath();
4443
if (Files.isRegularFile(target) && Files.size(target) < 5_000_000) {
4544
return Files.readAllLines(target);
4645
}

0 commit comments

Comments
 (0)