import org.apache.maven.artifact.versioning.DefaultArtifactVersion; DefaultArtifactVersion minVersion = new DefaultArtifactVersion("1.0.1"); DefaultArtifactVersion maxVersion = new DefaultArtifactVersion("1.10"); DefaultArtifactVersion version = new DefaultArtifactVersion("1.11"); if (version.compareTo(minVersion) < 0 || version.compareTo(maxVersion) > 0) { System.out.println("Sorry, your version is unsupported"); }
private VersionMatcher( String version ) { this.version = new DefaultArtifactVersion( version ); }
@Override public int compare(String o1, String o2) { //noinspection StringEquality if (o1 == o2) { return 0; } if (o1 == null) { return -1; } if (o2 == null) { return 1; } DefaultArtifactVersion version1 = new DefaultArtifactVersion(o1); DefaultArtifactVersion version2 = new DefaultArtifactVersion(o2); return version1.compareTo(version2); }
public static VersionRange createFromVersion( String version ) { List<Restriction> restrictions = Collections.emptyList(); return new VersionRange( new DefaultArtifactVersion( version ), restrictions ); }
public static VersionRange createFromVersion( String version ) { List<Restriction> restrictions = Collections.emptyList(); return new VersionRange( new DefaultArtifactVersion( version ), restrictions ); }
public int compareTo( ArtifactVersion otherVersion ) { if ( otherVersion instanceof DefaultArtifactVersion ) { return this.comparable.compareTo( ( (DefaultArtifactVersion) otherVersion ).comparable ); } else { return compareTo( new DefaultArtifactVersion( otherVersion.toString() ) ); } }
public void initialize() throws InitializationException { String mavenVersion = rtInfo.getMavenVersion(); if ( StringUtils.isEmpty( mavenVersion ) ) { throw new InitializationException( "Unable to read Maven version from maven-core" ); } applicationVersion = new DefaultArtifactVersion( mavenVersion ); }
public int compareTo( ArtifactVersion otherVersion ) { if ( otherVersion instanceof DefaultArtifactVersion ) { return this.comparable.compareTo( ( (DefaultArtifactVersion) otherVersion ).comparable ); } else { return compareTo( new DefaultArtifactVersion( otherVersion.toString() ) ); } }
private List<ArtifactVersion> retrieveAvailableVersionsFromMetadata( Metadata repoMetadata, List<String> availableVersions ) { Collection<String> versions = new LinkedHashSet<>(); if ( ( repoMetadata != null ) && ( repoMetadata.getVersioning() != null ) ) { versions.addAll( repoMetadata.getVersioning().getVersions() ); } versions.addAll( availableVersions ); List<ArtifactVersion> artifactVersions = new ArrayList<>( versions.size() ); for ( String version : versions ) { artifactVersions.add( new DefaultArtifactVersion( version ) ); } return artifactVersions; }
String version = existing.get( 0 ).split( "(" + artifact.getArtifactId() + "-)" )[1].split( "(.jar)" )[0]; DefaultArtifactVersion existingVersion = new DefaultArtifactVersion( version ); DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion( artifact.getVersion() );
ArtifactVersion version = new DefaultArtifactVersion( process ); if ( lowerBound.length() > 0 ) lowerVersion = new DefaultArtifactVersion( lowerBound ); upperVersion = new DefaultArtifactVersion( upperBound );
result = new DefaultArtifactVersion( version ).compareTo( new DefaultArtifactVersion( a.getVersion() ) );
result = new DefaultArtifactVersion( version ).compareTo( new DefaultArtifactVersion( a.getVersion() ) );
ArtifactVersion version = new DefaultArtifactVersion( process ); if ( lowerBound.length() > 0 ) lowerVersion = new DefaultArtifactVersion( lowerBound ); upperVersion = new DefaultArtifactVersion( upperBound );
public MetadataGraphEdge apply( MetadataGraphEdge e1, MetadataGraphEdge e2 ) { int depth1 = e1.getDepth(); int depth2 = e2.getDepth(); if ( depth1 == depth2 ) { ArtifactVersion v1 = new DefaultArtifactVersion( e1.getVersion() ); ArtifactVersion v2 = new DefaultArtifactVersion( e2.getVersion() ); if ( newerFirst ) { return v1.compareTo( v2 ) > 0 ? e1 : e2; } return v1.compareTo( v2 ) > 0 ? e2 : e1; } if ( closerFirst ) { return depth1 < depth2 ? e1 : e2; } return depth1 < depth2 ? e2 : e1; }
versions.add( new DefaultArtifactVersion( version ) );
version = new DefaultArtifactVersion( process ); restrictions.add( Restriction.EVERYTHING );
private boolean matchJdkVersionRange( String jdk ) throws InvalidVersionSpecificationException { VersionRange jdkVersionRange = VersionRange.createFromVersionSpec( convertJdkToMavenVersion( jdk ) ); DefaultArtifactVersion jdkVersion = new DefaultArtifactVersion( convertJdkToMavenVersion( getJdkVersion() ) ); return jdkVersionRange.containsVersion( jdkVersion ); }
version = new DefaultArtifactVersion( process ); restrictions.add( Restriction.EVERYTHING );
private boolean matchJdkVersionRange( String jdk ) throws InvalidVersionSpecificationException { VersionRange jdkVersionRange = VersionRange.createFromVersionSpec( convertJdkToMavenVersion( jdk ) ); DefaultArtifactVersion jdkVersion = new DefaultArtifactVersion( convertJdkToMavenVersion( getJdkVersion() ) ); return jdkVersionRange.containsVersion( jdkVersion ); }