use of org.apache.maven.artifact.repository.metadata.Metadata in project indy by Commonjava.
the class KojiMavenMetadataProviderTest method retrieveVersionMetadata.
@Test
public void retrieveVersionMetadata() throws Exception {
initKojiClient("simple-metadata-generate", false);
Metadata metadata = provider.getMetadata(new StoreKey(MAVEN_PKG_KEY, group, "public"), "commons-io/commons-io/maven-metadata.xml");
assertThat(metadata, notNullValue());
StringWriter sw = new StringWriter();
new MetadataXpp3Writer().write(sw, metadata);
System.out.println(sw.toString());
Versioning versioning = metadata.getVersioning();
assertThat(versioning, notNullValue());
assertThat(versioning.getLatest(), equalTo("2.4.0.redhat-1"));
assertThat(versioning.getRelease(), equalTo("2.4.0.redhat-1"));
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(2));
int idx = 0;
assertThat(versions.get(idx), equalTo("2.1-redhat-1"));
idx++;
assertThat(versions.get(idx), equalTo("2.4.0.redhat-1"));
}
use of org.apache.maven.artifact.repository.metadata.Metadata in project indy by Commonjava.
the class KojiMavenMetadataProviderTest method allowVersionMetadataToExpire.
@Test
public void allowVersionMetadataToExpire() throws Exception {
initKojiClient("simple-metadata-generate", false);
StoreKey sk = new StoreKey(MAVEN_PKG_KEY, group, "public");
String path = "commons-io/commons-io/maven-metadata.xml";
Metadata metadata = provider.getMetadata(sk, path);
assertThat(metadata, notNullValue());
StringWriter sw = new StringWriter();
new MetadataXpp3Writer().write(sw, metadata);
System.out.println(sw.toString());
Versioning versioning = metadata.getVersioning();
assertThat(versioning, notNullValue());
assertThat(versioning.getLatest(), equalTo("2.4.0.redhat-1"));
assertThat(versioning.getRelease(), equalTo("2.4.0.redhat-1"));
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(2));
int idx = 0;
assertThat(versions.get(idx), equalTo("2.1-redhat-1"));
idx++;
assertThat(versions.get(idx), equalTo("2.4.0.redhat-1"));
String originalLastUpdated = versioning.getLastUpdated();
Thread.sleep(4000);
// reset to just after getAPIVersion, since this is only called when the client initializes.
counter.set(1);
metadata = provider.getMetadata(sk, path);
assertThat(metadata, notNullValue());
sw = new StringWriter();
new MetadataXpp3Writer().write(sw, metadata);
System.out.println(sw.toString());
assertThat(metadata.getVersioning(), notNullValue());
System.out.printf("\n\nOriginal lastUpdated: '%s'\nNew lastUpdated: '%s'\n\n", originalLastUpdated, metadata.getVersioning().getLastUpdated());
assertThat(metadata.getVersioning().getLastUpdated(), CoreMatchers.not(CoreMatchers.equalTo(originalLastUpdated)));
}
use of org.apache.maven.artifact.repository.metadata.Metadata in project indy by Commonjava.
the class KojiMavenMetadataProviderTest method retrieveVersionMetadataWithVerification.
@Test
public void retrieveVersionMetadataWithVerification() throws Exception {
initKojiClient("simple-metadata-verify", true);
Metadata metadata = provider.getMetadata(new StoreKey(MAVEN_PKG_KEY, group, "public"), "commons-io/commons-io/maven-metadata.xml");
assertThat(metadata, notNullValue());
StringWriter sw = new StringWriter();
new MetadataXpp3Writer().write(sw, metadata);
System.out.println(sw.toString());
Versioning versioning = metadata.getVersioning();
assertThat(versioning, notNullValue());
assertThat(versioning.getLatest(), equalTo("2.4.0.redhat-1"));
assertThat(versioning.getRelease(), equalTo("2.4.0.redhat-1"));
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(2));
int idx = 0;
assertThat(versions.get(idx), equalTo("2.1-redhat-1"));
idx++;
assertThat(versions.get(idx), equalTo("2.4.0.redhat-1"));
}
use of org.apache.maven.artifact.repository.metadata.Metadata in project indy by Commonjava.
the class KojiMavenMetadataProviderTest method retrieveVersionMetadataWithTagWhitelist.
@Test
public void retrieveVersionMetadataWithTagWhitelist() throws Exception {
kojiConfig.setTagPatternsEnabled(true);
kojiConfig.setTagPatterns(Collections.singletonList("jb-.+"));
initKojiClient("whitelisted-tags-metadata-generate", false);
Metadata metadata = provider.getMetadata(new StoreKey(MAVEN_PKG_KEY, group, "public"), "commons-io/commons-io/maven-metadata.xml");
assertThat(metadata, notNullValue());
StringWriter sw = new StringWriter();
new MetadataXpp3Writer().write(sw, metadata);
System.out.println(sw.toString());
Versioning versioning = metadata.getVersioning();
assertThat(versioning, notNullValue());
assertThat(versioning.getLatest(), equalTo("2.4.0.redhat-1"));
assertThat(versioning.getRelease(), equalTo("2.4.0.redhat-1"));
List<String> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.size(), equalTo(2));
int idx = 0;
assertThat(versions.get(idx), equalTo("2.1-redhat-1"));
idx++;
assertThat(versions.get(idx), equalTo("2.4.0.redhat-1"));
}
use of org.apache.maven.artifact.repository.metadata.Metadata in project gradle by gradle.
the class AbstractMavenPublisher method publish.
protected void publish(MavenNormalizedPublication publication, ExternalResourceRepository repository, URI rootUri, boolean localRepo) {
String groupId = publication.getGroupId();
String artifactId = publication.getArtifactId();
String version = publication.getVersion();
ModuleArtifactPublisher artifactPublisher = new ModuleArtifactPublisher(repository, localRepo, rootUri, groupId, artifactId, version);
if (isSnapshot(version)) {
ExternalResourceName snapshotMetadataPath = artifactPublisher.getSnapshotMetadataLocation();
Metadata snapshotMetadata = createSnapshotMetadata(publication, groupId, artifactId, version, repository, snapshotMetadataPath);
artifactPublisher.publish(snapshotMetadataPath, writeMetadataToTmpFile(snapshotMetadata, "snapshot-maven-metadata.xml"));
if (!localRepo) {
// Use the timestamped version for all published artifacts:
// The timestamped version is hidden deep in `Metadata.versioning.snapshotVersions`
artifactPublisher.artifactVersion = snapshotMetadata.getVersioning().getSnapshotVersions().get(0).getVersion();
}
}
if (publication.getMainArtifact() != null) {
artifactPublisher.publish(null, publication.getMainArtifact().getExtension(), publication.getMainArtifact().getFile());
}
artifactPublisher.publish(null, "pom", publication.getPomArtifact().getFile());
for (MavenArtifact artifact : publication.getAdditionalArtifacts()) {
artifactPublisher.publish(artifact.getClassifier(), artifact.getExtension(), artifact.getFile());
}
ExternalResourceName externalResource = artifactPublisher.getMetadataLocation();
Metadata metadata = createMetadata(groupId, artifactId, version, repository, externalResource);
artifactPublisher.publish(externalResource, writeMetadataToTmpFile(metadata, "module-maven-metadata.xml"));
}
Aggregations