org.apache.maven.artifact.repository.metadata.Versioning.getLatest()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中org.apache.maven.artifact.repository.metadata.Versioning.getLatest()方法的一些代码示例,展示了Versioning.getLatest()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Versioning.getLatest()方法的具体详情如下:
包路径:org.apache.maven.artifact.repository.metadata.Versioning
类名称:Versioning
方法名:getLatest

Versioning.getLatest介绍

[英]Get what the latest version in the directory is, including snapshots.
[中]获取目录中的最新版本,包括快照。

代码示例

代码示例来源:origin: apache/maven

protected String constructVersion( Versioning versioning, String baseVersion )
  {
    return versioning.getLatest();
  }
}

代码示例来源:origin: apache/maven

private void mergeMetadata( Versions versions, Metadata source, ArtifactRepository repository )
{
  Versioning versioning = source.getVersioning();
  if ( versioning != null )
  {
    String timestamp = StringUtils.clean( versioning.getLastUpdated() );
    if ( StringUtils.isNotEmpty( versioning.getRelease() )
      && timestamp.compareTo( versions.releaseTimestamp ) > 0 )
    {
      versions.releaseVersion = versioning.getRelease();
      versions.releaseTimestamp = timestamp;
      versions.releaseRepository = repository;
    }
    if ( StringUtils.isNotEmpty( versioning.getLatest() )
      && timestamp.compareTo( versions.latestTimestamp ) > 0 )
    {
      versions.latestVersion = versioning.getLatest();
      versions.latestTimestamp = timestamp;
      versions.latestRepository = repository;
    }
    for ( String version : versioning.getVersions() )
    {
      if ( !versions.versions.containsKey( version ) )
      {
        versions.versions.put( version, repository );
      }
    }
  }
}

代码示例来源:origin: apache/maven

@Override
protected void merge( Metadata recessive )
{
  Versioning versioning = metadata.getVersioning();
  versioning.updateTimestamp();
  if ( recessive.getVersioning() != null )
  {
    if ( versioning.getLatest() == null )
    {
      versioning.setLatest( recessive.getVersioning().getLatest() );
    }
    if ( versioning.getRelease() == null )
    {
      versioning.setRelease( recessive.getVersioning().getRelease() );
    }
    Collection<String> versions = new LinkedHashSet<>( recessive.getVersioning().getVersions() );
    versions.addAll( versioning.getVersions() );
    versioning.setVersions( new ArrayList<>( versions ) );
  }
}

代码示例来源:origin: apache/maven

if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
  merge( LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository );

代码示例来源:origin: apache/maven

if ( versioning.getLatest() != null )
  serializer.startTag( NAMESPACE, "latest" ).text( versioning.getLatest() ).endTag( NAMESPACE, "latest" );

代码示例来源:origin: apache/maven

v.setRelease( versioning.getRelease() );
if ( versioning.getLatest() != null )
  v.setLatest( versioning.getLatest() );

代码示例来源:origin: com.cloudbees/bees-maven-components

/**
 * List up all the versions found in the metadata.
 */
private void merge(Versioning versioning, ArtifactRepository from, List<VersionInfo> found) {
  if ( StringUtils.isNotEmpty( versioning.getRelease() ) )
    found.add(new VersionInfo(versioning.getRelease(),from));
  if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
    found.add(new VersionInfo(versioning.getLatest(),from));
  for ( String v : versioning.getVersions() )
    found.add(new VersionInfo(v,from));
}

代码示例来源:origin: org.sonatype.nexus.plugins/nexus-repository-maven

private boolean versioningEquals(@Nullable final Versioning v1,
                 @Nullable final Versioning v2) { // NOSONAR
 if (v1 == null || v2 == null) {
  return v1 == v2; // NOSONAR
 }
 else {
  return
   Objects.equals(v1.getLatest(), v2.getLatest()) && // NOSONAR
   Objects.equals(v1.getRelease(), v2.getRelease()) &&
   snapshotEquals(v1.getSnapshot(), v2.getSnapshot()) &&
   Objects.equals(v1.getVersions(), v2.getVersions()) &&
   snapshotVersionsEquals(v1.getSnapshotVersions(), v2.getSnapshotVersions());
 }
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher

public static void assertEquals(Metadata m1, Metadata m2) {
 assertThat(m1, is(notNullValue()));
 assertThat(m2, is(notNullValue()));
 assertThat(m1.getArtifactId(), equalTo(m2.getArtifactId()));
 assertThat(m1.getGroupId(), equalTo(m2.getGroupId()));
 assertThat(m1.getVersion(), equalTo(m2.getVersion()));
 assertThat(m1.getVersioning(), is(notNullValue()));
 assertThat(m2.getVersioning(), is(notNullValue()));
 assertThat(m1.getVersioning().getLatest(), equalTo(m2.getVersioning().getLatest()));
 assertThat(m1.getVersioning().getRelease(), equalTo(m2.getVersioning().getRelease()));
 if (m1.getVersioning().getSnapshot() != null || m1.getVersioning().getSnapshot() != null) {
  assertThat(m1.getVersioning().getSnapshot().getBuildNumber(),
    equalTo(m2.getVersioning().getSnapshot().getBuildNumber()));
  assertThat(m1.getVersioning().getSnapshot().getTimestamp(),
    equalTo(m2.getVersioning().getSnapshot().getTimestamp()));
 }
 assertThat(m1.getVersioning().getSnapshotVersions().size(), equalTo(
   m2.getVersioning().getSnapshotVersions().size()));
 for (int i = 0; i < m1.getVersioning().getSnapshotVersions().size(); i++) {
  SnapshotVersion s1 = m1.getVersioning().getSnapshotVersions().get(i);
  SnapshotVersion s2 = get(s1, m2.getVersioning().getSnapshotVersions());
  assertThat(s1, is(notNullValue()));
  assertThat(s2, is(notNullValue()));
  assertThat(s1.getClassifier(), equalTo(s2.getClassifier()));
  assertThat(s1.getExtension(), equalTo(s2.getExtension()));
  assertThat(s1.getUpdated(), equalTo(s2.getUpdated()));
  assertThat(s1.getVersion(), equalTo(s2.getVersion()));
 }
}

代码示例来源:origin: org.sonatype.nexus/nexus-test-utils

assertThat( m2.getVersioning(), is( notNullValue() ) );
assertThat( m1.getVersioning().getLatest(), equalTo( m2.getVersioning().getLatest() ) );
assertThat( m1.getVersioning().getRelease(), equalTo( m2.getVersioning().getRelease() ) );

代码示例来源:origin: org.apache.maven/maven-aether-provider

@Override
protected void merge( Metadata recessive )
{
  Versioning versioning = metadata.getVersioning();
  versioning.updateTimestamp();
  if ( recessive.getVersioning() != null )
  {
    if ( versioning.getLatest() == null )
    {
      versioning.setLatest( recessive.getVersioning().getLatest() );
    }
    if ( versioning.getRelease() == null )
    {
      versioning.setRelease( recessive.getVersioning().getRelease() );
    }
    Collection<String> versions = new LinkedHashSet<>( recessive.getVersioning().getVersions() );
    versions.addAll( versioning.getVersions() );
    versioning.setVersions( new ArrayList<>( versions ) );
  }
}

代码示例来源:origin: io.tesla.maven/maven-aether-provider

@Override
protected void merge( Metadata recessive )
{
  Versioning versioning = metadata.getVersioning();
  versioning.updateTimestamp();
  if ( recessive.getVersioning() != null )
  {
    if ( versioning.getLatest() == null )
    {
      versioning.setLatest( recessive.getVersioning().getLatest() );
    }
    if ( versioning.getRelease() == null )
    {
      versioning.setRelease( recessive.getVersioning().getRelease() );
    }
    Collection<String> versions = new LinkedHashSet<String>( recessive.getVersioning().getVersions() );
    versions.addAll( versioning.getVersions() );
    versioning.setVersions( new ArrayList<String>( versions ) );
  }
}

代码示例来源:origin: org.apache.maven/maven-resolver-provider

@Override
protected void merge( Metadata recessive )
{
  Versioning versioning = metadata.getVersioning();
  versioning.updateTimestamp();
  if ( recessive.getVersioning() != null )
  {
    if ( versioning.getLatest() == null )
    {
      versioning.setLatest( recessive.getVersioning().getLatest() );
    }
    if ( versioning.getRelease() == null )
    {
      versioning.setRelease( recessive.getVersioning().getRelease() );
    }
    Collection<String> versions = new LinkedHashSet<>( recessive.getVersioning().getVersions() );
    versions.addAll( versioning.getVersions() );
    versioning.setVersions( new ArrayList<>( versions ) );
  }
}

代码示例来源:origin: org.sonatype.nexus/nexus-proxy

protected Metadata cleanseMetadataForRepository( boolean snapshot, Metadata metadata )
{
  // remove base versions not belonging here
  List<String> versions = metadata.getVersioning().getVersions();
  for ( Iterator<String> iversion = versions.iterator(); iversion.hasNext(); )
  {
    // if we need snapshots and the version is not snapshot, or
    // if we need releases and the version is snapshot
    if ( ( snapshot && !Gav.isSnapshot( iversion.next() ) )
      || ( !snapshot && Gav.isSnapshot( iversion.next() ) ) )
    {
      iversion.remove();
    }
  }
  metadata.getVersioning().setLatest( getLatestVersion( metadata.getVersioning().getVersions() ) );
  if ( snapshot )
  {
    metadata.getVersioning().setRelease( null );
  }
  else
  {
    metadata.getVersioning().setRelease( metadata.getVersioning().getLatest() );
  }
  return metadata;
}

代码示例来源:origin: org.apache.maven/maven-aether-provider

if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
  merge( LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository );

代码示例来源:origin: io.tesla.maven/maven-aether-provider

if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
  merge( LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository );

代码示例来源:origin: com.atlassian.sdk/ap3-aether-maven-provider

if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
  merge( LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository );

代码示例来源:origin: org.apache.maven/maven-resolver-provider

if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
  merge( LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository );

代码示例来源:origin: org.sonatype.nexus/nexus-proxy

@Override
protected boolean isMetadataCorrect( Metadata oldMd, String path )
  throws IOException
{
  Metadata md = createMetadata( path );
  if ( oldMd.getVersioning().getRelease() == null )
  {
    oldMd.getVersioning().setRelease( "" );
  }
  if ( md.getVersioning().getRelease() == null )
  {
    md.getVersioning().setRelease( "" );
  }
  if ( oldMd.getVersioning().getLatest() == null )
  {
    return false;
  }
  if ( oldMd.getVersioning().getVersions() == null )
  {
    return false;
  }
  if ( oldMd.getArtifactId().equals( md.getArtifactId() ) && oldMd.getGroupId().equals( md.getGroupId() )
    && oldMd.getVersioning().getLatest().equals( md.getVersioning().getLatest() )
    && oldMd.getVersioning().getRelease().equals( md.getVersioning().getRelease() )
    && oldMd.getVersioning().getVersions().equals( md.getVersioning().getVersions() ) )
  {
    return true;
  }
  return false;
}

代码示例来源:origin: portofrotterdam/versiondebt-plugin

private String retrieveLatestReleasedVersion(final Artifact artifact) {
  final RepositoryMetadata metadata = new ArtifactRepositoryMetadata(artifact);
  try {
    repositoryMetadataManager.resolve(metadata, currentProject.getRemoteArtifactRepositories(), localRepository);
  } catch (final RepositoryMetadataResolutionException e1) {
    e1.printStackTrace();
  }
  final Metadata repoMetadata = metadata.getMetadata();
  if (repoMetadata.getVersioning() != null) {
    final String releasedVersion = repoMetadata.getVersioning().getRelease();
    if (releasedVersion != null) {
      return releasedVersion;
    }
    final String latestVersion = repoMetadata.getVersioning().getLatest();
    if (latestVersion != null) {
      return latestVersion;
    }
  }
  return repoMetadata.getVersion();
}

相关文章