< prev index next >

buildSrc/src/main/java/workaround/GradleJUnitWorker.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * 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,10 +51,15 @@
  * 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,11 +139,11 @@
     static HashSet<String> ignoreSysProps  =  new HashSet(defSysProps.length + 10);
 
     public static void main(String args[]) {
 
         try {
-            ArrayList<String> cmd = new ArrayList<>(30);
+            final ArrayList<String> cmd = new ArrayList<>(30);
             String gradleWorkerJar = null;
             String patchesDir = null;
             String exportsFile = null;
             String classpathFile = null;
             String libraryPath = null;

@@ -147,19 +152,19 @@
             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";
+            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(java9Property);
+            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,14 +178,14 @@
                     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)) {
+                } else if (args[i].contains(javaCmdProperty)) {
                     int equals = args[i].indexOf("=");
                     java9path = args[i].substring(equals+1);
-                    if (debug) System.err.println("XWORKER "+java9Property+"="+java9path);
+                    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,11 +342,11 @@
 
             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);
+                java9path = System.getProperty(javaCmdProperty);
             }
 
             String java_cmd = "java";
             if (java9path != null) {
                 // good we have it - probably the safest way on windows

@@ -361,34 +366,46 @@
                 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);
             }
 
-            cmd.add("@" + classPathArgFile.getAbsolutePath());
+            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 >