From 235a5de6a478d252feb9e5a53e561a1d04a51754 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sat, 7 Dec 2024 18:42:53 +0000 Subject: [PATCH] Replace two deprecated methods (#224) * Replace 2 deprecated methods --- .../org/apache/maven/plugins/jlink/JLinkMojo.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java index 2458017..b2704da 100644 --- a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java +++ b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java @@ -41,10 +41,11 @@ import java.io.File; import java.io.IOException; +import java.nio.file.attribute.FileTime; +import java.time.Instant; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -368,7 +369,7 @@ public class JLinkMojo extends AbstractJLinkMojo { private String outputTimestamp; /** - * These files are added to the image after calling the jlink, but before creating the zipfile. + * These files are added to the image after calling jlink, but before creating the zip file. * * @since 3.2.0 */ @@ -491,8 +492,8 @@ private Map getModulePathElements() throws MojoFailureException { Optional toolchain = getToolchain(); if (toolchain.isPresent() && toolchain.orElseThrow(NoSuchElementException::new) instanceof DefaultJavaToolChain) { - Toolchain toolcahin1 = toolchain.orElseThrow(NoSuchElementException::new); - request.setJdkHome(new File(((DefaultJavaToolChain) toolcahin1).getJavaHome())); + Toolchain toolchain1 = toolchain.orElseThrow(NoSuchElementException::new); + request.setJdkHome(new File(((DefaultJavaToolChain) toolchain1).getJavaHome())); } ResolvePathsResult resolvePathsResult = locationManager.resolvePaths(request); @@ -576,9 +577,9 @@ private File createZipArchiveFromImage(File outputDirectory, File outputDirector zipArchiver.addDirectory(outputDirectoryImage); // configure for Reproducible Builds based on outputTimestamp value - Date lastModified = new MavenArchiver().parseOutputTimestamp(outputTimestamp); - if (lastModified != null) { - zipArchiver.configureReproducible(lastModified); + Optional lastModified = MavenArchiver.parseBuildOutputTimestamp(outputTimestamp); + if (lastModified.isPresent()) { + zipArchiver.configureReproducibleBuild(FileTime.from(lastModified.get())); } File resultArchive = getArchiveFile(outputDirectory, finalName, getClassifier(), "zip");