Search in sources :

Example 46 with Metadata

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"));
}
Also used : Versioning(org.apache.maven.artifact.repository.metadata.Versioning) MetadataXpp3Writer(org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer) StringWriter(java.io.StringWriter) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) TransferMetadata(org.commonjava.maven.galley.io.checksum.TransferMetadata) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 47 with Metadata

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)));
}
Also used : Versioning(org.apache.maven.artifact.repository.metadata.Versioning) MetadataXpp3Writer(org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer) StringWriter(java.io.StringWriter) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) TransferMetadata(org.commonjava.maven.galley.io.checksum.TransferMetadata) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 48 with Metadata

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"));
}
Also used : Versioning(org.apache.maven.artifact.repository.metadata.Versioning) MetadataXpp3Writer(org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer) StringWriter(java.io.StringWriter) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) TransferMetadata(org.commonjava.maven.galley.io.checksum.TransferMetadata) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 49 with Metadata

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"));
}
Also used : Versioning(org.apache.maven.artifact.repository.metadata.Versioning) MetadataXpp3Writer(org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer) StringWriter(java.io.StringWriter) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) TransferMetadata(org.commonjava.maven.galley.io.checksum.TransferMetadata) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 50 with Metadata

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"));
}
Also used : ExternalResourceName(org.gradle.internal.resource.ExternalResourceName) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) MavenArtifact(org.gradle.api.publish.maven.MavenArtifact)

Aggregations

Metadata (org.apache.maven.artifact.repository.metadata.Metadata)55 Versioning (org.apache.maven.artifact.repository.metadata.Versioning)31 Test (org.junit.Test)20 File (java.io.File)18 MetadataXpp3Reader (org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader)16 MetadataXpp3Writer (org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer)16 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)15 Transfer (org.commonjava.maven.galley.model.Transfer)13 SnapshotVersion (org.apache.maven.artifact.repository.metadata.SnapshotVersion)12 StoreKey (org.commonjava.indy.model.core.StoreKey)12 IOException (java.io.IOException)9 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)9 Group (org.commonjava.indy.model.core.Group)9 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)9 Snapshot (org.apache.maven.artifact.repository.metadata.Snapshot)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 MavenResolver (io.fabric8.maven.MavenResolver)6 InputStream (java.io.InputStream)6 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6