Search in sources :

Example 26 with ArtifactRepositoryMetadata

use of org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata in project archiva by apache.

the class LegacyToDefaultConverterTest method testV4PomConvert.

@Test
public void testV4PomConvert() throws Exception {
    // test that it is copied as is
    Artifact artifact = createArtifact("test", "v4artifact", "1.0.0");
    ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata(artifact);
    Path artifactMetadataFile = Paths.get(targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata(artifactMetadata));
    Files.deleteIfExists(artifactMetadataFile);
    ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata(artifact);
    Path versionMetadataFile = Paths.get(targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata(versionMetadata));
    Files.deleteIfExists(versionMetadataFile);
    Path artifactFile = Paths.get(targetRepository.getBasedir(), targetRepository.pathOf(artifact));
    Files.deleteIfExists(artifactFile);
    artifactConverter.convert(artifact, targetRepository);
    checkSuccess(artifactConverter);
    assertTrue("Check artifact created", Files.exists(artifactFile));
    assertTrue("Check artifact matches", FileUtils.contentEquals(artifactFile.toFile(), artifact.getFile()));
    artifact = createPomArtifact(artifact);
    Path pomFile = Paths.get(targetRepository.getBasedir(), targetRepository.pathOf(artifact));
    Path sourcePomFile = Paths.get(sourceRepository.getBasedir(), sourceRepository.pathOf(artifact));
    assertTrue("Check POM created", Files.exists(pomFile));
    compareFiles(sourcePomFile, pomFile);
    assertTrue("Check artifact metadata created", Files.exists(artifactMetadataFile));
    Path expectedMetadataFile = getTestFile("src/test/expected-files/v4-artifact-metadata.xml");
    compareFiles(expectedMetadataFile, artifactMetadataFile);
    assertTrue("Check snapshot metadata created", Files.exists(versionMetadataFile));
    expectedMetadataFile = getTestFile("src/test/expected-files/v4-version-metadata.xml");
    compareFiles(expectedMetadataFile, versionMetadataFile);
}
Also used : Path(java.nio.file.Path) SnapshotArtifactRepositoryMetadata(org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata) ArtifactMetadata(org.apache.maven.artifact.metadata.ArtifactMetadata) Artifact(org.apache.maven.artifact.Artifact) ArtifactRepositoryMetadata(org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata) SnapshotArtifactRepositoryMetadata(org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata) Test(org.junit.Test)

Example 27 with ArtifactRepositoryMetadata

use of org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata in project maven by apache.

the class DefaultUpdateCheckManagerTest method testMissingMetadata.

@Test
public void testMissingMetadata() throws Exception {
    ArtifactRepository remoteRepository = remoteRepository();
    ArtifactRepository localRepository = localRepository();
    Artifact a = createRemoteArtifact("a", "0.0.1-SNAPSHOT");
    RepositoryMetadata metadata = new ArtifactRepositoryMetadata(a);
    File file = new File(localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata(metadata, localRepository));
    file.delete();
    File touchFile = updateCheckManager.getTouchfile(metadata, file);
    touchFile.delete();
    assertTrue(updateCheckManager.isUpdateRequired(metadata, remoteRepository, file));
    updateCheckManager.touch(metadata, remoteRepository, file);
    assertFalse(updateCheckManager.isUpdateRequired(metadata, remoteRepository, file));
    assertNotNull(updateCheckManager.readLastUpdated(touchFile, updateCheckManager.getMetadataKey(remoteRepository, file)));
}
Also used : ArtifactRepositoryMetadata(org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata) RepositoryMetadata(org.apache.maven.artifact.repository.metadata.RepositoryMetadata) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact) ArtifactRepositoryMetadata(org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata) Test(org.junit.jupiter.api.Test)

Example 28 with ArtifactRepositoryMetadata

use of org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata in project maven by apache.

the class MavenMetadataSource method retrieveAvailableVersions.

public List<ArtifactVersion> retrieveAvailableVersions(MetadataResolutionRequest request) throws ArtifactMetadataRetrievalException {
    RepositoryMetadata metadata = new ArtifactRepositoryMetadata(request.getArtifact());
    try {
        repositoryMetadataManager.resolve(metadata, request);
    } catch (RepositoryMetadataResolutionException e) {
        throw new ArtifactMetadataRetrievalException(e.getMessage(), e, request.getArtifact());
    }
    List<String> availableVersions = request.getLocalRepository().findVersions(request.getArtifact());
    return retrieveAvailableVersionsFromMetadata(metadata.getMetadata(), availableVersions);
}
Also used : ArtifactMetadataRetrievalException(org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException) ArtifactRepositoryMetadata(org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata) RepositoryMetadata(org.apache.maven.artifact.repository.metadata.RepositoryMetadata) RepositoryMetadataResolutionException(org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException) ArtifactRepositoryMetadata(org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata)

Aggregations

ArtifactRepositoryMetadata (org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata)28 SnapshotArtifactRepositoryMetadata (org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata)22 Artifact (org.apache.maven.artifact.Artifact)20 Path (java.nio.file.Path)18 Test (org.junit.Test)16 ArtifactMetadata (org.apache.maven.artifact.metadata.ArtifactMetadata)11 RepositoryMetadata (org.apache.maven.artifact.repository.metadata.RepositoryMetadata)8 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)4 Metadata (org.apache.maven.artifact.repository.metadata.Metadata)3 RepositoryMetadataResolutionException (org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException)3 Versioning (org.apache.maven.artifact.repository.metadata.Versioning)3 File (java.io.File)2 ArtifactMetadataRetrievalException (org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException)2 MetadataBridge (org.apache.maven.artifact.repository.metadata.MetadataBridge)2 Snapshot (org.apache.maven.artifact.repository.metadata.Snapshot)2 ProjectArtifactMetadata (org.apache.maven.project.artifact.ProjectArtifactMetadata)2 RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)2 SubArtifact (org.eclipse.aether.util.artifact.SubArtifact)2 Test (org.junit.jupiter.api.Test)2 IOException (java.io.IOException)1