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);
}
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)));
}
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);
}
Aggregations