Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Jan 29, 2025
1 parent 6e812b9 commit a7577c2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@
import eu.maveniverse.maven.toolbox.shared.ToolboxSearchApi;
import eu.maveniverse.maven.toolbox.shared.output.Output;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.CharacterIterator;
Expand Down Expand Up @@ -632,10 +630,9 @@ public Result<Path> localRepository() throws Exception {
public Result<Path> artifactPath(Artifact artifact, RemoteRepository repository) throws Exception {
Result<Path> result;
if (repository == null) {
result =
Result.success(Paths.get(session.getLocalRepositoryManager().getPathForLocalArtifact(artifact)));
result = Result.success(Path.of(session.getLocalRepositoryManager().getPathForLocalArtifact(artifact)));
} else {
result = Result.success(Paths.get(
result = Result.success(Path.of(
session.getLocalRepositoryManager().getPathForRemoteArtifact(artifact, repository, "toolbox")));
}
result.getData().ifPresent(path -> output.tell(path.toString()));
Expand All @@ -646,10 +643,9 @@ public Result<Path> artifactPath(Artifact artifact, RemoteRepository repository)
public Result<Path> metadataPath(Metadata metadata, RemoteRepository repository) throws Exception {
Result<Path> result;
if (repository == null) {
result =
Result.success(Paths.get(session.getLocalRepositoryManager().getPathForLocalMetadata(metadata)));
result = Result.success(Path.of(session.getLocalRepositoryManager().getPathForLocalMetadata(metadata)));
} else {
result = Result.success(Paths.get(
result = Result.success(Path.of(
session.getLocalRepositoryManager().getPathForRemoteMetadata(metadata, repository, "toolbox")));
}
result.getData().ifPresent(path -> output.tell(path.toString()));
Expand Down Expand Up @@ -1084,13 +1080,13 @@ public Result<Map<String, Artifact>> identify(
RemoteRepository remoteRepository, Collection<String> targets, boolean decorated) throws IOException {
HashMap<String, String> sha1s = new HashMap<>();
for (String target : targets) {
if (Files.exists(Paths.get(target))) {
if (Files.exists(Path.of(target))) {
try {
output.tell("Calculating SHA1 of file {}", target);
MessageDigest sha1md = MessageDigest.getInstance("SHA-1");
byte[] buf = new byte[8192];
int read;
try (FileInputStream fis = new FileInputStream(target)) {
try (InputStream fis = Files.newInputStream(Path.of(target))) {
read = fis.read(buf);
while (read != -1) {
sha1md.update(buf, 0, read);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import eu.maveniverse.maven.mima.context.Runtimes;
import eu.maveniverse.maven.toolbox.shared.Sink;
import eu.maveniverse.maven.toolbox.shared.output.NopOutput;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.HashMap;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.repository.RemoteRepository;
Expand All @@ -27,7 +27,7 @@ public class ArtifactSinksTest {
void parse() {
Runtime runtime = Runtimes.INSTANCE.getRuntime();
try (Context context = runtime.create(ContextOverrides.create()
.withBasedirOverride(Paths.get("target").toAbsolutePath())
.withBasedirOverride(Path.of("target").toAbsolutePath())
.build())) {
ToolboxCommandoImpl tc = new ToolboxCommandoImpl(NopOutput.INSTANCE, context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import eu.maveniverse.maven.mima.context.Runtimes;
import eu.maveniverse.maven.toolbox.shared.output.NopOutput;
import java.io.IOException;
import java.nio.file.Paths;
import java.nio.file.Path;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -40,7 +39,7 @@ protected Collection<String> slurp(String csv) throws IOException {
return Collections.emptyList();
}
try {
Path target = Paths.get(csv).toAbsolutePath();
Path target = Path.of(csv).toAbsolutePath();
if (Files.isRegularFile(target) && Files.size(target) < 5_000_000) {
return Files.readAllLines(target);
}
Expand Down

0 comments on commit a7577c2

Please sign in to comment.