Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile-no-fork with existing jar FileSystems (#547) #548

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.FileSystemAlreadyExistsException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;
Expand Down Expand Up @@ -293,13 +294,23 @@ protected void addArtifactToClasspath(Artifact artifact) throws MojoExecutionExc
Optional.ofNullable(processSupportedArtifacts(artifact)).ifPresent(imageClasspath::add);
}

private static FileSystem openFileSystem(URI uri) throws IOException {
FileSystem fs;
try {
fs = FileSystems.newFileSystem(uri, Collections.emptyMap());
} catch (FileSystemAlreadyExistsException e) {
fs = FileSystems.getFileSystem(uri);
}
return fs;
}

protected void warnIfWrongMetaInfLayout(Path jarFilePath, Artifact artifact) throws MojoExecutionException {
if (jarFilePath.toFile().isDirectory()) {
logger.debug("Artifact `" + jarFilePath + "` is a directory.");
return;
}
URI jarFileURI = URI.create("jar:" + jarFilePath.toUri());
try (FileSystem jarFS = FileSystems.newFileSystem(jarFileURI, Collections.emptyMap())) {
try (FileSystem jarFS = openFileSystem(jarFileURI)) {
Path nativeImageMetaInfBase = jarFS.getPath("/" + NATIVE_IMAGE_META_INF);
if (Files.isDirectory(nativeImageMetaInfBase)) {
try (Stream<Path> stream = Files.walk(nativeImageMetaInfBase)) {
Expand Down