Skip to content

Commit

Permalink
šŸµšŸ¶šŸ»
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsuter committed Jul 22, 2024
1 parent c99c5dc commit 3fd2744
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
15 changes: 8 additions & 7 deletions src/main/java/ch/ivyteam/ivy/maven/engine/EngineControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -139,7 +138,7 @@ private Executor createEngineExecutor() {
}

private PumpStreamHandler createEngineLogStreamForwarder(Consumer<String> logLineHandler)
throws FileNotFoundException {
throws IOException {
OutputStream output = getEngineLogTarget();
OutputStream engineLogStream = new LineOrientedOutputStreamRedirector(output) {
@Override
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 3fd2744

Please sign in to comment.