From e69e7af14fc77e5d89eb5d1394fddf2b3ebc4f94 Mon Sep 17 00:00:00 2001 From: Alexander Suter Date: Mon, 22 Jul 2024 14:42:11 +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 --- .../ch/ivyteam/ivy/maven/deploy/AbstractDeployMojo.java | 2 +- .../maven/engine/deploy/DeploymentOptionsFileFactory.java | 8 ++++---- .../ivyteam/ivy/maven/deploy/TestDeployToEngineMojo.java | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/ch/ivyteam/ivy/maven/deploy/AbstractDeployMojo.java b/src/main/java/ch/ivyteam/ivy/maven/deploy/AbstractDeployMojo.java index 6b2cb9a0..0c678d55 100644 --- a/src/main/java/ch/ivyteam/ivy/maven/deploy/AbstractDeployMojo.java +++ b/src/main/java/ch/ivyteam/ivy/maven/deploy/AbstractDeployMojo.java @@ -186,7 +186,7 @@ public abstract class AbstractDeployMojo extends AbstractIntegrationTestMojo { * Guide */ @Parameter(property = "ivy.deploy.options.file", required = false) - protected File deployOptionsFile; + protected Path deployOptionsFile; @Component private MavenFileFilter fileFilter; diff --git a/src/main/java/ch/ivyteam/ivy/maven/engine/deploy/DeploymentOptionsFileFactory.java b/src/main/java/ch/ivyteam/ivy/maven/engine/deploy/DeploymentOptionsFileFactory.java index 67766a7f..1fd7d3bb 100644 --- a/src/main/java/ch/ivyteam/ivy/maven/engine/deploy/DeploymentOptionsFileFactory.java +++ b/src/main/java/ch/ivyteam/ivy/maven/engine/deploy/DeploymentOptionsFileFactory.java @@ -23,16 +23,16 @@ public DeploymentOptionsFileFactory(Path deployableArtifact) { this.deployableArtifact = deployableArtifact; } - public Path createFromTemplate(File optionsFile, MavenProject project, MavenSession session, + public Path createFromTemplate(Path optionsFile, MavenProject project, MavenSession session, MavenFileFilter fileFilter) throws MojoExecutionException { - if (!isOptionsFile(optionsFile)) { + if (!isOptionsFile(optionsFile.toFile())) { return null; } - String fileFormat = FilenameUtils.getExtension(optionsFile.getName()); + String fileFormat = FilenameUtils.getExtension(optionsFile.getFileName().toString()); var targetFile = getTargetFile(fileFormat); try { - fileFilter.copyFile(optionsFile, targetFile.toFile(), true, project, Collections.emptyList(), false, + fileFilter.copyFile(optionsFile.toFile(), targetFile.toFile(), true, project, Collections.emptyList(), false, StandardCharsets.UTF_8.name(), session); } catch (MavenFilteringException ex) { throw new MojoExecutionException("Failed to resolve templates in options file", ex); diff --git a/src/test/java/ch/ivyteam/ivy/maven/deploy/TestDeployToEngineMojo.java b/src/test/java/ch/ivyteam/ivy/maven/deploy/TestDeployToEngineMojo.java index f4a59f1e..83e93eb0 100644 --- a/src/test/java/ch/ivyteam/ivy/maven/deploy/TestDeployToEngineMojo.java +++ b/src/test/java/ch/ivyteam/ivy/maven/deploy/TestDeployToEngineMojo.java @@ -66,7 +66,7 @@ public void deployWithExistingOptionsFile() throws Throwable { rule.project.getProperties().setProperty("doDeploy.test.user", "true"); DeployToEngineMojo mojo = rule.getMojo(); - mojo.deployOptionsFile = new File("src/test/resources/options.yaml"); + mojo.deployOptionsFile = Path.of("src/test/resources/options.yaml"); var deployedIar = getTarget(mojo.deployFile, mojo); var deploymentOptionsFile = deployedIar.resolveSibling(deployedIar.getFileName() + ".options.yaml"); @@ -137,6 +137,7 @@ public void failOnEngineDeployError() throws Throwable { DelayedOperation mockEngineDeployThread = new DelayedOperation(500, TimeUnit.MILLISECONDS); Callable engineOperation = () -> { + Files.createDirectories(markers.errorLog().getParent()); Files.writeString(markers.errorLog(), "validation errors"); assertThat(deployedIar).exists(); Files.delete(deployedIar);