Java Code Examples for org.apache.maven.artifact.repository.metadata.Metadata#setVersioning()

The following examples show how to use org.apache.maven.artifact.repository.metadata.Metadata#setVersioning() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositoryMetadataMergerTest.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
private Metadata a(final String groupId,
                   final String artifactId,
                   final String lastUpdated,
                   final String latest,
                   final String release,
                   final String... versions)
{
  final Metadata m = new Metadata();
  m.setGroupId(groupId);
  m.setArtifactId(artifactId);
  m.setVersioning(new Versioning());
  final Versioning mv = m.getVersioning();
  if (!Strings.isNullOrEmpty(lastUpdated)) {
    mv.setLastUpdated(lastUpdated);
  }
  if (!Strings.isNullOrEmpty(latest)) {
    mv.setLatest(latest);
  }
  if (!Strings.isNullOrEmpty(release)) {
    mv.setRelease(release);
  }
  mv.getVersions().addAll(Arrays.asList(versions));
  return m;
}
 
Example 2
Source File: MavenMetadataGenerator.java    From artifactory-resource with Apache License 2.0 5 votes vote down vote up
private void writeMetadata(File folder, List<MavenCoordinates> coordinates, boolean generateChecksums) {
	List<SnapshotVersion> snapshotVersions = getSnapshotVersionMetadata(coordinates);
	if (!snapshotVersions.isEmpty()) {
		Metadata metadata = new Metadata();
		Versioning versioning = new Versioning();
		versioning.setSnapshotVersions(snapshotVersions);
		metadata.setVersioning(versioning);
		metadata.setGroupId(coordinates.get(0).getGroupId());
		metadata.setArtifactId(coordinates.get(0).getArtifactId());
		metadata.setVersion(coordinates.get(0).getVersion());
		writeMetadataFile(metadata, new File(folder, "maven-metadata.xml"), generateChecksums);
	}
}
 
Example 3
Source File: RepositoryMetadataMergerTest.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private Metadata v(final String groupId,
                   final String artifactId,
                   final String versionPrefix,
                   final String timestamp,
                   final int buildNumber)
{
  final Metadata m = new Metadata();
  m.setGroupId(groupId);
  m.setArtifactId(artifactId);
  m.setVersion(versionPrefix + "-SNAPSHOT");
  m.setVersioning(new Versioning());
  final Versioning mv = m.getVersioning();
  mv.setLastUpdated(timestamp.replace(".", ""));
  final Snapshot snapshot = new Snapshot();
  snapshot.setTimestamp(timestamp);
  snapshot.setBuildNumber(buildNumber);
  mv.setSnapshot(snapshot);
  final SnapshotVersion pom = new SnapshotVersion();
  pom.setExtension("pom");
  pom.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
  pom.setUpdated(timestamp);
  mv.getSnapshotVersions().add(pom);

  final SnapshotVersion jar = new SnapshotVersion();
  jar.setExtension("jar");
  jar.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
  jar.setUpdated(timestamp);
  mv.getSnapshotVersions().add(jar);

  final SnapshotVersion sources = new SnapshotVersion();
  sources.setExtension("jar");
  sources.setClassifier("sources");
  sources.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
  sources.setUpdated(timestamp);
  mv.getSnapshotVersions().add(sources);

  return m;
}
 
Example 4
Source File: VersioningCalculatorTest.java    From pom-manipulation-ext with Apache License 2.0 5 votes vote down vote up
private byte[] setupMetadataVersions( final String... versions )
    throws IOException
{
    final Metadata md = new Metadata();
    final Versioning v = new Versioning();
    md.setVersioning( v );
    v.setVersions( Arrays.asList( versions ) );

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new MetadataXpp3Writer().write( baos, md );

    return baos.toByteArray();
}