mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-20 02:24:52 +00:00
Merge pull request #423 from gnodet/i422
Fix the environment update, fixes #422
This commit is contained in:
@@ -700,19 +700,26 @@ public class DaemonMavenCli {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static float javaSpec = 0.0f;
|
||||||
|
|
||||||
protected static void chDir(String workingDir) throws Exception {
|
protected static void chDir(String workingDir) throws Exception {
|
||||||
CLibrary.chdir(workingDir);
|
CLibrary.chdir(workingDir);
|
||||||
System.setProperty("user.dir", workingDir);
|
System.setProperty("user.dir", workingDir);
|
||||||
// change current dir for the java.io.File class
|
// change current dir for the java.io.File class
|
||||||
Class<?> fileClass = Class.forName("java.io.File");
|
Class<?> fileClass = Class.forName("java.io.File");
|
||||||
|
if (javaSpec <= 0.0f) {
|
||||||
|
javaSpec = Float.parseFloat(System.getProperty("java.specification.version"));
|
||||||
|
}
|
||||||
|
if (javaSpec >= 11.0) {
|
||||||
Field fsField = fileClass.getDeclaredField("fs");
|
Field fsField = fileClass.getDeclaredField("fs");
|
||||||
fsField.setAccessible(true);
|
fsField.setAccessible(true);
|
||||||
Object fs = fsField.get(null);
|
Object fs = fsField.get(null);
|
||||||
Field userDirField = fs.getClass().getDeclaredField("userDir");
|
Field userDirField = fs.getClass().getDeclaredField("userDir");
|
||||||
userDirField.setAccessible(true);
|
userDirField.setAccessible(true);
|
||||||
userDirField.set(fs, workingDir);
|
userDirField.set(fs, workingDir);
|
||||||
|
}
|
||||||
// change current dir for the java.nio.Path class
|
// change current dir for the java.nio.Path class
|
||||||
fs = FileSystems.getDefault();
|
Object fs = FileSystems.getDefault();
|
||||||
Class<?> fsClass = fs.getClass();
|
Class<?> fsClass = fs.getClass();
|
||||||
while (fsClass != Object.class) {
|
while (fsClass != Object.class) {
|
||||||
if ("sun.nio.fs.UnixFileSystem".equals(fsClass.getName())) {
|
if ("sun.nio.fs.UnixFileSystem".equals(fsClass.getName())) {
|
||||||
|
Reference in New Issue
Block a user