Search in sources :

Example 1 with MavenRepository

use of aQute.maven.provider.MavenRepository in project bnd by bndtools.

the class PomRepositoryTest method getRepo.

MavenRepository getRepo() throws Exception {
    List<MavenBackingRepository> central = MavenBackingRepository.create("https://repo1.maven.org/maven2/", reporter, localRepo, client);
    List<MavenBackingRepository> apache = MavenBackingRepository.create("https://repository.apache.org/content/groups/snapshots/", reporter, localRepo, client);
    MavenRepository mr = new MavenRepository(localRepo, "test", central, apache, Processor.getExecutor(), reporter, null);
    return mr;
}
Also used : MavenBackingRepository(aQute.maven.provider.MavenBackingRepository) MavenRepository(aQute.maven.provider.MavenRepository)

Example 2 with MavenRepository

use of aQute.maven.provider.MavenRepository 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 3 with MavenRepository

use of aQute.maven.provider.MavenRepository in project bnd by bndtools.

the class MavenBndRepository method init.

private synchronized void init() {
    try {
        if (inited)
            return;
        client = registry.getPlugin(HttpClient.class);
        inited = true;
        name = configuration.name("Maven");
        localRepo = IO.getFile(configuration.local(MAVEN_REPO_LOCAL));
        List<MavenBackingRepository> release = MavenBackingRepository.create(configuration.releaseUrl(), reporter, localRepo, client);
        List<MavenBackingRepository> snapshot = MavenBackingRepository.create(configuration.snapshotUrl(), reporter, localRepo, client);
        storage = new MavenRepository(localRepo, getName(), release, snapshot, Processor.getExecutor(), reporter, getRefreshCallback());
        File base = IO.work;
        if (registry != null) {
            Workspace ws = registry.getPlugin(Workspace.class);
            if (ws != null)
                base = ws.getBuildDir();
        }
        File indexFile = IO.getFile(base, configuration.index(name.toLowerCase() + ".mvn"));
        IndexFile ixf = new IndexFile(reporter, indexFile, storage);
        ixf.open();
        this.index = ixf;
        startPoll(index);
        logger.debug("initing {}", this);
    } catch (Exception e) {
        reporter.exception(e, "Init for maven repo failed %s", configuration);
        throw new RuntimeException(e);
    }
}
Also used : MavenBackingRepository(aQute.maven.provider.MavenBackingRepository) MavenRepository(aQute.maven.provider.MavenRepository) HttpClient(aQute.bnd.http.HttpClient) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) Workspace(aQute.bnd.build.Workspace)

Example 4 with MavenRepository

use of aQute.maven.provider.MavenRepository in project bnd by bndtools.

the class BndPomRepository method init.

public synchronized void init() {
    try {
        if (inited)
            return;
        inited = true;
        Workspace workspace = registry.getPlugin(Workspace.class);
        HttpClient client = registry.getPlugin(HttpClient.class);
        File localRepo = IO.getFile(configuration.local(MAVEN_REPO_LOCAL));
        File location = workspace.getFile(getLocation());
        List<MavenBackingRepository> release = MavenBackingRepository.create(configuration.releaseUrls(), reporter, localRepo, client);
        List<MavenBackingRepository> snapshot = MavenBackingRepository.create(configuration.snapshotUrls(), reporter, localRepo, client);
        MavenRepository repository = new MavenRepository(localRepo, name, release, snapshot, Processor.getExecutor(), reporter, null);
        boolean transitive = configuration.transitive(true);
        if (pomFiles != null) {
            repoImpl = new PomRepository(repository, client, location, transitive).uris(pomFiles);
        } else if (revisions != null) {
            repoImpl = new PomRepository(repository, client, location, transitive).revisions(revisions);
        } else if (query != null) {
            repoImpl = new SearchRepository(repository, location, query, queryUrl, workspace, client, transitive);
        } else {
            repository.close();
            throw new IllegalStateException("We have neither a pom, revision, or query set!");
        }
        bridge = new BridgeRepository(repoImpl);
    } catch (Exception e) {
        throw Exceptions.duck(e);
    }
}
Also used : BridgeRepository(aQute.bnd.osgi.repository.BridgeRepository) MavenBackingRepository(aQute.maven.provider.MavenBackingRepository) MavenRepository(aQute.maven.provider.MavenRepository) HttpClient(aQute.bnd.http.HttpClient) File(java.io.File) Workspace(aQute.bnd.build.Workspace)

Example 5 with MavenRepository

use of aQute.maven.provider.MavenRepository 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

MavenRepository (aQute.maven.provider.MavenRepository)6 HttpClient (aQute.bnd.http.HttpClient)4 Revision (aQute.maven.api.Revision)3 MavenBackingRepository (aQute.maven.provider.MavenBackingRepository)3 Resource (org.osgi.resource.Resource)3 Workspace (aQute.bnd.build.Workspace)2 Archive (aQute.maven.api.Archive)2 File (java.io.File)2 BridgeRepository (aQute.bnd.osgi.repository.BridgeRepository)1 XMLResourceParser (aQute.bnd.osgi.repository.XMLResourceParser)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1