Skip to content

Commit 60d60a8

Browse files
committed
Use basedir as forked JVM's working directory in Maven plugin
Fixes gh-16811
1 parent 32e1d68 commit 60d60a8

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/it/run-fork/src/main/java/org/test/SampleApplication.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,10 +16,12 @@
1616

1717
package org.test;
1818

19+
import java.io.File;
20+
1921
public class SampleApplication {
2022

2123
public static void main(String[] args) {
22-
System.out.println("I haz been run");
24+
System.out.println("I haz been run from '" + new File("").getAbsolutePath() + "'");
2325
}
2426

2527
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
def file = new File(basedir, "build.log")
2-
return file.text.contains("I haz been run")
2+
return file.text.contains("I haz been run from '$basedir'")
33

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,10 @@ private void doRunWithForkedJvm(String startClassName)
281281
addClasspath(args);
282282
args.add(startClassName);
283283
addArgs(args);
284-
runWithForkedJvm(this.workingDirectory, args, determineEnvironmentVariables());
284+
runWithForkedJvm(
285+
(this.workingDirectory != null) ? this.workingDirectory
286+
: this.project.getBasedir(),
287+
args, determineEnvironmentVariables());
285288
}
286289

287290
/**

0 commit comments

Comments
 (0)