Search in sources :

Example 21 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.

the class AetherRepsitoryTests method testSourceLookup.

public void testSourceLookup() throws Exception {
    RepositoryPlugin repo = createRepo();
    Map<String, String> attrs = new HashMap<String, String>();
    attrs.put("version", "2.5");
    attrs.put("bsn", "javax.servlet:servlet-api");
    File file = repo.get("servlet-api.source", new Version(2, 5, 0), attrs, listener);
    assertTrue(file.exists());
    assertEquals("servlet-api-2.5-sources.jar", file.getName());
}
Also used : HashMap(java.util.HashMap) Version(aQute.bnd.version.Version) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) File(java.io.File)

Example 22 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.

the class AetherRepsitoryTests method testVersionsGAVStyle.

public void testVersionsGAVStyle() throws Exception {
    RepositoryPlugin repo = createRepo();
    SortedSet<Version> versions = repo.versions("javax.servlet:servlet-api");
    assertNotNull(versions);
    assertTrue(versions.size() == 2);
    assertEquals("2.4.0", versions.first().toString());
    assertEquals("2.5.0", versions.last().toString());
}
Also used : Version(aQute.bnd.version.Version) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Example 23 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.

the class BndrunResolveContext method loadRepositories.

/**
	 * Load all the OSGi repositories from our registry
	 * <p>
	 * TODO Use Instruction ...
	 *
	 * @return
	 * @throws Exception
	 */
private Processor loadRepositories() throws Exception {
    //
    // Get all of the repositories from the plugin registry
    //
    List<Repository> allRepos = registry.getPlugins(Repository.class);
    Collection<Repository> orderedRepositories;
    String rn = properties.mergeProperties(Constants.RUNREPOS);
    if (rn == null) {
        //
        // No filter set, so we use all
        //
        orderedRepositories = allRepos;
    } else {
        Parameters repoNames = new Parameters(rn, project);
        // Map the repository names...
        Map<String, Repository> repoNameMap = new HashMap<String, Repository>(allRepos.size());
        for (Repository repo : allRepos) {
            String name;
            if (repo instanceof aQute.bnd.deployer.repository.wrapper.Plugin) {
                @SuppressWarnings("resource") aQute.bnd.deployer.repository.wrapper.Plugin wrapper = (aQute.bnd.deployer.repository.wrapper.Plugin) repo;
                wrapper.init();
                name = wrapper.toString();
            } else if (repo instanceof RepositoryPlugin) {
                name = ((RepositoryPlugin) repo).getName();
            } else {
                name = repo.toString();
            }
            repoNameMap.put(name, repo);
        }
        // Create the result list
        orderedRepositories = new ArrayList<>();
        for (String repoName : repoNames.keySet()) {
            Repository repo = repoNameMap.get(repoName);
            if (repo != null)
                orderedRepositories.add(repo);
        }
    }
    Processor repositoryAugments = findRepositoryAugments(orderedRepositories);
    Parameters augments = new Parameters(repositoryAugments.mergeProperties(Constants.AUGMENT), project);
    augments.putAll(new Parameters(properties.mergeProperties(Constants.AUGMENT), project));
    if (!augments.isEmpty()) {
        AggregateRepository aggregate = new AggregateRepository(orderedRepositories);
        AugmentRepository augment = new AugmentRepository(augments, aggregate);
        orderedRepositories = Collections.singleton((Repository) augment);
    }
    for (Repository repository : orderedRepositories) {
        super.addRepository(repository);
    }
    return repositoryAugments;
}
Also used : Parameters(aQute.bnd.header.Parameters) Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) AggregateRepository(aQute.bnd.osgi.repository.AggregateRepository) AggregateRepository(aQute.bnd.osgi.repository.AggregateRepository) Repository(org.osgi.service.repository.Repository) AugmentRepository(aQute.bnd.osgi.repository.AugmentRepository) AugmentRepository(aQute.bnd.osgi.repository.AugmentRepository) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Example 24 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.

the class LocalRepositorySelectionPage method setSelectedRepository.

private void setSelectedRepository(RepositoryPlugin item) {
    RepositoryPlugin old = selectedRepository;
    selectedRepository = item;
    propSupport.firePropertyChange(PROP_SELECTED_REPO, old, selectedRepository);
    getContainer().updateButtons();
}
Also used : RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Example 25 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.

the class LocalRepositorySelectionPage method createControl.

public void createControl(Composite parent) {
    setTitle("Select Local Repository");
    setMessage("Bundle will be imported into the selected repository.");
    Table table = new Table(parent, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    final TableViewer viewer = new TableViewer(table);
    viewer.setContentProvider(new RepositoryTreeContentProvider());
    viewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
    viewer.setFilters(new ViewerFilter[] { new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return (element instanceof RepositoryPlugin) && ((RepositoryPlugin) element).canWrite();
        }
    } });
    try {
        Workspace workspace = Central.getWorkspace();
        viewer.setInput(workspace);
        if (selectedRepository != null)
            viewer.setSelection(new StructuredSelection(selectedRepository));
        validate(workspace);
    } catch (Exception e) {
        logger.logError("Error querying local repositories", e);
        setErrorMessage("Error querying local repositories, see log for details.");
    }
    // LISTENERS
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            setSelectedRepository((RepositoryPlugin) selection.getFirstElement());
        }
    });
    viewer.addOpenListener(new IOpenListener() {

        public void open(OpenEvent evt) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            setSelectedRepository((RepositoryPlugin) selection.getFirstElement());
            IWizardPage nextPage = getNextPage();
            if (nextPage != null)
                getContainer().showPage(nextPage);
        }
    });
    setControl(table);
}
Also used : Table(org.eclipse.swt.widgets.Table) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) RepositoryTreeContentProvider(bndtools.model.repo.RepositoryTreeContentProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryTreeLabelProvider(bndtools.model.repo.RepositoryTreeLabelProvider) IOpenListener(org.eclipse.jface.viewers.IOpenListener) IWizardPage(org.eclipse.jface.wizard.IWizardPage) TableViewer(org.eclipse.jface.viewers.TableViewer) Workspace(aQute.bnd.build.Workspace) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Aggregations

RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)62 Version (aQute.bnd.version.Version)25 File (java.io.File)24 Workspace (aQute.bnd.build.Workspace)12 IOException (java.io.IOException)10 Project (aQute.bnd.build.Project)9 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 Jar (aQute.bnd.osgi.Jar)7 CoreException (org.eclipse.core.runtime.CoreException)7 RemoteRepositoryPlugin (aQute.bnd.service.RemoteRepositoryPlugin)5 VersionRange (aQute.bnd.version.VersionRange)5 Description (aQute.lib.getopt.Description)5 Parameters (aQute.bnd.header.Parameters)4 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStatus (org.eclipse.core.runtime.IStatus)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 PartInitException (org.eclipse.ui.PartInitException)4 Attrs (aQute.bnd.header.Attrs)3