Package com.puppetlabs.geppetto.semver

Examples of com.puppetlabs.geppetto.semver.Version


    }

    void addIfAllMatch(Set<VersionRange> allRequirements, Map<Version, Metadata> relMap,
        Collection<Dependency> addedDependenciesCollector) {
      nextRelease: for(Metadata r : releases) {
        Version v = r.getVersion();
        for(VersionRange vr : allRequirements)
          if(!vr.isIncluded(v))
            continue nextRelease;

        if(addedDependenciesCollector != null) {
View Full Code Here


    if(module == null)
      return;

    SubMonitor submon = SubMonitor.convert(monitor, "Generating project...", 100);
    try {
      Version v = getModuleVersion(module);
      VersionRange vr = v == null
          ? null
          : VersionRange.exact(v);

      File projectDir = project.getLocation().toFile();
View Full Code Here

      try {
        org.apache.maven.artifact.versioning.VersionRange vr = org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec(dep.getVersion());
        List<Restriction> restrictions = vr.getRestrictions();
        if(restrictions.size() == 1) {
          Restriction r = restrictions.get(0);
          Version lower = r.getLowerBound() == null
              ? Version.MIN
              : Version.create(r.getLowerBound().toString());
          Version upper = r.getUpperBound() == null
              ? Version.MAX
              : Version.create(r.getUpperBound().toString());

          Dependency forgeDep = new Dependency();
          String dgid = mavenProject.getGroupId();
View Full Code Here

        Object[] selection = getSelectedElements();
        if(selection.length == 1) {
          VersionedName mi = (VersionedName) selection[0];
          moduleNameText.setText(mi.getModuleName().toString());
          Version v = mi.getVersion();
          versionRequirementText.setText(v == null
              ? ""
              : v.toString());
        }
      }
View Full Code Here

      if(tst.equals(moduleSource))
        throw new IllegalArgumentException("Destination cannot reside within the module itself");
    }

    ModuleName fullName = md.getName();
    Version ver = md.getVersion();
    if(fullName == null || ver == null)
      // Reason has been added to the Diagnostic result
      return null;

    /**
 
View Full Code Here

        if(tracer.isTracing())
          tracer.trace("Project not accessible: ", p.getName());
        continue;
      }

      Version version = null;
      ModuleName moduleName = null;
      try {
        String mn = p.getPersistentProperty(PROJECT_PROPERTY_MODULENAME);
        moduleName = mn == null
            ? null
            : ModuleName.fromString(mn);
      }
      catch(CoreException e) {
        log.error("Could not read project Modulename property", e);
      }
      if(tracer.isTracing())
        tracer.trace("Project: ", p.getName(), " has persisted name: ", moduleName);
      boolean matched = false;
      if(name.equals(moduleName))
        matched = true;

      if(tracer.isTracing()) {
        if(!matched)
          tracer.trace("== not matched on name");
      }
      // get the version from the persisted property
      if(matched) {
        try {
          version = Version.fromString(p.getPersistentProperty(PROJECT_PROPERTY_MODULEVERSION));
        }
        catch(Exception e) {
          log.error("Error while getting version from project", e);
        }
        if(version == null)
          version = Version.MIN;
        if(tracer.isTracing())
          tracer.trace("Candidate with version; ", version.toString(), " added as candidate");
        candidates.put(p, version);
      }
    }
    if(candidates.isEmpty()) {
      if(tracer.isTracing())
        tracer.trace("No candidates found");
      return null;
    }
    if(tracer.isTracing()) {
      tracer.trace("Getting best version");
    }
    // find best version and do a lookup of project
    if(vr == null)
      vr = VersionRange.ALL_INCLUSIVE;
    Version best = vr.findBestMatch(candidates.values());
    if(best == null) {
      if(tracer.isTracing())
        tracer.trace("No best match found");
      return null;
    }
View Full Code Here

      IFile moduleFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(extractionSourcePath);

      createResourceMarkers(moduleFile, diagnostic);

      // sync version and name project data
      Version version = null;
      ModuleName moduleName = null;
      if(metadata != null) {
        version = metadata.getVersion();
        moduleName = metadata.getName();
      }

      if(version == null)
        version = Version.fromString("0.0.0");

      if(moduleName != null) {
        if(!project.getName().toLowerCase().contains(moduleName.getName().toString().toLowerCase()))
          createWarningMarker(moduleFile, "Mismatched name - project does not reflect module: '" +
              moduleName + "'", null);
      }

      try {
        IProject p = getProject();
        String storedVersion = p.getPersistentProperty(PROJECT_PROPERTY_MODULEVERSION);
        String vstr = version.toString();
        if(!vstr.equals(storedVersion))
          p.setPersistentProperty(PROJECT_PROPERTY_MODULEVERSION, vstr);

        String storedName = p.getPersistentProperty(PROJECT_PROPERTY_MODULENAME);
        if(moduleName == null) {
View Full Code Here

      return null;

    VersionRange vr = d.getVersionRequirement();
    if(vr == null)
      vr = VersionRange.ALL_INCLUSIVE;
    Version best = vr.findBestMatch(candidates.values());
    return candidates.inverse().get(best);
  }
View Full Code Here

            Collection<MetadataInfo> candidates = moduleData.get(requiredName);
            List<Version> candidateVersions = Lists.newArrayList();
            List<MetadataInfo> unversioned = Lists.newArrayList();
            if(candidates != null)
              for(MetadataInfo mi : candidates) {
                Version cv = mi.getMetadata().getVersion();
                if(cv == null) {
                  unversioned.add(mi);
                  continue; // the (possibly) broken version
                        // is reported elsewhere
                }
                candidateVersions.add(cv);
              }

            // if the dependency has no version requirement use ">=0"
            final VersionRange versionRequirement = d.getVersionRequirement();
            if(versionRequirement == null) {
              // find best match for >= 0 if there are candidates with versions
              // the best will always win over unversioned.
              if(candidateVersions.size() > 0) {
                Collections.sort(candidateVersions);
                Version best = candidateVersions.get(candidateVersions.size() - 1);

                // get the matched MetaDataInfo as the resolution of the dependency
                // and remember it
                for(MetadataInfo mi : candidates) {
                  if(mi.getMetadata().getVersion().equals(best))
                    info.addResolvedDependency(d, mi);
                }

              }
              // or there must be unversioned candidates
              else if(unversioned.size() == 0)
                if(shouldDiagnosticBeReported)
                  addFileDiagnostic(
                    diagnostics, (candidates.size() > 0
                        ? Diagnostic.WARNING
                        : Diagnostic.ERROR), info.getFile(), root,
                    "Unresolved Dependency to: " + d.getName() + " (unversioned).",
                    IValidationConstants.ISSUE__MODULEFILE_UNSATISFIED_DEPENDENCY);
                else {
                  // pick the first as resolution
                  // worry about ambiguity elsewhere
                  info.addResolvedDependency(d, unversioned.get(0));
                }
            }
            else {
              // there was a version requirement, it must match something with a version.
              Version best = d.getVersionRequirement().findBestMatch(candidateVersions);
              if(best == null) {
                info.addUnresolvedDependency(d);
                if(shouldDiagnosticBeReported)
                  addFileDiagnostic(
                    diagnostics,
View Full Code Here

        addFileError(
          diagnostics, moduleFile, parentFile, "A name must be specified.",
          IValidationConstants.ISSUE__MODULEFILE_NO_NAME);

      // must have version
      Version version = metadata.getVersion();
      if(version == null)
        addFileWarning(
          diagnostics, moduleFile, parentFile, "A version should be specified.",
          IValidationConstants.ISSUE__MODULEFILE_NO_VERSION);
    }
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.semver.Version

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.