Search in sources :

Example 1 with Revision

use of aQute.maven.api.Revision in project bnd by bndtools.

the class MavenRepoTest method testBasic.

public void testBasic() throws Exception {
    Program program = Program.valueOf("commons-cli", "commons-cli");
    List<Revision> revisions = storage.getRevisions(program);
    assertNotNull(revisions);
    assertEquals(3, revisions.size());
    Revision revision = program.version(new MavenVersion("1.4-SNAPSHOT"));
    assertTrue(revisions.contains(revision));
    List<Archive> snapshotArchives = storage.getSnapshotArchives(revision);
    assertNotNull(snapshotArchives);
    assertEquals(10, snapshotArchives.size());
    Archive archive = storage.getResolvedArchive(revision, "pom", null);
    assertNotNull(archive);
    assertEquals("1.4-20160119.062305-9", archive.snapshot.toString());
    File file = storage.get(archive).getValue();
    assertNotNull(file);
    assertEquals(10373L, file.length());
}
Also used : MavenVersion(aQute.bnd.version.MavenVersion) Program(aQute.maven.api.Program) Archive(aQute.maven.api.Archive) Revision(aQute.maven.api.Revision) File(java.io.File)

Example 2 with Revision

use of aQute.maven.api.Revision in project bnd by bndtools.

the class MavenRepoTest method testSnapshotCaches.

public void testSnapshotCaches() throws Exception {
    File fpom = IO.getFile(local, "commons-cli/commons-cli/1.4-SNAPSHOT/commons-cli-1.4-SNAPSHOT.pom");
    Program program = Program.valueOf("commons-cli", "commons-cli");
    Revision revision = Program.valueOf("commons-cli", "commons-cli").version("1.4-SNAPSHOT");
    Archive apom = revision.archive("pom", null);
    assertFalse(fpom.exists());
    assertFalse(apom.isResolved());
    File f = storage.get(apom).getValue();
    assertEquals(fpom.getAbsolutePath(), f.getAbsolutePath());
    assertRecent(f);
    long flastModified = f.lastModified();
    Thread.sleep(1001);
    f = storage.get(apom).getValue();
    assertEquals(flastModified, f.lastModified());
    f.setLastModified(0);
    assertFalse(Math.abs(System.currentTimeMillis() - f.lastModified()) <= 2000);
    f = storage.get(apom).getValue();
    assertFalse(f.lastModified() != 0);
}
Also used : Program(aQute.maven.api.Program) Archive(aQute.maven.api.Archive) Revision(aQute.maven.api.Revision) File(java.io.File)

Example 3 with Revision

use of aQute.maven.api.Revision in project bnd by bndtools.

the class Traverser method getResources.

Promise<Map<Archive, Resource>> getResources() throws Exception {
    /*
		 * We don't want to resolve until all the work is queued so we
		 * initialize the count to 1 and call finish after queuing all the work.
		 */
    if (count.compareAndSet(-1, 1)) {
        try {
            if (!uris.isEmpty()) {
                for (URI uri : uris) {
                    File in = client.build().useCache().age(1, TimeUnit.DAYS).go(uri);
                    POM pom = new POM(repo, in);
                    parsePom(pom, ROOT);
                }
            } else {
                for (Revision revision : revisions) parse(revision.archive("jar", null), ROOT);
            }
        } finally {
            finish();
        }
    }
    return deferred.getPromise();
}
Also used : Revision(aQute.maven.api.Revision) URI(java.net.URI) File(java.io.File) POM(aQute.maven.provider.POM)

Example 4 with Revision

use of aQute.maven.api.Revision in project bnd by bndtools.

the class PomRepositoryTest method testRepository.

public void testRepository() throws Exception {
    MavenRepository repo = getRepo();
    Revision revision = Revision.valueOf("bcel:bcel:5.1");
    PomRepository pom = new PomRepository(repo, client, location).revisions(Collections.singleton(revision));
    assertTrue(location.isFile());
    try (XMLResourceParser xp = new XMLResourceParser(location)) {
        List<Resource> parse = xp.parse();
        assertEquals(parse.size(), pom.getResources().size());
    }
}
Also used : MavenRepository(aQute.maven.provider.MavenRepository) Revision(aQute.maven.api.Revision) Resource(org.osgi.resource.Resource) XMLResourceParser(aQute.bnd.osgi.repository.XMLResourceParser)

Example 5 with Revision

use of aQute.maven.api.Revision in project bnd by bndtools.

the class RepoActions method addUpdate.

void addUpdate(final BundleDescriptor bd, Map<String, Runnable> map) throws Exception {
    try {
        Revision rev = bd.archive.revision;
        Program prog = rev.program;
        List<Revision> revisions = repo.storage.getRevisions(prog);
        if (revisions.size() > 1) {
            final Revision last = revisions.get(revisions.size() - 1);
            if (!rev.equals(last)) {
                map.put("Update to " + last, new Runnable() {

                    @Override
                    public void run() {
                        try {
                            repo.index.remove(bd.archive);
                            repo.index.add(last.archive(bd.archive.extension, bd.archive.classifier));
                            addDependency(bd.archive, MavenScope.runtime);
                        } catch (Exception e) {
                            throw Exceptions.duck(e);
                        }
                    }
                });
            } else
                map.put("-Update", null);
        }
    } catch (Exception e) {
        map.put("-Update [" + e + "]", null);
    }
}
Also used : Program(aQute.maven.api.Program) Revision(aQute.maven.api.Revision)

Aggregations

Revision (aQute.maven.api.Revision)11 Archive (aQute.maven.api.Archive)6 File (java.io.File)6 Program (aQute.maven.api.Program)5 MavenRepository (aQute.maven.provider.MavenRepository)3 Resource (org.osgi.resource.Resource)3 HttpClient (aQute.bnd.http.HttpClient)2 XMLResourceParser (aQute.bnd.osgi.repository.XMLResourceParser)1 MavenVersion (aQute.bnd.version.MavenVersion)1 Release (aQute.maven.api.Release)1 POM (aQute.maven.provider.POM)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Properties (java.util.Properties)1