Search in sources :

Example 1 with BridgeRepository

use of aQute.bnd.osgi.repository.BridgeRepository in project bnd by bndtools.

the class FileSetRepository method readFiles.

private Promise<BridgeRepository> readFiles() {
    List<Promise<Resource>> promises = new ArrayList<>(getFiles().size());
    for (File file : getFiles()) {
        promises.add(parse(Promises.resolved(file)));
    }
    Promise<List<Resource>> all = Promises.all(promises);
    return all.map(new Function<List<Resource>, BridgeRepository>() {

        @Override
        public BridgeRepository apply(List<Resource> resources) {
            try {
                ResourcesRepository rr = new ResourcesRepository();
                for (Resource r : resources) {
                    if (r != null) {
                        logger.debug("{}: adding resource {}", getName(), r);
                        rr.add(r);
                    }
                }
                return new BridgeRepository(rr);
            } catch (Exception e) {
                throw Exceptions.duck(e);
            }
        }
    });
}
Also used : ArrayList(java.util.ArrayList) Resource(org.osgi.resource.Resource) BridgeRepository(aQute.bnd.osgi.repository.BridgeRepository) DownloadListenerPromise(aQute.bnd.util.repository.DownloadListenerPromise) Promise(org.osgi.util.promise.Promise) ArrayList(java.util.ArrayList) List(java.util.List) JarFile(java.util.jar.JarFile) File(java.io.File) ResourcesRepository(aQute.bnd.osgi.repository.ResourcesRepository)

Example 2 with BridgeRepository

use of aQute.bnd.osgi.repository.BridgeRepository in project bnd by bndtools.

the class BndPomRepository method refresh.

@Override
public boolean refresh() throws Exception {
    init();
    repoImpl.refresh();
    bridge = new BridgeRepository(repoImpl);
    return true;
}
Also used : BridgeRepository(aQute.bnd.osgi.repository.BridgeRepository)

Example 3 with BridgeRepository

use of aQute.bnd.osgi.repository.BridgeRepository in project bnd by bndtools.

the class OSGiIndex method readIndexes.

private Promise<BridgeRepository> readIndexes(boolean refresh) throws Exception {
    List<Promise<List<Resource>>> promises = new ArrayList<>(getURIs().size());
    for (URI uri : getURIs()) {
        promises.add(download(uri, refresh));
    }
    Promise<List<List<Resource>>> all = Promises.all(promises);
    return all.map(new Function<List<List<Resource>>, BridgeRepository>() {

        @Override
        public BridgeRepository apply(List<List<Resource>> resources) {
            try {
                ResourcesRepository rr = new ResourcesRepository();
                for (List<Resource> p : resources) {
                    rr.addAll(p);
                }
                return new BridgeRepository(rr);
            } catch (Exception e) {
                throw Exceptions.duck(e);
            }
        }
    });
}
Also used : ArrayList(java.util.ArrayList) Resource(org.osgi.resource.Resource) URI(java.net.URI) BridgeRepository(aQute.bnd.osgi.repository.BridgeRepository) Promise(org.osgi.util.promise.Promise) ArrayList(java.util.ArrayList) List(java.util.List) ResourcesRepository(aQute.bnd.osgi.repository.ResourcesRepository)

Example 4 with BridgeRepository

use of aQute.bnd.osgi.repository.BridgeRepository in project bnd by bndtools.

the class P2Indexer method refresh.

public void refresh() throws Exception {
    Repository repository = readRepository();
    save(repository);
    this.bridge = new BridgeRepository(repository);
}
Also used : BridgeRepository(aQute.bnd.osgi.repository.BridgeRepository) Repository(org.osgi.service.repository.Repository) ResourcesRepository(aQute.bnd.osgi.repository.ResourcesRepository) BridgeRepository(aQute.bnd.osgi.repository.BridgeRepository)

Example 5 with BridgeRepository

use of aQute.bnd.osgi.repository.BridgeRepository 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)

Aggregations

BridgeRepository (aQute.bnd.osgi.repository.BridgeRepository)5 ResourcesRepository (aQute.bnd.osgi.repository.ResourcesRepository)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Resource (org.osgi.resource.Resource)2 Promise (org.osgi.util.promise.Promise)2 Workspace (aQute.bnd.build.Workspace)1 HttpClient (aQute.bnd.http.HttpClient)1 DownloadListenerPromise (aQute.bnd.util.repository.DownloadListenerPromise)1 MavenBackingRepository (aQute.maven.provider.MavenBackingRepository)1 MavenRepository (aQute.maven.provider.MavenRepository)1 URI (java.net.URI)1 JarFile (java.util.jar.JarFile)1 Repository (org.osgi.service.repository.Repository)1