protected int runEclipse(String message, File location, String[] args, File extensions) { File root = new File(Activator.getBundleContext().getProperty("java.home")); root = new File(root, "bin"); File exe = new File(root, "javaw.exe"); if (!exe.exists()) exe = new File(root, "java"); assertTrue("Java executable not found in: " + exe.getAbsolutePath(), exe.exists()); List<String> command = new ArrayList<String>(); Collections.addAll( command, new String[] { (new File(location == null ? output : location, getExeFolder() + "eclipse")) .getAbsolutePath(), "--launcher.suppressErrors", "-nosplash", "-vm", exe.getAbsolutePath() }); Collections.addAll(command, args); Collections.addAll(command, new String[] {"-vmArgs", "-Dosgi.checkConfiguration=true"}); // command-line if you want to run and allow a remote debugger to connect if (debug) Collections.addAll( command, new String[] { "-Xdebug", "-Xnoagent", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8787" }); int result = run(message, command.toArray(new String[command.size()])); // 13 means that we wrote something out in the log file. // so try and parse it and fail via that message if we can. if (result == 13) parseExitdata(message); return result; }
/* * Iterate over the sites in the given configuration and remove the one which * has a url matching the given location. */ public boolean removeSite(Configuration configuration, String location) throws IOException, URISyntaxException { File left = new File(new URI(location)).getCanonicalFile(); List sites = configuration.getSites(); for (Iterator iter = sites.iterator(); iter.hasNext(); ) { Site tempSite = (Site) iter.next(); String siteURL = tempSite.getUrl(); File right = new File(new URI(siteURL)).getCanonicalFile(); if (left.equals(right)) { return configuration.removeSite(tempSite); } } return false; }
/* * Assert that a feature with the given id exists in the configuration. If * a version is specified then match the version, otherwise any version will * do. */ public void assertFeatureExists( String message, Configuration configuration, String id, String version) { List sites = configuration.getSites(); assertNotNull(message, sites); boolean found = false; for (Iterator iter = sites.iterator(); iter.hasNext(); ) { Site site = (Site) iter.next(); Feature[] features = site.getFeatures(); for (int i = 0; features != null && i < features.length; i++) { if (id.equals(features[i].getId())) { if (version == null) found = true; else if (version.equals(features[i].getVersion())) found = true; } } } assertTrue(message, found); }
/* * Run the reconciler to discover changes in the drop-ins folder and update the system state. */ public void reconcile(String message, boolean clean) { List<String> args = new ArrayList<String>(); args.add("-application"); args.add("org.eclipse.equinox.p2.reconciler.application"); if (clean) args.add("-clean"); runEclipse(message, args.toArray(new String[args.size()])); }