当前位置: 首页>>代码示例>>Java>>正文


Java ArtifactVersion.compareTo方法代码示例

本文整理汇总了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);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:DefaultPomDependenciesConverter.java

示例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();
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:20,代码来源:DisplayPluginUpdatesMojo.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:FixVersionConflictPanel.java

示例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;
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:19,代码来源:LibraryFile.java

示例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;
}
 
开发者ID:axonivy,项目名称:project-build-plugin,代码行数:30,代码来源:AbstractEngineMojo.java

示例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 );
}
 
开发者ID:mojohaus,项目名称:mrm,代码行数:10,代码来源:MemoryArtifactStore.java

示例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 );
}
 
开发者ID:mojohaus,项目名称:mrm,代码行数:11,代码来源:MockArtifactStore.java

示例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;

}
 
开发者ID:bsorrentino,项目名称:maven-confluence-plugin,代码行数:60,代码来源:VersionUtil.java

示例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 );
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:47,代码来源:PropertyVersions.java

示例10: compare

import org.apache.maven.artifact.versioning.ArtifactVersion; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public int compare( ArtifactVersion o1, ArtifactVersion o2 )
{
    return o1.compareTo( o2 );
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:8,代码来源:MavenVersionComparator.java

示例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" );
        }
    }
}
 
开发者ID:mojohaus,项目名称:build-helper-maven-plugin,代码行数:50,代码来源:ReleasedVersionMojo.java

示例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 );
}
 
开发者ID:petr-ujezdsky,项目名称:versions-maven-plugin-svn-clone,代码行数:47,代码来源:PropertyVersions.java


注:本文中的org.apache.maven.artifact.versioning.ArtifactVersion.compareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。