Search in sources :

Example 61 with Workspace

use of aQute.bnd.build.Workspace 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)

Example 62 with Workspace

use of aQute.bnd.build.Workspace in project bndtools by bndtools.

the class MapValuesContentProvider method refreshBundleList.

protected void refreshBundleList() throws Exception {
    Workspace workspace = Central.getWorkspace();
    workspace.refresh();
    availableViewer.setInput(RepositoryUtils.listRepositories(workspace, true));
}
Also used : Workspace(aQute.bnd.build.Workspace)

Example 63 with Workspace

use of aQute.bnd.build.Workspace in project bnd by bndtools.

the class IndexedReposWithComms method testIndexedRepo.

/*
	 * Uses workspaces/indexed Sets up a FixedIndexedRepo to the local server.
	 */
public void testIndexedRepo() throws IOException, Exception {
    try (HttpTestServer ht = http()) {
        createSecureSocks5();
        Workspace ws = Workspace.getWorkspace(aQute.lib.io.IO.getFile("workspaces/indexed"));
        assertNotNull(ws);
        ws.setProperty("repo", ht.getBaseURI().toASCIIString() + "/index");
        FixedIndexedRepo plugin = ws.getPlugin(FixedIndexedRepo.class);
        assertTrue(ws.check());
        assertNotNull(plugin);
        List<String> list = plugin.list(null);
        assertTrue(ws.check());
        assertTrue(list.size() > 0);
    }
}
Also used : HttpTestServer(aQute.http.testservers.HttpTestServer) FixedIndexedRepo(aQute.bnd.deployer.repository.FixedIndexedRepo) Workspace(aQute.bnd.build.Workspace)

Example 64 with Workspace

use of aQute.bnd.build.Workspace in project bnd by bndtools.

the class IndexedReposWithComms method testIndexedRepoWithPassword.

/*
	 * Uses workspaces/indexed Sets up a FixedIndexedRepo to the local server.
	 */
public void testIndexedRepoWithPassword() throws IOException, Exception {
    try (HttpTestServer ht = https()) {
        createSecureSocks5();
        Workspace ws = Workspace.getWorkspace(aQute.lib.io.IO.getFile("workspaces/indexed"));
        assertNotNull(ws);
        ws.setProperty("-connection-settings", "${build}/settings-withpassword.xml");
        ws.setProperty("repo", ht.getBaseURI().toASCIIString() + "/index-auth/user/good");
        FixedIndexedRepo plugin = ws.getPlugin(FixedIndexedRepo.class);
        assertTrue(ws.check());
        assertNotNull(plugin);
        List<String> list = plugin.list(null);
        assertTrue(ws.check());
        assertTrue(list.size() > 0);
    }
}
Also used : HttpTestServer(aQute.http.testservers.HttpTestServer) FixedIndexedRepo(aQute.bnd.deployer.repository.FixedIndexedRepo) Workspace(aQute.bnd.build.Workspace)

Example 65 with Workspace

use of aQute.bnd.build.Workspace in project bnd by bndtools.

the class MavenTest method testMavenRepo.

/**
	 * See if we can create a maven repostory as a plugin
	 * 
	 * @throws Exception
	 */
public static void testMavenRepo() throws Exception {
    Workspace ws = Workspace.getWorkspace(cwd.getParentFile());
    Maven maven = ws.getMaven();
    Processor processor = new Processor(ws);
    processor.setProperty(Constants.PLUGIN, "aQute.bnd.maven.support.MavenRemoteRepository;repositories=testresources/ws/maven1/m2");
    MavenRemoteRepository mr = processor.getPlugin(MavenRemoteRepository.class);
    assertNotNull(mr);
    assertEquals(maven, mr.getMaven());
    // Cleanup the maven cache so we do not get random results
    MavenEntry me = maven.getEntry("org.apache.commons", "com.springsource.org.apache.commons.beanutils", "1.6.1");
    assertNotNull(me);
    me.remove();
    Map<String, String> map = MAP.$("groupId", "org.apache.commons");
    File file = mr.get("com.springsource.org.apache.commons.beanutils", "1.6.1", Strategy.LOWEST, map);
    assertNotNull(file);
    assertEquals("com.springsource.org.apache.commons.beanutils-1.6.1.jar", file.getName());
    assertTrue(file.isFile());
    Map<String, String> map2 = MAP.$("groupId", "org.apache.commons").$("scope", "compile");
    file = mr.get("com.springsource.org.apache.commons.beanutils", "1.6.1", Strategy.LOWEST, map2);
    assertNotNull(file);
    assertTrue(file.isFile());
    assertEquals("compile.lib", file.getName());
    String lib = IO.collect(file);
    System.err.println(lib);
    lib = lib.replaceAll("org.apache.commons\\+com.springsource.org.apache.commons.beanutils;version=\"1.6.1\"", "1");
    lib = lib.replaceAll("org.apache.commons\\+com.springsource.org.apache.commons.collections;version=\"2.1.1\"", "2");
    lib = lib.replaceAll("org.apache.commons\\+com.springsource.org.apache.commons.logging;version=\"1.0.4\"", "3");
    assertEquals("1\n2\n3\n", lib);
}
Also used : Maven(aQute.bnd.maven.support.Maven) Processor(aQute.bnd.osgi.Processor) MavenRemoteRepository(aQute.bnd.maven.support.MavenRemoteRepository) MavenEntry(aQute.bnd.maven.support.MavenEntry) File(java.io.File) Workspace(aQute.bnd.build.Workspace)

Aggregations

Workspace (aQute.bnd.build.Workspace)164 Project (aQute.bnd.build.Project)69 File (java.io.File)62 Processor (aQute.bnd.osgi.Processor)26 IOException (java.io.IOException)20 HashMap (java.util.HashMap)20 Container (aQute.bnd.build.Container)15 ArrayList (java.util.ArrayList)15 Version (aQute.bnd.version.Version)13 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)12 IProject (org.eclipse.core.resources.IProject)10 Run (aQute.bnd.build.Run)9 CoreException (org.eclipse.core.runtime.CoreException)9 Description (aQute.lib.getopt.Description)7 Collection (java.util.Collection)6 BndEditModel (aQute.bnd.build.model.BndEditModel)5 Jar (aQute.bnd.osgi.Jar)5 HttpTestServer (aQute.http.testservers.HttpTestServer)5 BuildException (org.apache.tools.ant.BuildException)5 IResource (org.eclipse.core.resources.IResource)5