From 6b0c06afdd701fc4892021c1bbc5098e7841c1df Mon Sep 17 00:00:00 2001 From: "mykola.hryhoriev" Date: Fri, 22 Jan 2021 10:49:45 +0200 Subject: [PATCH] Add ability to customize working directory of forked process --- pom.xml | 2 +- .../tools/maven/AbstractScalaTestMojo.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1458110..6d20ca0 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.scalatest scalatest-maven-plugin maven-plugin - 2.0.2 + 2.0.3 ScalaTest Maven Plugin Integrates ScalaTest into Maven diff --git a/src/main/java/org/scalatest/tools/maven/AbstractScalaTestMojo.java b/src/main/java/org/scalatest/tools/maven/AbstractScalaTestMojo.java index 8f9d1ce..f7b78d4 100644 --- a/src/main/java/org/scalatest/tools/maven/AbstractScalaTestMojo.java +++ b/src/main/java/org/scalatest/tools/maven/AbstractScalaTestMojo.java @@ -224,6 +224,13 @@ abstract class AbstractScalaTestMojo extends AbstractMojo { */ double spanScaleFactor = 1.0; + /** + * The current working directory for forked process. Optional. If not specified, basedir will be used. + * + * @parameter property="workingDirectory" + */ + String workingDirectory; + // 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 { @@ -259,7 +266,11 @@ private boolean runWithoutForking(String[] args) { private boolean runForkingOnce(String[] args) throws MojoFailureException { final Commandline cli = new Commandline(); - cli.setWorkingDirectory(project.getBasedir()); + if ((this.workingDirectory == null || this.workingDirectory.isEmpty())) { + cli.setWorkingDirectory(project.getBasedir()); + } else { + cli.setWorkingDirectory(workingDirectory); + } cli.setExecutable(getJvm()); // Set up environment