use of aQute.jpm.lib.JVM in project bnd by bndtools.
the class JPMTest method testVM.
public void testVM() throws Exception {
File tmp = new File("tmp");
IO.delete(tmp);
tmp.mkdirs();
File home = new File(tmp, "home");
File bin = new File(tmp, "bin");
System.setProperty("jpm.intest", "true");
JustAnotherPackageManager jpm = new JustAnotherPackageManager(new ReporterAdapter(), null, home, bin);
SortedSet<JVM> vms = jpm.getVMs();
assertNotNull(vms);
assertTrue(vms.size() >= 1);
System.out.println(vms);
File f = IO.getFile("~/jdk1.8");
if (f.isDirectory()) {
JVM jvm = jpm.addVm(f);
assertNotNull(jvm);
}
}
use of aQute.jpm.lib.JVM in project bnd by bndtools.
the class MacOS method getJVM.
@Override
public JVM getJVM(File vmdir) throws Exception {
if (!vmdir.isDirectory()) {
return null;
}
File contents = new File(vmdir, "Contents");
if (!contents.isDirectory()) {
logger.debug("Found a directory {}, but it does not have the expected Contents directory", vmdir);
return null;
}
File plist = new File(contents, "Info.plist");
if (!plist.isFile()) {
logger.debug("The VM in {} has no Info.plist with the necessary details", vmdir);
return null;
}
File home = new File(contents, "Home");
String error = verifyVM(home);
if (error != null) {
reporter.error("Invalid vm directory for MacOS %s: %s", vmdir, error);
return null;
}
DocumentBuilder db = dbf.newDocumentBuilder();
try {
Document doc = db.parse(plist);
XPath xp = xpf.newXPath();
Node versionNode = (Node) xp.evaluate("//dict/key[text()='JVMVersion']", doc, XPathConstants.NODE);
Node platformVersionNode = (Node) xp.evaluate("//dict/key[text()='JVMPlatformVersion']", doc, XPathConstants.NODE);
Node vendorNode = (Node) xp.evaluate("//dict/key[text()='JVMVendor']", doc, XPathConstants.NODE);
Node capabilitiesNode = (Node) xp.evaluate("//dict/key[text()='JVMCapabilities']", doc, XPathConstants.NODE);
JVM jvm = new JVM();
jvm.name = vmdir.getName();
jvm.path = home.getCanonicalPath();
jvm.platformRoot = vmdir.getCanonicalPath();
jvm.version = getSiblingValue(versionNode);
jvm.platformVersion = getSiblingValue(platformVersionNode);
jvm.vendor = getSiblingValue(vendorNode);
return jvm;
} catch (Exception e) {
logger.debug("Could not parse the Info.plist in {}", vmdir, e);
throw e;
}
}
Aggregations