From: Jim Procter Date: Tue, 11 Sep 2018 15:05:02 +0000 (+0100) Subject: JAL-3112 Use classgraph to reconstruct the classpath for launching Jalview X-Git-Tag: Release_2_11_1_0~107^2^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d3546f175bfbb5d16ed7942bf8e602e8ba53c5b5;p=jalview.git JAL-3112 Use classgraph to reconstruct the classpath for launching Jalview --- diff --git a/.classpath b/.classpath index f4d788d..0da91bb 100644 --- a/.classpath +++ b/.classpath @@ -48,6 +48,7 @@ + diff --git a/THIRDPARTYLIBS b/THIRDPARTYLIBS index c7c9b5d..afa99d2 100644 --- a/THIRDPARTYLIBS +++ b/THIRDPARTYLIBS @@ -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 diff --git a/test/jalview/bin/CommandLineOperations.java b/test/jalview/bin/CommandLineOperations.java index d586dae..b81facf 100644 --- a/test/jalview/bin/CommandLineOperations.java +++ b/test/jalview/bin/CommandLineOperations.java @@ -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 index 0000000..a0788bc Binary files /dev/null and b/utils/classgraph-4.1.6.jar differ