From 5f657d389223bd43957ba6ea30e458729af45724 Mon Sep 17 00:00:00 2001 From: Alexander Suter Date: Mon, 22 Jul 2024 16:36:52 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=B5=F0=9F=90=B6=F0=9F=90=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ivy/maven/deploy/DeployToEngineMojo.java | 13 ++++++------- .../ivy/maven/deploy/DeployToTestEngineMojo.java | 6 +++--- .../maven/deploy/TestDeployToTestEngineMojo.java | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/ch/ivyteam/ivy/maven/deploy/DeployToEngineMojo.java b/src/main/java/ch/ivyteam/ivy/maven/deploy/DeployToEngineMojo.java index 2a16986c..82b36775 100644 --- a/src/main/java/ch/ivyteam/ivy/maven/deploy/DeployToEngineMojo.java +++ b/src/main/java/ch/ivyteam/ivy/maven/deploy/DeployToEngineMojo.java @@ -16,7 +16,7 @@ package ch.ivyteam.ivy.maven.deploy; -import java.io.File; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -166,13 +166,13 @@ private void deployToDirectory(Path resolvedOptionsFile) throws MojoExecutionExc return; } - if (!deployDir.exists()) { + if (!Files.exists(deployDir)) { getLog().warn("Skipping deployment to engine '" + deployEngineDirectory + "'. The directory '" + deployDir + "' does not exist."); return; } checkDirParams(); - deployToDirectory(resolvedOptionsFile, deployDir.toPath()); + deployToDirectory(resolvedOptionsFile, deployDir); } private void deployToRestService(Path resolvedOptionsFile) throws MojoExecutionException { @@ -213,14 +213,14 @@ private void logParameterIgnoredByMethod(String parameter, String value, String + " deployment."); } - private File getDeployDirectory() throws MojoExecutionException { + private Path getDeployDirectory() throws MojoExecutionException { if (deployEngineDirectory == null || engineToTarget()) { // re-use engine used to build deployEngineDirectory = getEngineDir(project).toPath(); } if (Paths.get(deployDirectory).isAbsolute()) { - return new File(deployDirectory); + return Paths.get(deployDirectory); } - return new File(deployEngineDirectory.toFile(), deployDirectory); + return deployEngineDirectory.resolve(deployDirectory); } public static interface DefaultDeployOptions { @@ -234,5 +234,4 @@ public static interface DeployMethod { String DIRECTORY = "DIRECTORY"; String HTTP = "HTTP"; } - } diff --git a/src/main/java/ch/ivyteam/ivy/maven/deploy/DeployToTestEngineMojo.java b/src/main/java/ch/ivyteam/ivy/maven/deploy/DeployToTestEngineMojo.java index 3f4d1eeb..e16b8173 100644 --- a/src/main/java/ch/ivyteam/ivy/maven/deploy/DeployToTestEngineMojo.java +++ b/src/main/java/ch/ivyteam/ivy/maven/deploy/DeployToTestEngineMojo.java @@ -123,7 +123,7 @@ Path createFullAppZip(List deps) throws ArchiverException, IOException { if (d.isFile() && d.getName().endsWith("iar")) { appZipper.addFile(d, d.getName()); } else if (d.isDirectory()) { - Optional packedIar = findPackedIar(d); + Optional packedIar = findPackedIar(dep); if (packedIar.isPresent()) { File iar = packedIar.get().toFile(); appZipper.addFile(iar, iar.getName()); @@ -139,8 +139,8 @@ Path createFullAppZip(List deps) throws ArchiverException, IOException { return appZip.toPath(); } - static Optional findPackedIar(File dep) throws IOException { - Path target = dep.toPath().resolve("target"); + static Optional findPackedIar(Path dep) throws IOException { + var target = dep.resolve("target"); if (!Files.isDirectory(target)) { return Optional.empty(); } diff --git a/src/test/java/ch/ivyteam/ivy/maven/deploy/TestDeployToTestEngineMojo.java b/src/test/java/ch/ivyteam/ivy/maven/deploy/TestDeployToTestEngineMojo.java index b1802db9..9c3d770d 100644 --- a/src/test/java/ch/ivyteam/ivy/maven/deploy/TestDeployToTestEngineMojo.java +++ b/src/test/java/ch/ivyteam/ivy/maven/deploy/TestDeployToTestEngineMojo.java @@ -57,7 +57,7 @@ public void autoAppZip() throws ArchiverException, IOException { reactorProject, builtTarget.getParent())); assertThat(appZip.getFileName().toString()).isEqualTo("myApp-app.zip"); - assertThat(DeployToTestEngineMojo.findPackedIar(builtTarget.getParent().toFile())).isPresent(); + assertThat(DeployToTestEngineMojo.findPackedIar(builtTarget.getParent())).isPresent(); assertThat(getRootFiles(appZip)) .containsOnly("demo.iar", "demoTest.iar", "myReactorProject", "alreadyPacked.iar"); }