/** * Gets an instance of the step with the supplied name. * * @param _name The step name. * @param _properties The step properties. * @return The step. */ private static Object getStep(String _name, Properties _properties) { try { String name = _name; if (consoleMode) { name += ".console"; } String classname = steps.getProperty(name); if (classname == null) { throw new RuntimeException(Installer.getString("step.not.found", _name)); } Constructor constructor = Class.forName(classname).getConstructor(new Class[] {String.class, Properties.class}); WizardStep step = (WizardStep) constructor.newInstance(new Object[] {_name, _properties}); if (consoleMode) { return new ConsoleWizardStep((ConsoleStep) step); } return new GuiWizardStep((GuiStep) step); } catch (InvocationTargetException ite) { Throwable target = ite.getTargetException(); if (target instanceof IllegalArgumentException) { throw (IllegalArgumentException) target; } throw new RuntimeException(target); } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new RuntimeException(Installer.getString("step.error.loading", _name), e); } }
public Status validate() { String eclipseHome = (String) Installer.getContext().getValue("eclipse.home"); eclipseHome = eclipseHome.replace('\\', '/'); // probably a better way File file = new File(eclipseHome + "/readme/readme_eclipse.html"); String version = null; if (file.exists()) { version = versionFromReadme(file); } if (version == null) { version = versionFromPlugins(eclipseHome); } if (version == null) { return new Status(WARN, Installer.getString("eclipse.validation.failed")); } String[] parts = StringUtils.split(version, '.'); int major = Integer.parseInt(parts[0]); int minor = Integer.parseInt(parts[1]); int patch = parts.length > 2 ? Integer.parseInt(parts[2]) : 0; if (major < 3 || minor < 7 || patch < 0) { return new Status( FAIL, Installer.getString("eclipse.version.invalid", version, "3.7.x (Indigo)")); } return OK_STATUS; }
public Status validate() { try { CommandExecutor command = CommandExecutor.execute(new String[] {"vim", "--version"}, 2000); if (command.getReturnCode() != 0) { logger.error("Error checking vim version: {}", command.getErrorMessage()); return new Status(WARN, Installer.getString("vim.validation.failed")); } String result = command.getResult(); Matcher matcher = VERSION.matcher(result); if (!matcher.find()) { logger.error("Error finding vim version in output: {}", result); return new Status(WARN, Installer.getString("vim.validation.failed")); } String version = matcher.group(1); String[] parts = StringUtils.split(version, '.'); int major = Integer.parseInt(parts[0]); int minor = Integer.parseInt(parts[1]); int patch = parts.length > 2 ? Integer.parseInt(parts[2]) : 0; if (major < 7 || minor < 0 || patch < 0) { return new Status(FAIL, Installer.getString("vim.version.invalid", version, "7.0.x")); } } catch (Exception e) { logger.error("Error checking vim version.", e); return new Status(WARN, Installer.getString("vim.validation.failed")); } return OK_STATUS; }
public static EclipseInfo gatherEclipseInfo() throws Exception { final Map<String, Feature> installedFeatures = new HashMap<String, Feature>(); // run eclipse to get a list of existing installed features Command command = new InfoCommand( new OutputHandler() { public void process(String line) { logger.info(line); if (line.startsWith(FEATURE)) { String[] attrs = StringUtils.split(line.substring(FEATURE.length())); File site = null; try { site = new File(new URL(attrs[2]).getFile()); } catch (Exception e) { logger.error("Failed to parse feature: " + line, e); } installedFeatures.put(attrs[0], new Feature(attrs[1], site)); } else if (line.startsWith(CONFIGURATION)) { String config = line.substring(CONFIGURATION.length()); if (config.startsWith("file:")) { config = config.substring(5); } if (Os.isFamily(Os.FAMILY_WINDOWS) && config.startsWith("/")) { config = config.substring(1); } String local = new File(config).getParent(); logger.info("eclipse.local=" + local); Installer.getContext().setValue("eclipse.local", local); } else if (line.startsWith(PROFILE)) { String profile = line.substring(PROFILE.length()); logger.info("eclipse.profile=" + profile); Installer.getContext().setValue("eclipse.profile", profile); } } }); try { command.start(); command.join(); if (command.getReturnCode() != 0) { if (command.isShutdown()) { return null; } throw new RuntimeException( "error: " + command.getErrorMessage() + " out: " + command.getResult()); } } finally { command.destroy(); } return new EclipseInfo( (String) Installer.getContext().getValue("eclipse.profile"), (String) Installer.getContext().getValue("eclipse.local"), installedFeatures); }
public Status validate() { try { int result = Runtime.getRuntime().exec(new String[] {"which", program}).waitFor(); if (result != 0) { return new Status(FAIL, Installer.getString(program + ".not.found")); } } catch (Exception e) { logger.error("Error checking for '" + program + "'", e); return new Status(WARN, Installer.getString(program + ".validation.failed")); } return OK_STATUS; }
/** Installs the eclipse plugin used to install eclipse features. */ public static boolean installInstallerPlugin() throws Exception { File updateDir = Installer.tempDir("update"); Extractor.extractResource("/files/installer-update-site.zip", updateDir); String url = "file://" + updateDir; Command command = new InstallCommand(null, url, "org.eclim.installer", "org.eclipse.equinox.p2.director"); try { command.start(); command.join(); if (command.getReturnCode() != 0) { if (command.isShutdown()) { return false; } RuntimeException re = new RuntimeException( "error: " + command.getErrorMessage() + " out: " + command.getResult()); logger.warn( "Error installing eclim installer feature, " + "attempting uninstall/reinstall."); // attempt to uninstall the feature Command uninstall = new UninstallCommand( null, url, "org.eclim.installer", "org.eclipse.equinox.p2.director"); uninstall.start(); uninstall.join(); // now try to install again command = new InstallCommand(null, url, "org.eclim.installer", "org.eclipse.equinox.p2.director"); command.start(); command.join(); if (command.getReturnCode() != 0) { if (command.isShutdown()) { return false; } throw re; } } Installer.getProject().setProperty("eclim.installer.feature.installed", "true"); Installer.getProject().setProperty("eclim.installer.feature.location", url); } finally { command.destroy(); } return true; }
/** * Loads step name to step class mappings from the supplied resource. * * @param _resource The resource. */ public static void loadSteps(String _resource) { try { steps.load(Installer.class.getResourceAsStream(_resource)); } catch (NullPointerException npe) { throw new RuntimeException(Installer.getString("resource.not.found", _resource)); } catch (IOException ioe) { throw new RuntimeException(ioe); } }
/** * {@inheritDoc} * * @see RequirementProvider#getRequirements() */ public Requirement[] getRequirements() { if (Os.isFamily("windows")) { Requirement[] requirements = new Requirement[1]; requirements[0] = new EclipseRequirement(); return requirements; } InstallContext context = Installer.getContext(); boolean skipVim = ((Boolean) context.getValue("vim.skip")).booleanValue(); Requirement[] requirements = new Requirement[skipVim ? 3 : 4]; requirements[0] = new EclipseRequirement(); requirements[1] = new WhichRequirement("make"); requirements[2] = new WhichRequirement("gcc"); if (!skipVim) { requirements[3] = new VimRequirement(); } return requirements; }