< prev index next >
buildSrc/src/main/java/workaround/GradleJUnitWorker.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 51,60 ****
--- 51,65 ----
* specified, certain command line properties may either be :
* an argument - because it came after this file
* a property - because it was before this file and was processed as a property
* Because of this, everything is checked as both.
*
+ * The worker specific properties are found below as worker.*. These
+ * properties also need to be forwarded as system properties just in case
+ * we have something like MainLauncherTest that needs some of these to
+ * construct a new java command.
+ *
*/
public class GradleJUnitWorker {
public static boolean debug = false;
*** 134,144 ****
static HashSet<String> ignoreSysProps = new HashSet(defSysProps.length + 10);
public static void main(String args[]) {
try {
! ArrayList<String> cmd = new ArrayList<>(30);
String gradleWorkerJar = null;
String patchesDir = null;
String exportsFile = null;
String classpathFile = null;
String libraryPath = null;
--- 139,149 ----
static HashSet<String> ignoreSysProps = new HashSet(defSysProps.length + 10);
public static void main(String args[]) {
try {
! final ArrayList<String> cmd = new ArrayList<>(30);
String gradleWorkerJar = null;
String patchesDir = null;
String exportsFile = null;
String classpathFile = null;
String libraryPath = null;
*** 147,165 ****
final String exportsFileProperty = "worker.exports.file";
final String workerDebugProperty = "worker.debug";
final String patchesDirProperty = "worker.xpatch.dir";
final String classpathFileProperty = "worker.classpath.file";
final String libraryPathProperty = "worker.library.path";
! final String java9Property = "worker.java9";
Collections.addAll(ignoreSysProps, defSysProps);
ignoreSysProps.add(exportsFileProperty);
ignoreSysProps.add(workerDebugProperty);
ignoreSysProps.add(patchesDirProperty);
ignoreSysProps.add(classpathFileProperty);
ignoreSysProps.add(libraryPathProperty);
! ignoreSysProps.add(java9Property);
debug = Boolean.parseBoolean(System.getProperty(workerDebugProperty, "false"));
ArrayList<String> newArgs = new ArrayList<>(50);
for (int i = 0; i < args.length; i++) {
--- 152,170 ----
final String exportsFileProperty = "worker.exports.file";
final String workerDebugProperty = "worker.debug";
final String patchesDirProperty = "worker.xpatch.dir";
final String classpathFileProperty = "worker.classpath.file";
final String libraryPathProperty = "worker.library.path";
! final String javaCmdProperty = "worker.java.cmd";
Collections.addAll(ignoreSysProps, defSysProps);
ignoreSysProps.add(exportsFileProperty);
ignoreSysProps.add(workerDebugProperty);
ignoreSysProps.add(patchesDirProperty);
ignoreSysProps.add(classpathFileProperty);
ignoreSysProps.add(libraryPathProperty);
! ignoreSysProps.add(javaCmdProperty);
debug = Boolean.parseBoolean(System.getProperty(workerDebugProperty, "false"));
ArrayList<String> newArgs = new ArrayList<>(50);
for (int i = 0; i < args.length; i++) {
*** 173,186 ****
if (debug) System.err.println("XWORKER "+exportsFileProperty+"="+exportsFile);
} else if (args[i].contains(patchesDirProperty)) {
int equals = args[i].indexOf("=");
patchesDir = args[i].substring(equals+1);
if (debug) System.err.println("XWORKER "+patchesDirProperty+"="+patchesDir);
! } else if (args[i].contains(java9Property)) {
int equals = args[i].indexOf("=");
java9path = args[i].substring(equals+1);
! if (debug) System.err.println("XWORKER "+java9Property+"="+java9path);
} else if (args[i].contains(classpathFileProperty)) {
int equals = args[i].indexOf("=");
classpathFile = args[i].substring(equals+1);
if (debug) System.err.println("XWORKER "+classpathFileProperty+"="+classpathFile);
} else if (args[i].contains(libraryPathProperty)) {
--- 178,191 ----
if (debug) System.err.println("XWORKER "+exportsFileProperty+"="+exportsFile);
} else if (args[i].contains(patchesDirProperty)) {
int equals = args[i].indexOf("=");
patchesDir = args[i].substring(equals+1);
if (debug) System.err.println("XWORKER "+patchesDirProperty+"="+patchesDir);
! } else if (args[i].contains(javaCmdProperty)) {
int equals = args[i].indexOf("=");
java9path = args[i].substring(equals+1);
! if (debug) System.err.println("XWORKER "+javaCmdProperty+"="+java9path);
} else if (args[i].contains(classpathFileProperty)) {
int equals = args[i].indexOf("=");
classpathFile = args[i].substring(equals+1);
if (debug) System.err.println("XWORKER "+classpathFileProperty+"="+classpathFile);
} else if (args[i].contains(libraryPathProperty)) {
*** 337,347 ****
String jdk_home = System.getProperty("JDK_HOME");
if (debug) System.err.println("XWORKER JDK_HOME is set to " + jdk_home);
if (java9path == null) {
! java9path = System.getProperty(java9Property);
}
String java_cmd = "java";
if (java9path != null) {
// good we have it - probably the safest way on windows
--- 342,352 ----
String jdk_home = System.getProperty("JDK_HOME");
if (debug) System.err.println("XWORKER JDK_HOME is set to " + jdk_home);
if (java9path == null) {
! java9path = System.getProperty(javaCmdProperty);
}
String java_cmd = "java";
if (java9path != null) {
// good we have it - probably the safest way on windows
*** 361,394 ****
System.err.println("XWORKER using java " + java_cmd);
}
cmd.add(java_cmd);
if (patchesDir == null) {
patchesDir = System.getProperty(patchesDirProperty);
}
if (patchesDir != null) {
cmd.add("-Xpatch:" + patchesDir);
}
if (exportsFile == null) {
exportsFile = System.getProperty(exportsFileProperty);
}
if (exportsFile != null) {
cmd.add("@" + exportsFile);
}
! cmd.add("@" + classPathArgFile.getAbsolutePath());
if (libraryPath == null) {
libraryPath = System.getProperty(libraryPathProperty);
}
if (libraryPath != null) {
cmd.add("-Djava.library.path=" + libraryPath);
}
//forward any old system properties, other than the stock ones
Properties p = System.getProperties();
Enumeration keys = p.keys();
--- 366,411 ----
System.err.println("XWORKER using java " + java_cmd);
}
cmd.add(java_cmd);
+ cmd.add("-D"+javaCmdProperty+"="+java_cmd);
+
if (patchesDir == null) {
patchesDir = System.getProperty(patchesDirProperty);
}
if (patchesDir != null) {
cmd.add("-Xpatch:" + patchesDir);
+ cmd.add("-D"+patchesDirProperty+"="+patchesDir);
}
if (exportsFile == null) {
exportsFile = System.getProperty(exportsFileProperty);
}
if (exportsFile != null) {
cmd.add("@" + exportsFile);
+ cmd.add("-D"+exportsFileProperty+"="+exportsFile);
}
! final String cleanpath =
! classPathArgFile.getAbsolutePath().replaceAll("\\\\", "/");
! cmd.add("@" + cleanpath);
! cmd.add("-D"+classpathFileProperty+"="+cleanpath);
if (libraryPath == null) {
libraryPath = System.getProperty(libraryPathProperty);
}
if (libraryPath != null) {
cmd.add("-Djava.library.path=" + libraryPath);
+ cmd.add("-D"+libraryPathProperty+"="+libraryPath);
+ }
+
+ if (debug) {
+ cmd.add("-D"+workerDebugProperty+"="+debug);
}
//forward any old system properties, other than the stock ones
Properties p = System.getProperties();
Enumeration keys = p.keys();
< prev index next >