本文整理汇总了Java中org.apache.maven.artifact.versioning.ArtifactVersion.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java ArtifactVersion.compareTo方法的具体用法?Java ArtifactVersion.compareTo怎么用?Java ArtifactVersion.compareTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.artifact.versioning.ArtifactVersion
的用法示例。
在下文中一共展示了ArtifactVersion.compareTo方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareMavenVersionStrings
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
private int compareMavenVersionStrings(String dependencyVersionString, String duplicateVersionString) {
String dependencyVersion = emptyToNull(dependencyVersionString);
String duplicateVersion = emptyToNull(duplicateVersionString);
if (dependencyVersion == null && duplicateVersion == null) {
return 0;
}
if (dependencyVersion == null) {
return -1;
}
if (duplicateVersion == null) {
return 1;
}
ArtifactVersion dependencyArtifactVersion = new DefaultArtifactVersion(dependencyVersion);
ArtifactVersion duplicateArtifactVersion = new DefaultArtifactVersion(duplicateVersion);
return dependencyArtifactVersion.compareTo(duplicateArtifactVersion);
}
示例2: getRequiredMavenVersion
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
private String getRequiredMavenVersion( MavenProject mavenProject, String defaultValue )
{
ArtifactVersion requiredMavenVersion = null;
while ( mavenProject != null )
{
final Prerequisites prerequisites = mavenProject.getPrerequisites();
final String mavenVersion = prerequisites == null ? null : prerequisites.getMaven();
if ( mavenVersion != null )
{
final ArtifactVersion v = new DefaultArtifactVersion( mavenVersion );
if ( requiredMavenVersion == null || requiredMavenVersion.compareTo( v ) < 0 )
{
requiredMavenVersion = v;
}
}
mavenProject = mavenProject.getParent();
}
return requiredMavenVersion == null ? defaultValue : requiredMavenVersion.toString();
}
示例3: computeRecommendations
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
/** Checks the circumstances of version conflict and offers solution.
*
* @return description of found recommended solution
*/
private FixDescription computeRecommendations() {
FixDescription recs = new FixDescription();
boolean isDirect = conflictNode.getPrimaryLevel() == 1;
ArtifactVersion usedVersion = new DefaultArtifactVersion(
conflictNode.getImpl().getArtifact().getVersion());
ArtifactVersion newAvailVersion = getClashingVersions().get(0);
// case: direct dependency to older version -> recommend update to newer
if (isDirect && usedVersion.compareTo(newAvailVersion) < 0) {
recs.isSet = true;
recs.version2Set = newAvailVersion;
}
// case: more then one exclusion target, several of them are "good guys"
// which means they have non conflicting dependency on newer version ->
// recommend adding dependency exclusion to all but mentioned "good" targets
Set<Artifact> nonConf = eTargets.getNonConflicting();
if (!nonConf.isEmpty() && eTargets.getAll().size() > 1) {
recs.isExclude = true;
recs.exclusionTargets = eTargets.getConflicting();
}
// last try - brute force -> recommend exclude all and add dependency in some cases
if (!recs.isSet && !recs.isExclude) {
if (usedVersion.compareTo(newAvailVersion) < 0) {
recs.isSet = true;
recs.version2Set = newAvailVersion;
recs.isExclude = true;
recs.exclusionTargets = eTargets.getAll();
}
}
return recs;
}
示例4: updateVersion
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
/**
* Check Maven Central to find the latest release version of this artifact.
* This check is made at most once. Subsequent checks are no-ops.
*/
void updateVersion() {
if (!fixedVersion && !isPinned()) {
ArtifactVersion remoteVersion = ArtifactRetriever.DEFAULT.getBestVersion(
mavenCoordinates.getGroupId(), mavenCoordinates.getArtifactId());
if (remoteVersion != null) {
DefaultArtifactVersion localVersion = new DefaultArtifactVersion(mavenCoordinates.getVersion());
if (remoteVersion.compareTo(localVersion) > 0) {
String updatedVersion = remoteVersion.toString();
mavenCoordinates = mavenCoordinates.toBuilder().setVersion(updatedVersion).build();
}
}
fixedVersion = true;
}
}
示例5: findMatchingEngineInCacheDirectory
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
protected final File findMatchingEngineInCacheDirectory() throws MojoExecutionException
{
if (engineCacheDirectory == null || !engineCacheDirectory.exists())
{
return null;
}
File engineDirToTake = null;
ArtifactVersion versionOfEngineToTake = null;
for (File engineDirCandidate : engineCacheDirectory.listFiles())
{
if (!engineDirCandidate.isDirectory())
{
continue;
}
ArtifactVersion candidateVersion = getInstalledEngineVersion(engineDirCandidate);
if (candidateVersion == null || !getIvyVersionRange().containsVersion(candidateVersion))
{
continue;
}
if (versionOfEngineToTake == null || versionOfEngineToTake.compareTo(candidateVersion) < 0)
{
engineDirToTake = engineDirCandidate;
versionOfEngineToTake = candidateVersion;
}
}
return engineDirToTake;
}
示例6: compare
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public int compare( String o1, String o2 )
{
ArtifactVersion v1 = new DefaultArtifactVersion( o1 );
ArtifactVersion v2 = new DefaultArtifactVersion( o2 );
return v1.compareTo( v2 );
}
示例7: compare
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings( "unchecked" )
public int compare( String o1, String o2 )
{
ArtifactVersion v1 = new DefaultArtifactVersion( o1 );
ArtifactVersion v2 = new DefaultArtifactVersion( o2 );
return v1.compareTo( v2 );
}
示例8: sortAndFilter
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
public static LinkedList<String> sortAndFilter(Collection<String> versionNameList,
String start,
String end) {
final ArtifactVersion startVersion = parseArtifactVersion(start);
final ArtifactVersion endVersion;
if (end != null && !end.isEmpty()) {
endVersion = parseArtifactVersion(end);
} else {
endVersion = null;
}
if (endVersion!=null && startVersion.compareTo(endVersion) > 0) {
throw new IllegalArgumentException(
String.format("startVersion %s must be less or equals to endVersion %s",
startVersion, endVersion));
}
LinkedList<String> linkedList = new LinkedList<String>();
Map<ArtifactVersion, String> map = new HashMap<ArtifactVersion, String>();
for (String versionTag : versionNameList) {
map.put(parseArtifactVersion(versionTag), versionTag);
}
List<ArtifactVersion> artifactVersionSet = new ArrayList<ArtifactVersion>(map.keySet());
CollectionUtils.filter(artifactVersionSet, new Predicate() {
@Override
public boolean evaluate(Object o) {
ArtifactVersion current = (ArtifactVersion) o;
if (endVersion != null) {
if (startVersion.compareTo(current) <= 0
&&
endVersion.compareTo(current) >= 0) {
return true;
}
} else {
if (startVersion.compareTo(current) <= 0) {
return true;
}
}
return false;
}
});
Collections.sort(artifactVersionSet);
for (ArtifactVersion artifactVersion : artifactVersionSet) {
linkedList.add(map.get(artifactVersion));
}
return linkedList;
}
示例9: resolveAssociatedVersions
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
private static SortedSet<ArtifactVersion> resolveAssociatedVersions( VersionsHelper helper,
Set<ArtifactAssociation> associations,
VersionComparator versionComparator )
throws ArtifactMetadataRetrievalException
{
SortedSet<ArtifactVersion> versions = null;
for ( ArtifactAssociation association : associations )
{
final ArtifactVersions associatedVersions =
helper.lookupArtifactVersions( association.getArtifact(), association.isUsePluginRepositories() );
if ( versions != null )
{
final ArtifactVersion[] artifactVersions = associatedVersions.getVersions( true );
// since ArtifactVersion does not override equals, we have to do this the hard way
// result.retainAll( Arrays.asList( artifactVersions ) );
Iterator j = versions.iterator();
while ( j.hasNext() )
{
boolean contains = false;
ArtifactVersion version = (ArtifactVersion) j.next();
for ( ArtifactVersion artifactVersion : artifactVersions )
{
if ( version.compareTo( artifactVersion ) == 0 )
{
contains = true;
break;
}
}
if ( !contains )
{
j.remove();
}
}
}
else
{
versions = new TreeSet<>( versionComparator );
versions.addAll( Arrays.asList( associatedVersions.getVersions( true ) ) );
}
}
if ( versions == null )
{
versions = new TreeSet<>( versionComparator );
}
return Collections.unmodifiableSortedSet( versions );
}
示例10: compare
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public int compare( ArtifactVersion o1, ArtifactVersion o2 )
{
return o1.compareTo( o2 );
}
示例11: execute
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
@SuppressWarnings( "unchecked" )
public void execute()
{
org.apache.maven.artifact.Artifact artifact =
artifactFactory.createArtifact( getProject().getGroupId(), getProject().getArtifactId(), "", "", "" );
try
{
ArtifactVersion releasedVersion = null;
List<ArtifactVersion> versions =
artifactMetadataSource.retrieveAvailableVersions( artifact, localRepository,
remoteArtifactRepositories );
for ( ArtifactVersion version : versions )
{
if ( !ArtifactUtils.isSnapshot( version.toString() )
&& ( releasedVersion == null || version.compareTo( releasedVersion ) > 0 ) )
{
releasedVersion = version;
}
}
if ( releasedVersion != null )
{
// Use ArtifactVersion.toString(), the major, minor and incrementalVersion return all an int.
String releasedVersionValue = releasedVersion.toString();
// This would not always reflect the expected version.
int dashIndex = releasedVersionValue.indexOf( '-' );
if ( dashIndex >= 0 )
{
releasedVersionValue = releasedVersionValue.substring( 0, dashIndex );
}
defineVersionProperty( "version", releasedVersionValue );
defineVersionProperty( "majorVersion", releasedVersion.getMajorVersion() );
defineVersionProperty( "minorVersion", releasedVersion.getMinorVersion() );
defineVersionProperty( "incrementalVersion", releasedVersion.getIncrementalVersion() );
defineVersionProperty( "buildNumber", releasedVersion.getBuildNumber() );
defineVersionProperty( "qualifier", releasedVersion.getQualifier() );
}
}
catch ( ArtifactMetadataRetrievalException e )
{
if ( getLog().isWarnEnabled() )
{
getLog().warn( "Failed to retrieve artifacts metadata, cannot resolve the released version" );
}
}
}
示例12: resolveAssociatedVersions
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
private static SortedSet<ArtifactVersion> resolveAssociatedVersions( VersionsHelper helper,
Set<ArtifactAssociation> associations,
VersionComparator versionComparator )
throws ArtifactMetadataRetrievalException
{
SortedSet<ArtifactVersion> versions = null;
for ( ArtifactAssociation association : associations )
{
final ArtifactVersions associatedVersions =
helper.lookupArtifactVersions( association.getArtifact(), association.isUsePluginRepositories() );
if ( versions != null )
{
final ArtifactVersion[] artifactVersions = associatedVersions.getVersions( true );
// since ArtifactVersion does not override equals, we have to do this the hard way
// result.retainAll( Arrays.asList( artifactVersions ) );
Iterator j = versions.iterator();
while ( j.hasNext() )
{
boolean contains = false;
ArtifactVersion version = (ArtifactVersion) j.next();
for ( ArtifactVersion artifactVersion : artifactVersions )
{
if ( version.compareTo( artifactVersion ) == 0 )
{
contains = true;
break;
}
}
if ( !contains )
{
j.remove();
}
}
}
else
{
versions = new TreeSet<ArtifactVersion>( versionComparator );
versions.addAll( Arrays.asList( associatedVersions.getVersions( true ) ) );
}
}
if ( versions == null )
{
versions = new TreeSet<ArtifactVersion>( versionComparator );
}
return Collections.unmodifiableSortedSet( versions );
}