Search in sources :

Example 76 with Workspace

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

the class PomRepositoryTest method testBndPomRepoFileMissingParent.

public void testBndPomRepoFileMissingParent() throws Exception {
    BndPomRepository bpr = new BndPomRepository();
    Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
    w.setBase(tmp);
    bpr.setRegistry(w);
    Map<String, String> config = new HashMap<>();
    config.put("pom", "testdata/pomrepo/missing-parent.xml");
    config.put("snapshotUrls", "https://repo1.maven.org/maven2/");
    config.put("releaseUrls", "https://repo1.maven.org/maven2/");
    config.put("name", "test");
    bpr.setProperties(config);
    try {
        bpr.list(null);
        fail("Should throw IllegalArgumentException on missing parent pom.");
    } catch (Exception iae) {
    // This exception is expected!
    }
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) Workspace(aQute.bnd.build.Workspace)

Example 77 with Workspace

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

the class PomRepositoryTest method testSearchRepoFailNoQuery.

public void testSearchRepoFailNoQuery() throws Exception {
    BndPomRepository mcsr = new BndPomRepository();
    Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
    w.setBase(tmp);
    mcsr.setRegistry(w);
    Map<String, String> config = new HashMap<>();
    config.put("name", "test");
    try {
        mcsr.setProperties(config);
        fail();
    } catch (Exception e) {
        assertEquals("Neither pom, revision nor query property are set", e.getMessage());
    }
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) Workspace(aQute.bnd.build.Workspace)

Example 78 with Workspace

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

the class PomRepositoryTest method testBndPomRepoFile.

public void testBndPomRepoFile() throws Exception {
    BndPomRepository bpr = new BndPomRepository();
    Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
    w.setBase(tmp);
    bpr.setRegistry(w);
    Map<String, String> config = new HashMap<>();
    config.put("pom", "testdata/pomrepo/simple.xml");
    config.put("snapshotUrls", "https://repo1.maven.org/maven2/");
    config.put("releaseUrls", "https://repo1.maven.org/maven2/");
    config.put("name", "test");
    bpr.setProperties(config);
    List<String> list = bpr.list(null);
    assertNotNull(list);
    assertEquals(1, list.size());
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) Workspace(aQute.bnd.build.Workspace)

Example 79 with Workspace

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

the class WorkspaceMainPart method initialize.

@Override
public void initialize(final IManagedForm form) {
    super.initialize(form);
    final Composite container = (Composite) getSection().getClient();
    // create a layout stack and the first visible component will be an empty component with "waiting" message
    // this will be replaced by real composite once workspace completes
    final StackLayout stackLayout = new StackLayout();
    container.setLayout(stackLayout);
    Composite labelParent = new Composite(container, SWT.NONE);
    FillLayout fillLayout = new FillLayout();
    fillLayout.marginHeight = fillLayout.marginWidth = 10;
    labelParent.setLayout(fillLayout);
    if (!Central.isWorkspaceInited()) {
        Label label = new Label(labelParent, SWT.NONE);
        label.setText("Workspace is loading, please wait...");
        label.setBackground(container.getBackground());
        label.setForeground(container.getForeground());
    }
    stackLayout.topControl = labelParent;
    container.layout();
    Central.onWorkspaceInit(new Success<Workspace, Void>() {

        @Override
        public Promise<Void> call(Promise<Workspace> resolved) throws Exception {
            final Deferred<Void> completion = new Deferred<>();
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    try {
                        IFile buildFile = Central.getWorkspaceBuildFile();
                        if (buildFile == null)
                            return;
                        Composite contents = new Composite(container, SWT.NONE);
                        if (!mainFile) {
                            ImageHyperlink link = form.getToolkit().createImageHyperlink(contents, SWT.CENTER);
                            link.setText("Open main build.bnd file.");
                            link.setImage(bndFileImg);
                            link.addHyperlinkListener(new FileOpenLinkListener(buildFile.getFullPath()));
                        } else {
                            IResource[] extFiles;
                            IContainer cnfDir = buildFile.getParent();
                            IFolder extDir = cnfDir.getFolder(new Path("ext"));
                            if (extDir.exists())
                                extFiles = extDir.members();
                            else
                                extFiles = new IResource[0];
                            if (extFiles.length > 0) {
                                for (IResource extFile : extFiles) {
                                    if (extFile.getType() == IResource.FILE && "bnd".equalsIgnoreCase(extFile.getFileExtension())) {
                                        ImageHyperlink link = form.getToolkit().createImageHyperlink(contents, SWT.CENTER);
                                        link.setText("Open " + extFile.getName());
                                        link.setImage(extFileImg);
                                        link.addHyperlinkListener(new FileOpenLinkListener(extFile.getFullPath()));
                                    }
                                }
                            } else {
                                createMissingExtsWarningPanel(contents, form.getToolkit(), extDir.getFullPath());
                            }
                        }
                        stackLayout.topControl = contents;
                        container.layout();
                        completion.resolve(null);
                    } catch (Exception e) {
                        Plugin.error(Collections.singletonList(e.getMessage()));
                        completion.fail(e);
                    }
                }
            });
            return completion.getPromise();
        }
    });
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) Deferred(org.osgi.util.promise.Deferred) Label(org.eclipse.swt.widgets.Label) FillLayout(org.eclipse.swt.layout.FillLayout) PartInitException(org.eclipse.ui.PartInitException) Promise(org.osgi.util.promise.Promise) StackLayout(org.eclipse.swt.custom.StackLayout) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) Workspace(aQute.bnd.build.Workspace) IFolder(org.eclipse.core.resources.IFolder)

Example 80 with Workspace

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

the class JpmDependencyWizardPage method runQuery.

private void runQuery() {
    if (!queried) {
        errorText = null;
        try {
            Workspace workspace = Central.getWorkspace();
            repository = workspace.getPlugin(SearchableRepository.class);
            if (repository == null)
                throw new Exception("No searchable repository is configured in the workspace. Try adding the JPM4J plugin.");
            QueryJpmDependenciesRunnable query = new QueryJpmDependenciesRunnable(originUri, repository);
            getContainer().run(true, true, query);
            queried = true;
            errorText = query.getError();
            directResources = query.getDirectResources();
            indirectResources = query.getIndirectResources();
            selectedIndirectResources = new HashSet<ResourceDescriptor>();
        } catch (InvocationTargetException e) {
            errorText = e.getCause().getMessage();
        } catch (InterruptedException e) {
        // ignore
        } catch (Exception e) {
            errorText = e.getMessage();
        } finally {
            updateUi();
        }
    }
}
Also used : SearchableRepository(aQute.bnd.service.repository.SearchableRepository) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Workspace(aQute.bnd.build.Workspace) ResourceDescriptor(aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)

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