diff --git a/src/main/java/ch/ivyteam/ivy/maven/engine/EngineControl.java b/src/main/java/ch/ivyteam/ivy/maven/engine/EngineControl.java index 34440809..de60ed1f 100644 --- a/src/main/java/ch/ivyteam/ivy/maven/engine/EngineControl.java +++ b/src/main/java/ch/ivyteam/ivy/maven/engine/EngineControl.java @@ -18,8 +18,6 @@ import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.net.URI; @@ -28,6 +26,7 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; +import java.nio.file.Files; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; @@ -139,7 +138,7 @@ private Executor createEngineExecutor() { } private PumpStreamHandler createEngineLogStreamForwarder(Consumer logLineHandler) - throws FileNotFoundException { + throws IOException { OutputStream output = getEngineLogTarget(); OutputStream engineLogStream = new LineOrientedOutputStreamRedirector(output) { @Override @@ -163,15 +162,17 @@ public void stop() throws IOException { return streamHandler; } - private OutputStream getEngineLogTarget() throws FileNotFoundException { + private OutputStream getEngineLogTarget() throws IOException { if (context.engineLogFile == null) { context.log.info("Do not forward engine output to a persistent location"); return new ByteArrayOutputStream(); } - context.properties.setMavenProperty(Property.TEST_ENGINE_LOG, context.engineLogFile.getAbsolutePath()); - context.log.info("Forwarding engine logs to: " + context.engineLogFile.getAbsolutePath()); - return new FileOutputStream(context.engineLogFile.getAbsolutePath()); + var logFile = context.engineLogFile; + var logFilePath = logFile.toAbsolutePath().toString(); + context.properties.setMavenProperty(Property.TEST_ENGINE_LOG, logFilePath); + context.log.info("Forwarding engine logs to: " + logFilePath); + return Files.newOutputStream(logFile); } private String getJavaExec() { diff --git a/src/main/java/ch/ivyteam/ivy/maven/engine/EngineMojoContext.java b/src/main/java/ch/ivyteam/ivy/maven/engine/EngineMojoContext.java index 770d72bd..37a64946 100644 --- a/src/main/java/ch/ivyteam/ivy/maven/engine/EngineMojoContext.java +++ b/src/main/java/ch/ivyteam/ivy/maven/engine/EngineMojoContext.java @@ -17,6 +17,7 @@ package ch.ivyteam.ivy.maven.engine; import java.io.File; +import java.nio.file.Path; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; @@ -32,10 +33,10 @@ public class EngineMojoContext { public final EngineVmOptions vmOptions; public final String engineClasspathJarPath; public final MavenProperties properties; - public final File engineLogFile; + public final Path engineLogFile; public final Integer timeoutInSeconds; - public EngineMojoContext(File engineDirectory, MavenProject project, Log log, File engineLogFile, + public EngineMojoContext(File engineDirectory, MavenProject project, Log log, Path engineLogFile, EngineVmOptions vmOptions, Integer timeoutInSeconds) { this.engineDirectory = engineDirectory; this.project = project; diff --git a/src/main/java/ch/ivyteam/ivy/maven/test/StartTestEngineMojo.java b/src/main/java/ch/ivyteam/ivy/maven/test/StartTestEngineMojo.java index d375f286..f8e6d376 100644 --- a/src/main/java/ch/ivyteam/ivy/maven/test/StartTestEngineMojo.java +++ b/src/main/java/ch/ivyteam/ivy/maven/test/StartTestEngineMojo.java @@ -83,7 +83,7 @@ public class StartTestEngineMojo extends AbstractIntegrationTestMojo { /** The file where the engine start is logged **/ @Parameter(property = "ivy.engine.start.log", required = false, defaultValue = "${project.build.directory}/testEngineOut.log") - File engineLogFile; + Path engineLogFile; /** The maximum amount of seconds that we wait for a engine to start */ @Parameter(property = IVY_ENGINE_START_TIMEOUT_SECONDS, defaultValue = "120")