org.apache.maven.artifact.repository.metadata.Versioning类的使用及代码示例

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

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

Versioning介绍

[英]Versioning information for an artifact (un-versioned or snapshot).
[中]工件的版本控制信息(未版本化或快照)。

代码示例

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

v = new Versioning();
for ( String version : versioning.getVersions() )
  if ( !v.getVersions().contains( version ) )
    v.getVersions().add( version );
if ( "null".equals( versioning.getLastUpdated() ) )
  versioning.setLastUpdated( null );
if ( "null".equals( v.getLastUpdated() ) )
  v.setLastUpdated( null );
if ( versioning.getLastUpdated() == null || versioning.getLastUpdated().length() == 0 )
  versioning.setLastUpdated( v.getLastUpdated() );
if ( v.getLastUpdated() == null || v.getLastUpdated().length() == 0
   || versioning.getLastUpdated().compareTo( v.getLastUpdated() ) >= 0 )
  v.setLastUpdated( versioning.getLastUpdated() );
  if ( versioning.getRelease() != null )
    v.setRelease( versioning.getRelease() );

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

String lastUpdated;
if ( metadata.getVersioning() == null )
  utcDateFormatter.setTimeZone( DEFAULT_SNAPSHOT_TIME_ZONE );
  snapshot = new Snapshot();
  snapshot.setBuildNumber( getBuildNumber( recessive ) + 1 );
  snapshot.setTimestamp( utcDateFormatter.format( new Date() ) );
  Versioning versioning = new Versioning();
  versioning.setSnapshot( snapshot );
  versioning.setLastUpdated( snapshot.getTimestamp().replace( ".", "" ) );
  lastUpdated = versioning.getLastUpdated();
  metadata.setVersioning( versioning );
  snapshot = metadata.getVersioning().getSnapshot();
  lastUpdated = metadata.getVersioning().getLastUpdated();
if ( versioning != null )
  for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
  metadata.getVersioning().setSnapshotVersions( new ArrayList<>( versions.values() ) );

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

protected static Versioning createVersioning( Snapshot snapshot )
{
  Versioning versioning = new Versioning();
  versioning.setSnapshot( snapshot );
  versioning.updateTimestamp();
  return versioning;
}

代码示例来源: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

private ArtifactMetadata createMetadata( Artifact artifact )
{
  Versioning versioning = new Versioning();
  versioning.updateTimestamp();
  versioning.addVersion( artifact.getVersion() );
  if ( artifact.isRelease() )
  {
    versioning.setRelease( artifact.getVersion() );
  }
  return new ArtifactRepositoryMetadata( artifact, versioning );
}

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

versioning = new MetadataXpp3Reader().read( in, false ).getVersioning();
               && versioning.getSnapshot() != null
               && versioning.getSnapshot().getBuildNumber() > 0 )
            final Versioning repaired = new Versioning();
            repaired.setLastUpdated( versioning.getLastUpdated() );
            repaired.setSnapshot( new Snapshot() );
            repaired.getSnapshot().setLocalCopy( true );
            versioning = repaired;
            throw new IOException( "Snapshot information corrupted with remote repository data"
return ( versioning != null ) ? versioning : new Versioning();

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

private static Metadata createMetadata( Artifact artifact, boolean legacyFormat )
{
  Snapshot snapshot = new Snapshot();
  snapshot.setLocalCopy( true );
  Versioning versioning = new Versioning();
  versioning.setSnapshot( snapshot );
  Metadata metadata = new Metadata();
  metadata.setVersioning( versioning );
  metadata.setGroupId( artifact.getGroupId() );
  metadata.setArtifactId( artifact.getArtifactId() );
  metadata.setVersion( artifact.getBaseVersion() );
  if ( !legacyFormat )
  {
    metadata.setModelVersion( "1.1.0" );
  }
  return metadata;
}

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

final Metadata result = new Metadata();
result.setModelVersion("1.1.0");
result.setGroupId(maven2Metadata.getGroupId());
result.setArtifactId(maven2Metadata.getArtifactId());
result.setVersion(maven2Metadata.getVersion());
 final Versioning versioning = new Versioning();
 versioning.setLatest(maven2Metadata.getBaseVersions().getLatest());
 versioning.setRelease(maven2Metadata.getBaseVersions().getRelease());
 versioning.setVersions(maven2Metadata.getBaseVersions().getVersions());
 versioning.setLastUpdated(Constants.METADATA_DOTLESS_TIMESTAMP.print(maven2Metadata.getLastUpdated()));
 result.setVersioning(versioning);
 final Versioning versioning = result.getVersioning() != null ? result.getVersioning() : new Versioning();
 final org.apache.maven.artifact.repository.metadata.Snapshot snapshot = new org.apache.maven.artifact.repository.metadata.Snapshot();
 snapshot.setTimestamp(Constants.METADATA_DOTTED_TIMESTAMP.print(
   new DateTime(maven2Metadata.getSnapshots().getSnapshotTimestamp())));
 snapshot.setBuildNumber(maven2Metadata.getSnapshots().getSnapshotBuildNumber());
 versioning.setSnapshot(snapshot);
  snapshotVersions.add(snapshotVersion);
 versioning.setSnapshotVersions(snapshotVersions);
 versioning.setLastUpdated(Constants.METADATA_DOTLESS_TIMESTAMP.print(maven2Metadata.getLastUpdated()));
 result.setVersioning(versioning);

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

private void merge( Artifact artifact, Map<String, VersionInfo> infos, Versioning versioning,
          ArtifactRepository repository )
  if ( StringUtils.isNotEmpty( versioning.getRelease() ) )
    merge( RELEASE, infos, versioning.getLastUpdated(), versioning.getRelease(), repository );
  if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
    merge( LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository );
  for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
  Snapshot snapshot = versioning.getSnapshot();
  if ( snapshot != null && versioning.getSnapshotVersions().isEmpty() )
    if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 )
      String qualifier = snapshot.getTimestamp() + '-' + snapshot.getBuildNumber();
      version = version.substring( 0, version.length() - SNAPSHOT.length() ) + qualifier;
    merge( SNAPSHOT, infos, versioning.getLastUpdated(), version, repository );

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

Metadata metadata = new Metadata();
metadata.setGroupId(artifact.getGroupId());
metadata.setArtifactId(artifact.getArtifactId());
metadata.setVersion(artifact.getVersion());
metadata.setModelVersion("1.1.0");
Versioning versioning = new Versioning();
versioning.setLastUpdatedTimestamp(new Date(System.currentTimeMillis()));
Snapshot snapshot = new Snapshot();
snapshot.setLocalCopy(true);
versioning.setSnapshot(snapshot);
SnapshotVersion snapshotVersion = new SnapshotVersion();
snapshotVersion.setClassifier(artifact.getClassifier());
snapshotVersion.setVersion(artifact.getVersion());
snapshotVersion.setExtension(artifact.getType());
snapshotVersion.setUpdated(versioning.getLastUpdated());
versioning.addSnapshotVersion(snapshotVersion);
metadata.setVersioning(versioning);

代码示例来源: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: io.fabric8/fabric-maven-proxy

request.setFavorLocalRepository(true);
requests.add(request);
org.apache.maven.artifact.repository.metadata.Metadata mr = new org.apache.maven.artifact.repository.metadata.Metadata();
mr.setModelVersion("1.1.0");
mr.setGroupId(metadata.getGroupId());
mr.setArtifactId(metadata.getArtifactId());
mr.setVersioning(new Versioning());
boolean merged = false;
List<MetadataResult> results = system.resolveMetadata(session, requests);
    fis.close();
    if (m.getVersioning() != null) {
      mr.getVersioning().setLastUpdated(latestTimestamp(mr.getVersioning().getLastUpdated(), m.getVersioning().getLastUpdated()));
      mr.getVersioning().setLatest(latestVersion(mr.getVersioning().getLatest(), m.getVersioning().getLatest()));
      mr.getVersioning().setRelease(latestVersion(mr.getVersioning().getRelease(), m.getVersioning().getRelease()));
      for (String v : m.getVersioning().getVersions()) {
        if (!mr.getVersioning().getVersions().contains(v)) {
          mr.getVersioning().getVersions().add(v);
      mr.getVersioning().getSnapshotVersions().addAll(m.getVersioning().getSnapshotVersions());
  Collections.sort(mr.getVersioning().getVersions(), VERSION_COMPARATOR);
  Collections.sort(mr.getVersioning().getSnapshotVersions(), SNAPSHOT_VERSION_COMPARATOR);
  File tmpFile = Files.createTempFile(runtimeProperties.getDataPath());
  FileOutputStream fos = new FileOutputStream(tmpFile);

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

private static Metadata createRepositoryMetadata( Artifact artifact )
{
  Metadata metadata = new Metadata();
  metadata.setGroupId( artifact.getGroupId() );
  metadata.setArtifactId( artifact.getArtifactId() );
  Versioning versioning = new Versioning();
  versioning.addVersion( artifact.getBaseVersion() );
  if ( !artifact.isSnapshot() )
  {
    versioning.setRelease( artifact.getBaseVersion() );
  }
  if ( "maven-plugin".equals( artifact.getProperty( ArtifactProperties.TYPE, "" ) ) )
  {
    versioning.setLatest( artifact.getBaseVersion() );
  }
  metadata.setVersioning( versioning );
  return metadata;
}

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

if (left.getVersioning() == null) {
 left.setVersioning(new Versioning());
if (rv.getLastUpdated() != null) {
 if (lv.getLastUpdated() == null) {
  lv.setLastUpdated(rv.getLastUpdated());
  final long lts = ts(lv.getLastUpdated());
  final long rts = ts(rv.getLastUpdated());
  if (rts > lts) {
   lv.setLastUpdated(rv.getLastUpdated());
nullElementFilter(lv.getVersions());
nullElementFilter(rv.getVersions());
for (String version : rv.getVersions()) {
 if (!lv.getVersions().contains(version)) {
  lv.getVersions().add(version);
if (rv.getSnapshot() != null) {
 if (lv.getSnapshot() == null) {
  lv.setSnapshot(rv.getSnapshot());
  final long lts = ts(lv.getSnapshot().getTimestamp());
  final long rts = ts(rv.getSnapshot().getTimestamp());
  if (rts > lts) {
   lv.setSnapshot(rv.getSnapshot());
nullElementFilter(lv.getSnapshotVersions());
nullElementFilter(rv.getSnapshotVersions());

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

if ( versioning.getLatest() != null )
  serializer.startTag( NAMESPACE, "latest" ).text( versioning.getLatest() ).endTag( NAMESPACE, "latest" );
if ( versioning.getRelease() != null )
  serializer.startTag( NAMESPACE, "release" ).text( versioning.getRelease() ).endTag( NAMESPACE, "release" );
if ( versioning.getSnapshot() != null )
  writeSnapshot( (Snapshot) versioning.getSnapshot(), "snapshot", serializer );
if ( ( versioning.getVersions() != null ) && ( versioning.getVersions().size() > 0 ) )
  for ( Iterator iter = versioning.getVersions().iterator(); iter.hasNext(); )
if ( versioning.getLastUpdated() != null )
  serializer.startTag( NAMESPACE, "lastUpdated" ).text( versioning.getLastUpdated() ).endTag( NAMESPACE, "lastUpdated" );
if ( ( versioning.getSnapshotVersions() != null ) && ( versioning.getSnapshotVersions().size() > 0 ) )
  for ( Iterator iter = versioning.getSnapshotVersions().iterator(); iter.hasNext(); )

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

@Override
protected boolean isMetadataCorrect( Metadata oldMd, String path )
  throws IOException
{
  if ( oldMd.getArtifactId() == null || oldMd.getGroupId() == null || oldMd.getVersion() == null
    || oldMd.getVersioning() == null || oldMd.getVersioning().getSnapshot() == null
    || oldMd.getVersioning().getSnapshot().getTimestamp() == null )
  {
    return false;
  }
  Metadata md = createMetadata( path );
  if ( StringUtils.equals( oldMd.getArtifactId(), md.getArtifactId() )
    && StringUtils.equals( oldMd.getGroupId(), md.getGroupId() )
    && StringUtils.equals( oldMd.getVersion(), md.getVersion() )
    && md.getVersioning() != null
    && md.getVersioning().getSnapshot() != null
    && StringUtils.equals( oldMd.getVersioning().getSnapshot().getTimestamp(),
      md.getVersioning().getSnapshot().getTimestamp() )
    && oldMd.getVersioning().getSnapshot().getBuildNumber() == md.getVersioning().getSnapshot().getBuildNumber()
    && ( oldMd.getVersioning().getVersions().containsAll( md.getVersioning().getVersions() ) && md.getVersioning().getVersions().containsAll(
      oldMd.getVersioning().getVersions() ) )
    && equals( oldMd.getVersioning().getSnapshotVersions(), md.getVersioning().getSnapshotVersions() ) )
  {
    return true;
  }
  return false;
}

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

if ( repository.equals( selected ) )
  if ( m.getVersioning() == null )
    m.setVersioning( new Versioning() );
  if ( m.getVersioning().getSnapshot() == null )
    m.getVersioning().setSnapshot( new Snapshot() );
  if ( ( m.getVersioning() != null ) && ( m.getVersioning().getSnapshot() != null )
    && m.getVersioning().getSnapshot().isLocalCopy() )
    m.getVersioning().getSnapshot().setLocalCopy( false );
    metadata.setMetadata( m );
    metadata.storeInLocalRepository( localRepository, repository );

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

@Override
protected void merge( Metadata recessive )
  metadata.getVersioning().updateTimestamp();
    String lastUpdated = metadata.getVersioning().getLastUpdated();
    Versioning versioning = recessive.getVersioning();
    if ( versioning != null )
      for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
    metadata.getVersioning().setSnapshotVersions( new ArrayList<>( versions.values() ) );

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

private static int getBuildNumber( Metadata metadata )
{
  int number = 0;
  Versioning versioning = metadata.getVersioning();
  if ( versioning != null )
  {
    Snapshot snapshot = versioning.getSnapshot();
    if ( snapshot != null && snapshot.getBuildNumber() > 0 )
    {
      number = snapshot.getBuildNumber();
    }
  }
  return number;
}

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

Versioning vs = metadata.getVersioning();
  vs = new Versioning();
  metadata.setVersioning( vs );
if ( vs.getVersions() != null && vs.getVersions().size() > 0 )
  List<String> vl = vs.getVersions();
List<String> versions = vs.getVersions();
  vs.setVersions( new ArrayList2( versions ) );
  versions = vs.getVersions();
  vs.setLatest( getLatestVersion( versions ) );
  vs.setRelease( getReleaseVersion( versions ) );
  vs.setLastUpdated( TimeUtil.getUTCTimestamp() );

相关文章