use of org.apache.archiva.model.VersionedReference in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testToMetadataPathFromVersionReference.
@Test
public void testToMetadataPathFromVersionReference() {
VersionedReference reference = new VersionedReference();
reference.setGroupId("com.foo");
reference.setArtifactId("foo-tool");
reference.setVersion("1.0");
assertEquals("com/foo/foo-tool/1.0/maven-metadata.xml", repoContent.toMetadataPath(reference));
}
use of org.apache.archiva.model.VersionedReference in project archiva by apache.
the class MetadataToolsTest method assertSnapshotVersions.
private void assertSnapshotVersions(String artifactId, String version, String[] expectedVersions) throws Exception {
Path repoRootDir = Paths.get("src/test/repositories/metadata-repository");
VersionedReference reference = new VersionedReference();
reference.setGroupId("org.apache.archiva.metadata.tests");
reference.setArtifactId(artifactId);
reference.setVersion(version);
MavenManagedRepository repo = createRepository("test-repo", "Test Repository: " + name.getMethodName(), repoRootDir);
RepositoryContentProvider provider = applicationContext.getBean("repositoryContentProvider#maven", RepositoryContentProvider.class);
ManagedRepositoryContent repoContent = provider.createManagedContent(repo);
Set<String> testedVersionSet = tools.gatherSnapshotVersions(repoContent, reference);
// Sort the list (for asserts)
List<String> testedVersions = new ArrayList<>();
testedVersions.addAll(testedVersionSet);
Collections.sort(testedVersions, new VersionComparator());
// Test the expected array of versions, to the actual tested versions
assertEquals("Assert Snapshot Versions: length/size", expectedVersions.length, testedVersions.size());
for (int i = 0; i < expectedVersions.length; i++) {
String actualVersion = testedVersions.get(i);
assertEquals("Snapshot Versions[" + i + "]", expectedVersions[i], actualVersion);
}
}
use of org.apache.archiva.model.VersionedReference in project archiva by apache.
the class MetadataToolsTest method testToPathFromVersionReference.
@Test
public void testToPathFromVersionReference() {
VersionedReference reference = new VersionedReference();
reference.setGroupId("com.foo");
reference.setArtifactId("foo-tool");
reference.setVersion("1.0");
assertEquals("com/foo/foo-tool/1.0/maven-metadata.xml", tools.toPath(reference));
}
use of org.apache.archiva.model.VersionedReference in project archiva by apache.
the class ManagedDefaultRepositoryContent method newVersionedRef.
static final VersionedReference newVersionedRef(final String groupId, final String artifactId, final String version) {
VersionedReference ref = new VersionedReference();
ref.setGroupId(groupId);
ref.setArtifactId(artifactId);
ref.setVersion(version);
return ref;
}
use of org.apache.archiva.model.VersionedReference in project archiva by apache.
the class CleanupReleasedSnapshotsRepositoryPurge method updateMetadata.
/*
* TODO: Uses a deprecated API, but if we use the API with location string, it does not work as expected
* -> not sure what needs to be changed here.
*/
@SuppressWarnings("deprecation")
private void updateMetadata(ArtifactReference artifact) {
VersionedReference versionRef = new VersionedReference();
versionRef.setGroupId(artifact.getGroupId());
versionRef.setArtifactId(artifact.getArtifactId());
versionRef.setVersion(artifact.getVersion());
ProjectReference projectRef = new ProjectReference();
projectRef.setGroupId(artifact.getGroupId());
projectRef.setArtifactId(artifact.getArtifactId());
try {
metadataTools.updateMetadata(repository, versionRef);
} catch (ContentNotFoundException e) {
// Ignore. (Just means we have no snapshot versions left to reference).
} catch (RepositoryMetadataException e) {
// Ignore.
} catch (IOException e) {
// Ignore.
} catch (LayoutException e) {
// Ignore.
}
try {
metadataTools.updateMetadata(repository, projectRef);
} catch (ContentNotFoundException e) {
// Ignore. (Just means we have no snapshot versions left to reference).
} catch (RepositoryMetadataException e) {
// Ignore.
} catch (IOException e) {
// Ignore.
} catch (LayoutException e) {
// Ignore.
}
}
Aggregations