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 3fd2744 commit 7068a47
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/main/java/ch/ivyteam/ivy/maven/engine/EngineControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ private CommandLine toEngineCommand(Command command) {
classpath += File.pathSeparator + context.vmOptions.additionalClasspath;
}

File osgiDir = new File(context.engineDirectory, OsgiDir.INSTALL_AREA);
var osgiDir = context.engineDirectory.resolve(OsgiDir.INSTALL_AREA);

CommandLine cli = new CommandLine(new File(getJavaExec()))
.addArgument("-classpath").addArgument(classpath)
.addArgument("-Divy.engine.testheadless=true")
.addArgument("-Djava.awt.headless=true")
.addArgument("-Dosgi.install.area=" + osgiDir.getAbsolutePath());
.addArgument("-Dosgi.install.area=" + osgiDir.toAbsolutePath());

if (StringUtils.isNotBlank(context.vmOptions.additionalVmOptions)) {
cli.addArguments(context.vmOptions.additionalVmOptions, false);
Expand All @@ -133,7 +133,7 @@ private CommandLine toEngineCommand(Command command) {

private Executor createEngineExecutor() {
return DefaultExecutor.builder()
.setWorkingDirectory(context.engineDirectory)
.setWorkingDirectory(context.engineDirectory.toFile())
.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class EngineModuleHints {

public static void loadFromJvmOptionsFile(EngineMojoContext context, CommandLine cli) {
loadJvmOptions(context.engineDirectory.toPath(), context.log).stream().forEach(option -> cli.addArgument(option));
loadJvmOptions(context.engineDirectory, context.log).stream().forEach(option -> cli.addArgument(option));
}

public static String loadFromJvmOptionsFile(Path identifyAndGetEngineDirectory, Log log) {
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.Files;
import java.nio.file.Path;

import org.apache.maven.plugin.logging.Log;
Expand All @@ -27,7 +28,7 @@
import ch.ivyteam.ivy.maven.util.SharedFile;

public class EngineMojoContext {
public final File engineDirectory;
public final Path engineDirectory;
public final MavenProject project;
public final Log log;
public final EngineVmOptions vmOptions;
Expand All @@ -36,7 +37,7 @@ public class EngineMojoContext {
public final Path engineLogFile;
public final Integer timeoutInSeconds;

public EngineMojoContext(File engineDirectory, MavenProject project, Log log, Path engineLogFile,
public EngineMojoContext(Path engineDirectory, MavenProject project, Log log, Path engineLogFile,
EngineVmOptions vmOptions, Integer timeoutInSeconds) {
this.engineDirectory = engineDirectory;
this.project = project;
Expand All @@ -51,7 +52,7 @@ public EngineMojoContext(File engineDirectory, MavenProject project, Log log, Pa
if (!(new File(engineClasspathJarPath).exists())) {
throw new RuntimeException("Engine ClasspathJar " + engineClasspathJarPath + " does not exist.");
}
if (!(engineDirectory.exists())) {
if (!Files.exists(engineDirectory)) {
throw new RuntimeException("Engine Directory " + engineDirectory + " does not exist.");
}
}
Expand All @@ -62,7 +63,7 @@ private String setupEngineClasspathJarIfNotExists() {
try {
log.info("Creating a classpath jar for starting the engine");
new ClasspathJar(classpathJar)
.createFileEntries(EngineClassLoaderFactory.getOsgiBootstrapClasspath(engineDirectory));
.createFileEntries(EngineClassLoaderFactory.getOsgiBootstrapClasspath(engineDirectory.toFile()));
} catch (Exception ex) {
throw new RuntimeException(
"Could not create engine classpath jar: '" + classpathJar.getAbsolutePath() + "'", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package ch.ivyteam.ivy.maven.test;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -108,15 +107,15 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}

public Executor startEngine() throws Exception {
File engineDir = identifyAndGetEngineDirectory();
var engineDir = identifyAndGetEngineDirectory();

if (engineToTarget()) {
engineDir = copyEngineToTarget(engineDir.toPath()).toFile();
}

EngineVmOptions vmOptions = new EngineVmOptions(maxmem, additionalClasspath, additionalVmOptions);
EngineControl engineControl = new EngineControl(new EngineMojoContext(
engineDir, project, getLog(), engineLogFile, vmOptions, startTimeoutInSeconds));
engineDir.toPath(), project, getLog(), engineLogFile, vmOptions, startTimeoutInSeconds));
return engineControl.start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package ch.ivyteam.ivy.maven.test;

import java.io.File;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
Expand All @@ -30,7 +28,7 @@

/**
* Stops the Axon Ivy Engine after integration testing
*
*
* @since 6.2.0
*/
@Mojo(name = StopTestEngineMojo.GOAL)
Expand Down Expand Up @@ -78,14 +76,14 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}

public EngineControl createEngineController() throws MojoExecutionException {
File engineDir = getEngineDir(project);
var engineDir = getEngineDir(project);
if (engineDir == null || !engineDir.exists()) {
engineDir = identifyAndGetEngineDirectory();
}

EngineVmOptions vmOptions = new EngineVmOptions(maxmem, additionalClasspath, additionalVmOptions);
EngineControl engineControl = new EngineControl(new EngineMojoContext(
engineDir, project, getLog(), null, vmOptions, stopTimeoutInSeconds));
engineDir.toPath(), project, getLog(), null, vmOptions, stopTimeoutInSeconds));
return engineControl;
}

Expand Down

0 comments on commit 7068a47

Please sign in to comment.