コード例 #1
0
  private int compare(Revision a, Revision b) {
    if (Arrays.equals(a._id, b._id)) return 0;

    Version va = getVersion(a);
    Version vb = getVersion(b);
    int n = va.compareTo(vb);
    if (n != 0) return n;

    if (a.created != b.created) return a.created > b.created ? 1 : -1;

    for (int i = 0; i < a._id.length; i++)
      if (a._id[i] != b._id[i]) return a._id[i] > b._id[i] ? 1 : -1;

    return 0;
  }
コード例 #2
0
  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();
    }
  }