Search in sources :

Example 1 with RevisionMetadata

use of aQute.maven.provider.MetadataParser.RevisionMetadata in project bnd by bndtools.

the class MavenBackingRepository method getMetadata.

RevisionMetadata getMetadata(Revision revision) throws Exception {
    File metafile = IO.getFile(local, revision.metadata(id));
    RevisionMetadata metadata = revisions.get(revision);
    TaggedData tag = fetch(revision.metadata(), metafile);
    if (tag.getState() == State.NOT_FOUND || tag.getState() == State.OTHER) {
        if (metadata == null) {
            metadata = new RevisionMetadata();
            revisions.put(revision, metadata);
        }
        return metadata;
    }
    if (metadata == null || tag.getState() == State.UPDATED) {
        metadata = MetadataParser.parseRevisionMetadata(metafile);
        revisions.put(revision, metadata);
    }
    return metadata;
}
Also used : TaggedData(aQute.bnd.service.url.TaggedData) File(java.io.File) RevisionMetadata(aQute.maven.provider.MetadataParser.RevisionMetadata)

Example 2 with RevisionMetadata

use of aQute.maven.provider.MetadataParser.RevisionMetadata in project bnd by bndtools.

the class MavenBackingRepository method getSnapshotArchives.

public List<Archive> getSnapshotArchives(Revision revision) throws Exception {
    RevisionMetadata metadata = getMetadata(revision);
    List<Archive> archives = new ArrayList<>();
    for (SnapshotVersion snapshotVersion : metadata.snapshotVersions) {
        Archive archive = revision.archive(snapshotVersion.value, snapshotVersion.extension, snapshotVersion.classifier);
        archives.add(archive);
    }
    return archives;
}
Also used : Archive(aQute.maven.api.Archive) SnapshotVersion(aQute.maven.provider.MetadataParser.SnapshotVersion) ArrayList(java.util.ArrayList) RevisionMetadata(aQute.maven.provider.MetadataParser.RevisionMetadata)

Example 3 with RevisionMetadata

use of aQute.maven.provider.MetadataParser.RevisionMetadata in project bnd by bndtools.

the class MetadataTest method testSnapshotParsing.

public void testSnapshotParsing() throws Exception {
    try (InputStream in = new FileInputStream(IO.getFile("testresources/parser/commons-dbcp-1.4.1-SNAPSHOT.xml"))) {
        RevisionMetadata parse = MetadataParser.parseRevisionMetadata(in);
        assertNotNull(parse);
        assertEquals("commons.dbcp", parse.group);
        assertEquals("commons-dbcp", parse.artifact);
        assertEquals(MavenVersion.parseString("1.4.1-SNAPSHOT"), parse.version);
        assertNotNull(parse.snapshot);
        assertEquals("13", parse.snapshot.buildNumber);
        assertEquals("20140107.141700", parse.snapshot.timestamp);
        assertEquals(10, parse.snapshotVersions.size());
        SnapshotVersion snapshotVersion = parse.snapshotVersions.get(0);
        assertNotNull(snapshotVersion);
        assertEquals("bin", snapshotVersion.classifier);
        assertEquals("tar.gz", snapshotVersion.extension);
        assertEquals(MavenVersion.parseString("1.4.1-20140107.141700-13"), snapshotVersion.value);
        assertEquals(1389104220000L, snapshotVersion.updated);
        snapshotVersion = parse.snapshotVersions.get(9);
        assertNotNull(snapshotVersion);
        assertNull(snapshotVersion.classifier);
        assertEquals("pom", snapshotVersion.extension);
        assertEquals(MavenVersion.parseString("1.4.1-20140107.141700-13"), snapshotVersion.value);
        assertEquals(1389104220000L, snapshotVersion.updated);
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) SnapshotVersion(aQute.maven.provider.MetadataParser.SnapshotVersion) FileInputStream(java.io.FileInputStream) RevisionMetadata(aQute.maven.provider.MetadataParser.RevisionMetadata)

Aggregations

RevisionMetadata (aQute.maven.provider.MetadataParser.RevisionMetadata)3 SnapshotVersion (aQute.maven.provider.MetadataParser.SnapshotVersion)2 TaggedData (aQute.bnd.service.url.TaggedData)1 Archive (aQute.maven.api.Archive)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1