JAL-3112 Use classgraph to reconstruct the classpath for launching Jalview
authorJim Procter <jprocter@issues.jalview.org>
Tue, 11 Sep 2018 15:05:02 +0000 (16:05 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 11 Sep 2018 15:05:02 +0000 (16:05 +0100)
.classpath
THIRDPARTYLIBS
test/jalview/bin/CommandLineOperations.java
utils/classgraph-4.1.6.jar [new file with mode: 0644]

index f4d788d..0da91bb 100644 (file)
@@ -48,6 +48,7 @@
        <classpathentry kind="lib" path="lib/jfreesvg-2.1.jar"/>
        <classpathentry kind="lib" path="lib/quaqua-filechooser-only-8.0.jar"/>
        <classpathentry kind="lib" path="lib/VAqua5-patch.jar"/>
+       <classpathentry kind="lib" path="utils/classgraph-4.1.6.jar"/>
        <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/plugin"/>
        <classpathentry kind="lib" path="lib/xml-apis.jar"/>
        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
index c7c9b5d..afa99d2 100644 (file)
@@ -58,6 +58,12 @@ lib/biojava-core-4.1.0.jar LGPLv2.1 - latest license at https://github.com/bioja
 lib/biojava-ontology-4.1.0.jar LGPLv2.1 - latest license at https://github.com/biojava/biojava/blob/master/LICENSE
 
 
+Libraries for Test Suite
+
+utils/classgraph-4.1.6.jar: BSD License - allows recovery of classpath for programmatic construction of a Java command line to launch Jalview
+                      version 4.1.6 downloaded from https://mvnrepository.com/artifact/io.github.classgraph/classgraph/4.1.6
+
+
 Additional dependencies
 
 examples/javascript/deployJava.js : http://java.com/js/deployJava.js
index d586dae..b81facf 100644 (file)
@@ -35,6 +35,9 @@ import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
+import io.github.classgraph.ClassGraph;
+import io.github.classgraph.ScanResult;
+
 public class CommandLineOperations
 {
 
@@ -113,21 +116,39 @@ public class CommandLineOperations
     }
   }
 
-  private Worker jalviewDesktopRunner(boolean withAwt, String cmd,
-          int timeout)
+  private static ClassGraph scanner = null;
+
+  private static String classpath = null;
+
+  public synchronized static String getClassPath()
   {
-    String cp_sep = ":";
-    if (System.getProperty("os.name").indexOf("Windows") >= 0)
+    if (scanner == null)
+    {
+      scanner = new ClassGraph();
+      ScanResult scan = scanner.scan();
+      classpath = scan.getClasspath();
+    }
+    while (classpath == null)
     {
-      cp_sep = ";";
+      try
+      {
+        Thread.sleep(10);
+      } catch (InterruptedException x)
+      {
+
+      }
     }
+    return classpath;
+  }
+  private Worker jalviewDesktopRunner(boolean withAwt, String cmd,
+          int timeout)
+  {
     // Note: JAL-3065 - don't include quotes for lib/* because the arguments are
     // not expanded by the shell
+    String classpath = getClassPath();
     String _cmd = "java "
             + (withAwt ? "-Djava.awt.headless=true" : "")
-            + " -classpath ./classes" + cp_sep
-            + "./lib/* jalview.bin.Jalview ";
-    System.out.println("CMD [" + cmd + "]");
+            + " -classpath " + classpath + " jalview.bin.Jalview ";
     Process ls2_proc = null;
     Worker worker = null;
     try
diff --git a/utils/classgraph-4.1.6.jar b/utils/classgraph-4.1.6.jar
new file mode 100644 (file)
index 0000000..a0788bc
Binary files /dev/null and b/utils/classgraph-4.1.6.jar differ