Search in sources :

Example 6 with Revision

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

the class BndPomRepository method setProperties.

@Override
public void setProperties(Map<String, String> map) throws Exception {
    configuration = Converter.cnv(PomConfiguration.class, map);
    if (configuration.name() == null)
        throw new IllegalArgumentException("Must get a name");
    this.name = configuration.name();
    if (configuration.pom() != null) {
        List<String> parts = Strings.split(configuration.pom());
        pomFiles = new ArrayList<>();
        for (String part : parts) {
            File f = IO.getFile(part);
            if (f.isFile()) {
                pomFiles.add(f.toURI());
            } else {
                pomFiles.add(URI.create(part));
            }
        }
        if (pomFiles.isEmpty()) {
            throw new IllegalArgumentException("Pom is neither a file nor a revision " + configuration.pom());
        }
    } else if (configuration.revision() != null) {
        List<String> parts = Strings.split(configuration.revision());
        revisions = new ArrayList<>();
        for (String part : parts) {
            Revision revision = Revision.valueOf(part);
            if (revision != null) {
                revisions.add(revision);
            }
        }
        if (revisions.isEmpty()) {
            throw new IllegalArgumentException("Revision is neither a file nor a revision " + configuration.revision());
        }
    } else if (configuration.query() != null) {
        this.query = configuration.query();
        this.queryUrl = configuration.queryUrl("http://search.maven.org/solrsearch/select");
    } else {
        throw new IllegalArgumentException("Neither pom, revision nor query property are set");
    }
    inited = false;
}
Also used : Revision(aQute.maven.api.Revision) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Example 7 with Revision

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

the class MavenRepoTest method testBasicSnapshotRelease.

public void testBasicSnapshotRelease() throws Exception {
    File fpom = IO.getFile(local, "commons-cli/commons-cli/1.4-SNAPSHOT/commons-cli-1.4-SNAPSHOT.pom");
    File rpom = IO.getFile(remote, "commons-cli/commons-cli/1.4-SNAPSHOT/commons-cli-1.4-19700101.000010-10.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());
    Release r = storage.release(revision, new Properties());
    r.setBuild(10000, null);
    r.add("pom", null, new ByteArrayInputStream(new byte[0]));
    r.close();
    assertTrue(fpom.isFile());
    assertTrue(rpom.isFile());
}
Also used : Program(aQute.maven.api.Program) Archive(aQute.maven.api.Archive) Revision(aQute.maven.api.Revision) ByteArrayInputStream(java.io.ByteArrayInputStream) Properties(java.util.Properties) File(java.io.File) Release(aQute.maven.api.Release)

Example 8 with Revision

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

the class MavenRepoTest method testImmutable.

public void testImmutable() throws Exception {
    File fpom = IO.getFile(local, "commons-cli/commons-cli/1.2/commons-cli-1.2.pom");
    Program program = Program.valueOf("commons-cli", "commons-cli");
    Revision revision = Program.valueOf("commons-cli", "commons-cli").version("1.2");
    Archive apom = revision.archive("pom", null);
    assertFalse(fpom.exists());
    Archive rapom = storage.resolveSnapshot(apom);
    assertTrue(rapom.isResolved());
    assertEquals(rapom, apom);
    File f = storage.get(rapom).getValue();
    assertEquals(fpom, f);
    assertRecent(f);
    f.setLastModified(10000);
    f = storage.get(rapom).getValue();
    assertEquals(fpom, f);
    assertEquals(10000L, f.lastModified());
}
Also used : Program(aQute.maven.api.Program) Archive(aQute.maven.api.Archive) Revision(aQute.maven.api.Revision) File(java.io.File)

Example 9 with Revision

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

the class CentralTest method testBasic.

public void testBasic() throws Exception {
    Revision r = Program.valueOf("org.lunarray.model.extensions.descriptor", "spring").version("1.0");
    POM pom = storage.getPom(r);
    assertNotNull(pom);
    System.out.println(pom.getDependencies(MavenScope.compile, true));
}
Also used : Revision(aQute.maven.api.Revision)

Example 10 with Revision

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

the class PomRepositoryTest method testPomTransitive.

public void testPomTransitive() throws Exception {
    MavenRepository mr = getRepo();
    Revision revision = Program.valueOf("org.apache.aries.blueprint", "org.apache.aries.blueprint.cm").version("1.0.8");
    Traverser t = new Traverser(mr, new HttpClient(), Processor.getExecutor(), true).revision(revision);
    Map<Archive, Resource> value = t.getResources().getValue();
    assertEquals(8, value.size());
    assertAllBndCap(value);
}
Also used : Archive(aQute.maven.api.Archive) MavenRepository(aQute.maven.provider.MavenRepository) Revision(aQute.maven.api.Revision) HttpClient(aQute.bnd.http.HttpClient) Resource(org.osgi.resource.Resource)

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