コード例 #1
0
ファイル: EclipseInfo.java プロジェクト: nkxiaochuan/eclim
  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);
  }
コード例 #2
0
    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;
    }
コード例 #3
0
  /**
   * {@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;
  }