Exemple #1
0
    @Override
    protected CellEditor getCellEditor(Object element) {

      Set<String> versions = new TreeSet<String>();
      if (element instanceof Baseline) {
        Baseline info = (Baseline) element;
        versions.add(info.getSuggestedVersion().toString());
      }
      if (element instanceof Info) {
        Info info = (Info) element;
        versions.add(info.suggestedVersion.toString());
      }

      editor.setItems(versions.toArray(new String[versions.size()]));
      return editor;
    }
  protected void doBaselineJar(Jar jar, File output, aQute.bnd.build.Project bndProject)
      throws Exception {

    if (_reportLevelIsOff) {
      return;
    }

    ProjectBuilder projectBuilder = new ProjectBuilder(bndProject);

    projectBuilder.setClasspath(_classpathFiles.toArray(new File[_classpathFiles.size()]));
    projectBuilder.setPedantic(isPedantic());
    projectBuilder.setProperties(_file);
    projectBuilder.setSourcepath(new File[] {_sourcePath});

    Jar baselineJar = projectBuilder.getBaselineJar();

    try {
      if (baselineJar == null) {
        bndProject.deploy(output);

        return;
      }

      Baseline baseline = new Baseline(this, _diffPluginImpl);

      Set<Info> infos = baseline.baseline(jar, baselineJar, null);

      if (infos.isEmpty()) {
        return;
      }

      BundleInfo bundleInfo = baseline.getBundleInfo();

      Info[] infosArray = infos.toArray(new Info[infos.size()]);

      Arrays.sort(
          infosArray,
          new Comparator<Info>() {

            @Override
            public int compare(Info info1, Info info2) {
              return info1.packageName.compareTo(info2.packageName);
            }
          });

      for (Info info : infosArray) {
        String warnings = "-";

        Version newerVersion = info.newerVersion;
        Version suggestedVersion = info.suggestedVersion;

        if (suggestedVersion != null) {
          if (newerVersion.compareTo(suggestedVersion) > 0) {
            warnings = "EXCESSIVE VERSION INCREASE";
          } else if (newerVersion.compareTo(suggestedVersion) < 0) {
            warnings = "VERSION INCREASE REQUIRED";
          }
        }

        Diff packageDiff = info.packageDiff;

        Delta delta = packageDiff.getDelta();

        if (delta == Delta.REMOVED) {
          warnings = "PACKAGE REMOVED";
        } else if (delta == Delta.UNCHANGED) {
          boolean newVersionSuggested = false;

          if ((suggestedVersion.getMajor() != newerVersion.getMajor())
              || (suggestedVersion.getMicro() != newerVersion.getMicro())
              || (suggestedVersion.getMinor() != newerVersion.getMinor())) {

            warnings = "VERSION INCREASE SUGGESTED";

            newVersionSuggested = true;
          }

          if (!newVersionSuggested && !info.mismatch) {
            continue;
          }
        }

        if (((_reportLevelIsStandard || _reportOnlyDirtyPackages) && warnings.equals("-"))
            || (_reportOnlyDirtyPackages && (delta == Delta.REMOVED))) {

          continue;
        }

        doInfo(bundleInfo, info, warnings);

        if (_reportLevelIsDiff && (delta != Delta.REMOVED)) {
          doPackageDiff(packageDiff);
        }
      }
    } finally {
      if (baselineJar != null) {
        baselineJar.close();
      }

      if (_printWriter != null) {
        _printWriter.close();
      }

      projectBuilder.close();
    }
  }