Use basedir as forked JVM's working directory in Maven plugin

Fixes gh-16811
This commit is contained in:
Andy Wilkinson 2019-05-24 20:49:03 +01:00
parent 32e1d68d2f
commit 60d60a8304
3 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,10 +16,12 @@
package org.test;
import java.io.File;
public class SampleApplication {
public static void main(String[] args) {
System.out.println("I haz been run");
System.out.println("I haz been run from '" + new File("").getAbsolutePath() + "'");
}
}

View File

@ -1,3 +1,3 @@
def file = new File(basedir, "build.log")
return file.text.contains("I haz been run")
return file.text.contains("I haz been run from '$basedir'")

View File

@ -281,7 +281,10 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
addClasspath(args);
args.add(startClassName);
addArgs(args);
runWithForkedJvm(this.workingDirectory, args, determineEnvironmentVariables());
runWithForkedJvm(
(this.workingDirectory != null) ? this.workingDirectory
: this.project.getBasedir(),
args, determineEnvironmentVariables());
}
/**