From 2126538a0e4907eb8e88c3b20e952d16e8ce704d Mon Sep 17 00:00:00 2001 From: Sergii Druzkin <65374769+sdruzkin@users.noreply.github.com> Date: Mon, 11 Jul 2022 15:54:08 -0700 Subject: [PATCH] Allow to specify JVM path --- .../tools/maven/AbstractScalaTestMojo.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/scalatest/tools/maven/AbstractScalaTestMojo.java b/src/main/java/org/scalatest/tools/maven/AbstractScalaTestMojo.java index adebcbc..761362e 100644 --- a/src/main/java/org/scalatest/tools/maven/AbstractScalaTestMojo.java +++ b/src/main/java/org/scalatest/tools/maven/AbstractScalaTestMojo.java @@ -234,6 +234,14 @@ abstract class AbstractScalaTestMojo extends AbstractMojo { */ String workingDirectory; + /** + * Option to specify an alternative path to JVM (or path to the java executable) to use with + * the forked process. + * + * @parameter property="jvm" + */ + String jvm; + // runScalaTest is called by the concrete mojo subclasses TODO: make it protected and others too // Returns true if all tests pass boolean runScalaTest(String[] args) throws MojoFailureException { @@ -274,7 +282,12 @@ private boolean runForkingOnce(String[] args) throws MojoFailureException { } else { cli.setWorkingDirectory(workingDirectory); } - cli.setExecutable(getJvm()); + + if (this.jvm == null || this.jvm.isEmpty()) { + cli.setExecutable(getJvm()); + } else { + cli.setExecutable(this.jvm); + } // Set up environment if (environmentVariables != null) {