Package org.apache.maven.artifact.repository.metadata

Examples of org.apache.maven.artifact.repository.metadata.Snapshot


    }

    private static Versioning getVersioning( String timestamp, int buildNumber, File file )
    {
        Versioning versioning = new Versioning();
        versioning.setSnapshot( new Snapshot() );
        versioning.getSnapshot().setTimestamp( timestamp );
        versioning.getSnapshot().setBuildNumber( buildNumber );
        setLastUpdatedTimestamp( versioning, file );
        return versioning;
    }
View Full Code Here


    public void testValidSnapshotMetadata()
    {
        Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact",
                                                                 "1.0-alpha-1-SNAPSHOT", "type" );

        Snapshot snapshot = new Snapshot();
        snapshot.setBuildNumber( 1 );
        snapshot.setTimestamp( "20050611.202024" );

        RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );

        badMetadataReportProcessor.processMetadata( metadata, repository );
View Full Code Here

    public void testInvalidSnapshotMetadata()
    {
        Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact",
                                                                 "1.0-alpha-1-SNAPSHOT", "type" );

        Snapshot snapshot = new Snapshot();
        snapshot.setBuildNumber( 2 );
        snapshot.setTimestamp( "20050611.202024" );

        RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );

        badMetadataReportProcessor.processMetadata( metadata, repository );
View Full Code Here

                    versioning = new Versioning();

                    Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher( artifact.getVersion() );
                    if ( matcher.matches() )
                    {
                        Snapshot snapshot = new Snapshot();
                        snapshot.setBuildNumber( Integer.valueOf( matcher.group( 3 ) ).intValue() );
                        snapshot.setTimestamp( matcher.group( 2 ) );
                        versioning.setSnapshot( snapshot );
                    }

                    // TODO: merge latest/release/snapshot from source instead
                    metadata.setVersioning( versioning );
View Full Code Here

                    if ( matcher.matches() )
                    {
                        boolean correct = false;
                        if ( metadata.getVersioning() != null && metadata.getVersioning().getSnapshot() != null )
                        {
                            Snapshot snapshot = metadata.getVersioning().getSnapshot();
                            int build = Integer.valueOf( matcher.group( 3 ) ).intValue();
                            String ts = matcher.group( 2 );
                            if ( build == snapshot.getBuildNumber() && ts.equals( snapshot.getTimestamp() ) )
                            {
                                correct = true;
                            }
                        }
View Full Code Here

        ops.add(new AddVersionOperation(new StringOperand(sourceModelVersion, version)));
      }

      // versioning.snapshot
      // use the snapshot with newest timestamp
      Snapshot sourceSnapshot = sourceMetadata.getVersioning().getSnapshot();

      if (sourceSnapshot != null) {
        long timestamp = -1;

        if (targetMetadata.getVersioning() != null && targetMetadata.getVersioning().getSnapshot() != null
            && targetMetadata.getVersioning().getSnapshot().getTimestamp() != null) {
          try {
            timestamp =
                Long.parseLong(targetMetadata.getVersioning().getSnapshot().getTimestamp().replace(".",
                    ""));
          }
          catch (NumberFormatException e) {
          }
        }

        long sourceTimestamp = -1;

        if (sourceSnapshot.getTimestamp() != null) {
          try {
            sourceTimestamp = Long.parseLong(sourceSnapshot.getTimestamp().replace(".", ""));
          }
          catch (NumberFormatException e) {
          }
        }
View Full Code Here

  public static void updateTimestamp(Versioning target) {
    target.setLastUpdated(TimeUtil.getUTCTimestamp());
  }

  public static Snapshot createSnapshot(String version) {
    Snapshot sn = new Snapshot();

    if (version == null || version.length() < 3) {
      return sn;
    }

    String utc = TimeUtil.getUTCTimestamp();
    sn.setTimestamp(utc);

    if (version.endsWith("-SNAPSHOT")) {
      return sn;
    }

    int pos = version.lastIndexOf('-');

    if (pos == -1) {
      throw new IllegalArgumentException();
    }

    String sbn = version.substring(pos + 1);

    int bn = Integer.parseInt(sbn);
    sn.setBuildNumber(bn);

    String sts = version.substring(0, pos);
    pos = sts.lastIndexOf('-');

    if (pos == -1) {
      throw new IllegalArgumentException();
    }

    sn.setTimestamp(sts.substring(pos + 1));

    return sn;
  }
View Full Code Here

        if (sourceVersioning.getLatest() != null) {
          changed = true;
          targetVersioning.setLatest(sourceVersioning.getLatest());
        }

        Snapshot s = targetVersioning.getSnapshot();
        Snapshot snapshot = sourceVersioning.getSnapshot();
        if (snapshot != null) {
          if (s == null) {
            s = new Snapshot();
            targetVersioning.setSnapshot(s);
            changed = true;
          }

          // overwrite
          if (s.getTimestamp() == null ? snapshot.getTimestamp() != null
              : !s.getTimestamp().equals(snapshot.getTimestamp())) {
            s.setTimestamp(snapshot.getTimestamp());
            changed = true;
          }
          if (s.getBuildNumber() != snapshot.getBuildNumber()) {
            s.setBuildNumber(snapshot.getBuildNumber());
            changed = true;
          }
          if (s.isLocalCopy() != snapshot.isLocalCopy()) {
            s.setLocalCopy(snapshot.isLocalCopy());
            changed = true;
          }
        }
      }
    }
View Full Code Here

    SnapshotVersion snap = new SnapshotVersion();
    snap.setClassifier(gav.getClassifier());
    snap.setExtension(gav.getExtension());
    snap.setVersion(gav.getVersion());

    Snapshot timestamp = buildSnapshot(gav);
    if (timestamp != null) {
      snap.setUpdated(timestamp.getTimestamp().replace(".", ""));
    }
    else {
      snap.setUpdated(TimeUtil.getUTCTimestamp().replace(".", ""));
    }
    return new SnapshotVersion[]{snap};
View Full Code Here

    }
    return new SnapshotVersion[]{snap};
  }

  private Snapshot buildSnapshot(Gav gav) {
    Snapshot result = new Snapshot();

    final String version = gav.getVersion();

    if (version.equals(gav.getBaseVersion())) {
      return null;
    }

    int lastHyphenPos = version.lastIndexOf('-');

    int buildNumber = Integer.parseInt(version.substring(lastHyphenPos + 1));

    String timestamp = version.substring(gav.getBaseVersion().length() - 8, lastHyphenPos);

    result.setLocalCopy(false);

    result.setBuildNumber(buildNumber);

    result.setTimestamp(timestamp);

    return result;
  }
View Full Code Here

TOP

Related Classes of org.apache.maven.artifact.repository.metadata.Snapshot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.