Search in sources :

Example 1 with Program

use of aQute.maven.api.Program 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 Program

use of aQute.maven.api.Program 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 Program

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

the class POM method dependency.

private Dependency dependency(Element dependency) throws Exception {
    String groupId = get(dependency, "groupId", "<no group>");
    String artifactId = get(dependency, "artifactId", "<no artifact>");
    Dependency d = new Dependency();
    d.optional = isTrue(get(dependency, "optional", "true"));
    String version = get(dependency, "version", null);
    String extension = get(dependency, "type", "jar");
    String classifier = get(dependency, "classifier", null);
    String scope = get(dependency, "scope", "compile");
    Program program = Program.valueOf(groupId, artifactId);
    if (program == null)
        throw new IllegalArgumentException("Invalid dependency in " + revision + " to " + groupId + ":" + artifactId);
    d.program = program;
    d.version = version;
    d.type = extension;
    d.classifier = classifier;
    d.scope = MavenScope.getScope(scope);
    return d;
}
Also used : Program(aQute.maven.api.Program)

Example 4 with Program

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

the class RepoActions method addDependency.

private void addDependency(Archive archive, MavenScope scope) throws Exception {
    IPom pom = repo.storage.getPom(archive.revision);
    Map<Program, Dependency> dependencies = pom.getDependencies(scope, false);
    for (Dependency d : dependencies.values()) {
        BundleDescriptor add = repo.index.add(d.program.version(d.version).archive("jar", null));
        if (d.error != null)
            add.error = d.error;
    }
}
Also used : BundleDescriptor(aQute.bnd.repository.maven.provider.IndexFile.BundleDescriptor) Program(aQute.maven.api.Program) IPom(aQute.maven.api.IPom) Dependency(aQute.maven.api.IPom.Dependency)

Example 5 with Program

use of aQute.maven.api.Program 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

Program (aQute.maven.api.Program)8 Archive (aQute.maven.api.Archive)5 Revision (aQute.maven.api.Revision)5 File (java.io.File)4 Dependency (aQute.maven.api.IPom.Dependency)2 BundleDescriptor (aQute.bnd.repository.maven.provider.IndexFile.BundleDescriptor)1 MavenVersion (aQute.bnd.version.MavenVersion)1 IPom (aQute.maven.api.IPom)1 Release (aQute.maven.api.Release)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Properties (java.util.Properties)1