List of usage examples for org.apache.maven.artifact.versioning VersionRange hasRestrictions
public boolean hasRestrictions()
From source file:ch.ivyteam.ivy.maven.AbstractEngineMojo.java
License:Apache License
protected final VersionRange getIvyVersionRange() throws MojoExecutionException { try {//from w w w .ja v a2 s . com VersionRange minimalCompatibleVersionRange = VersionRange .createFromVersionSpec("[" + AbstractEngineMojo.MINIMAL_COMPATIBLE_VERSION + ",)"); VersionRange ivyVersionRange = VersionRange.createFromVersionSpec(ivyVersion); if (ivyVersionRange.getRecommendedVersion() != null) { ivyVersionRange = VersionRange.createFromVersionSpec("[" + ivyVersion + "]"); } VersionRange restrictedIvyVersionRange = ivyVersionRange.restrict(minimalCompatibleVersionRange); if (!restrictedIvyVersionRange.hasRestrictions()) { throw new MojoExecutionException( "The ivyVersion '" + ivyVersion + "' is lower than the minimal compatible version" + " '" + MINIMAL_COMPATIBLE_VERSION + "'."); } return restrictedIvyVersionRange; } catch (InvalidVersionSpecificationException ex) { throw new MojoExecutionException("Invalid ivyVersion '" + ivyVersion + "'.", ex); } }
From source file:net.oneandone.pommes.model.Database.java
License:Apache License
public static Document document(String origin, MavenProject mavenProject) throws InvalidVersionSpecificationException { Document doc;/*from ww w . ja v a 2s .com*/ MavenProject parent; Pom parPom; doc = document(origin, Pom.forProject(origin, mavenProject)); for (Dependency dependency : mavenProject.getDependencies()) { GAV dep = GAV.forDependency(dependency); // index groupId:artifactId for non-version searches doc.add(new StringField(DEP_GA, dep.toGaString(), Field.Store.YES)); // index groupId:artifactId:version for exact-version searches doc.add(new StringField(DEP_GAV, dep.toGavString(), Field.Store.YES)); // index groupId:artifactId for searches that need to evaluate the range VersionRange vr = VersionRange.createFromVersionSpec(dependency.getVersion()); if (vr.hasRestrictions()) { doc.add(new StringField(DEP_GA_RANGE, dep.toGaString(), Field.Store.YES)); } } // parent parent = mavenProject.getParent(); if (parent != null) { parPom = Pom.forProject(origin, parent); doc.add(new StringField(PAR_GA, parPom.coordinates.toGaString(), Field.Store.YES)); doc.add(new StringField(PAR_GAV, parPom.coordinates.toGavString(), Field.Store.YES)); } return doc; }
From source file:org.axway.grapes.maven.resolver.ArtifactResolver.java
/** * Finds a version out of a range/* w w w . j a va2s .c o m*/ * * @param range VersionRange * @return String */ public static String getArtifactVersion(final VersionRange range) { if (range.getRecommendedVersion() != null) { return range.getRecommendedVersion().toString(); } if (range.hasRestrictions()) { for (Restriction restriction : range.getRestrictions()) { if (restriction.getLowerBound() != null) { return restriction.getLowerBound().toString(); } if (restriction.getUpperBound() != null) { return restriction.getLowerBound().toString(); } } } return range.toString(); }
From source file:org.codehaus.mojo.versions.api.PomHelper.java
License:Apache License
/** * Checks if two versions or ranges have an overlap. * * @param leftVersionOrRange the 1st version number or range to test * @param rightVersionOrRange the 2nd version number or range to test * @return true if both versions have an overlap * @throws InvalidVersionSpecificationException * if the versions can't be parsed to a range *///from w w w .j a v a 2 s . c om public static boolean isVersionOverlap(String leftVersionOrRange, String rightVersionOrRange) throws InvalidVersionSpecificationException { VersionRange pomVersionRange = createVersionRange(leftVersionOrRange); if (!pomVersionRange.hasRestrictions()) { return true; } VersionRange oldVersionRange = createVersionRange(rightVersionOrRange); if (!oldVersionRange.hasRestrictions()) { return true; } VersionRange result = oldVersionRange.restrict(pomVersionRange); return result.hasRestrictions(); }