Search in sources :

Example 6 with Baseline

use of aQute.bnd.differ.Baseline in project bndtools by bndtools.

the class TreeContentProvider method getChildren.

@Override
public Object[] getChildren(Object parent) {
    if (parent instanceof List) {
        return ((List<?>) parent).toArray();
    }
    if (parent instanceof Baseline) {
        Collection<? extends Diff> diffs = ((Baseline) parent).getDiff().getChildren();
        List<Diff> filteredDiffs = new ArrayList<Diff>();
        for (Diff diff : diffs) {
            switch(diff.getType()) {
                case API:
                case MANIFEST:
                case RESOURCES:
                    if (getChildren(diff).length == 0)
                        continue;
                    break;
                default:
                    break;
            }
            filteredDiffs.add(diff);
        }
        return filteredDiffs.toArray(new Diff[0]);
    }
    if (parent instanceof Tree) {
        return ((Tree) parent).getChildren();
    }
    if (parent instanceof Diff) {
        return getChildren((Diff) parent);
    }
    return new Object[0];
}
Also used : Diff(aQute.bnd.service.diff.Diff) ArrayList(java.util.ArrayList) Tree(aQute.bnd.service.diff.Tree) List(java.util.List) ArrayList(java.util.ArrayList) Baseline(aQute.bnd.differ.Baseline)

Example 7 with Baseline

use of aQute.bnd.differ.Baseline in project bndtools by bndtools.

the class TreeLabelProvider method getImage.

@Override
public Image getImage(Object element) {
    if (element instanceof Baseline) {
        //$NON-NLS-1$
        return BundleTreeImages.resolveImage("bundle", ((Baseline) element).getDiff().getDelta().toString().toLowerCase(), null, null);
    }
    if (element instanceof Diff) {
        Diff tree = (Diff) element;
        String type = tree.getType().toString().toLowerCase();
        String strDelta = getDeltaString(tree);
        String impExp = null;
        if (tree.getType() == Type.PACKAGE) {
            //$NON-NLS-1$
            impExp = "export";
        } else if (tree.getType() == Type.RESOURCE) {
            String name = tree.getName();
            int idx = name.lastIndexOf('.');
            if (idx > -1) {
                //$NON-NLS-1$
                type = "dot_" + name.substring(idx + 1);
            }
        }
        return BundleTreeImages.resolveImage(type, strDelta, impExp, null);
    }
    if (element instanceof Tree) {
        Tree tree = (Tree) element;
        String type = tree.getType().toString().toLowerCase();
        String impExp = null;
        if (tree.getType() == Type.PACKAGE) {
            //$NON-NLS-1$
            impExp = "export";
        } else if (tree.getType() == Type.RESOURCE) {
            String name = tree.getName();
            int idx = name.lastIndexOf('.');
            if (idx > 0) {
                //$NON-NLS-1$
                type = "dot_" + name.substring(idx + 1);
            }
        }
        return BundleTreeImages.resolveImage(type, null, impExp, null);
    }
    return null;
}
Also used : Diff(aQute.bnd.service.diff.Diff) Tree(aQute.bnd.service.diff.Tree) Baseline(aQute.bnd.differ.Baseline)

Example 8 with Baseline

use of aQute.bnd.differ.Baseline in project bnd by bndtools.

the class DiffTest method testAPIStaticSuperClassChange.

public void testAPIStaticSuperClassChange() throws Exception {
    Jar older = new Jar(IO.getFile("../demo/generated/demo.jar"));
    Builder b = new Builder();
    b.addClasspath(IO.getFile("bin"));
    b.setExportPackage("test.api");
    b.build();
    assertTrue(b.check());
    Jar newer = b.getJar();
    Processor processor = new Processor();
    DiffPluginImpl differ = new DiffPluginImpl();
    Baseline baseline = new Baseline(processor, differ);
    Info info = baseline.baseline(newer, older, null).iterator().next();
    Diff field = info.packageDiff.get("test.api.B");
    show(field, 2);
    assertEquals(Delta.UNCHANGED, field.getDelta());
    b.close();
}
Also used : DiffPluginImpl(aQute.bnd.differ.DiffPluginImpl) Processor(aQute.bnd.osgi.Processor) Diff(aQute.bnd.service.diff.Diff) Builder(aQute.bnd.osgi.Builder) Jar(aQute.bnd.osgi.Jar) Baseline(aQute.bnd.differ.Baseline) Info(aQute.bnd.differ.Baseline.Info)

Example 9 with Baseline

use of aQute.bnd.differ.Baseline in project bndtools by bndtools.

the class WorkspaceAnalyserJob method run.

@Override
protected IStatus run(IProgressMonitor monitor) {
    IProgressMonitor mon = monitor;
    if (mon == null) {
        mon = new NullProgressMonitor();
    }
    try {
        Collection<Project> projects = Activator.getWorkspace().getAllProjects();
        mon.beginTask(Messages.workspaceReleaseJob, projects.size() * 2);
        List<Project> orderedProjects = getBuildOrder(mon, Activator.getWorkspace());
        if (mon.isCanceled()) {
            return Status.CANCEL_STATUS;
        }
        final List<ProjectDiff> projectDiffs = new ArrayList<ProjectDiff>();
        mon.setTaskName(Messages.processingProjects);
        for (Project project : orderedProjects) {
            IProject eProject = ReleaseUtils.getProject(project);
            if (!isIncluded(eProject)) {
                mon.worked(1);
                continue;
            }
            if ("".equals(project.getProperty(Constants.RELEASEREPO, null))) {
                mon.worked(1);
                continue;
            }
            if (eProject == null || !eProject.isOpen() || !eProject.isAccessible()) {
                mon.worked(1);
                continue;
            }
            List<Builder> builders = project.getBuilder(null).getSubBuilders();
            List<Baseline> jarDiffs = null;
            for (Builder b : builders) {
                mon.subTask(String.format(Messages.processingProject, b.getBsn()));
                Baseline jarDiff = DiffHelper.createBaseline(project, b.getBsn());
                if (jarDiff != null) {
                    if (jarDiffs == null) {
                        jarDiffs = new ArrayList<Baseline>();
                    }
                    jarDiffs.add(jarDiff);
                }
            }
            if (jarDiffs != null && jarDiffs.size() > 0) {
                projectDiffs.add(new ProjectDiff(project, jarDiffs));
            }
            if (mon.isCanceled()) {
                return Status.CANCEL_STATUS;
            }
            mon.worked(1);
        }
        if (projectDiffs.size() == 0) {
            Runnable runnable = new Runnable() {

                @Override
                public void run() {
                    MessageDialog.openInformation(shell, Messages.releaseWorkspaceBundles, Messages.noBundlesRequireRelease);
                }
            };
            if (Display.getCurrent() == null) {
                Display.getDefault().syncExec(runnable);
            } else {
                runnable.run();
            }
            return Status.OK_STATUS;
        }
        ReleaseHelper.initializeProjectDiffs(projectDiffs);
        Runnable runnable = new Runnable() {

            @Override
            public void run() {
                WorkspaceReleaseDialog dialog = new WorkspaceReleaseDialog(shell, projectDiffs, false);
                int ret = dialog.open();
                if (ret == WorkspaceReleaseDialog.OK) {
                    boolean runJob = false;
                    for (ProjectDiff diff : projectDiffs) {
                        if (diff.isRelease()) {
                            runJob = true;
                            break;
                        }
                    }
                    if (!runJob) {
                        return;
                    }
                    WorkspaceReleaseJob releaseJob = new WorkspaceReleaseJob(projectDiffs, dialog.getReleaseOption(), dialog.isShowMessage());
                    releaseJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
                    releaseJob.schedule();
                }
            }
        };
        if (Display.getCurrent() == null) {
            Display.getDefault().asyncExec(runnable);
        } else {
            runnable.run();
        }
    } catch (Exception e) {
        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
    }
    return Status.OK_STATUS;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Builder(aQute.bnd.osgi.Builder) ArrayList(java.util.ArrayList) WorkspaceReleaseDialog(bndtools.release.ui.WorkspaceReleaseDialog) Baseline(aQute.bnd.differ.Baseline) IProject(org.eclipse.core.resources.IProject) Project(aQute.bnd.build.Project) IProject(org.eclipse.core.resources.IProject) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)

Example 10 with Baseline

use of aQute.bnd.differ.Baseline in project bndtools by bndtools.

the class ReleaseHelper method getBsnsWithBundleVersionMacro.

public static List<MacroInfo> getBsnsWithBundleVersionMacro(List<ProjectDiff> projectDiffs) {
    List<MacroInfo> bsns = new ArrayList<MacroInfo>();
    for (ProjectDiff diff : projectDiffs) {
        if (diff.isRelease()) {
            for (Baseline baseline : diff.getBaselines()) {
                try {
                    Builder builder = diff.getProject().getSubBuilder(baseline.getBsn());
                    String bundleVersion = builder.getUnprocessedProperty(Constants.BUNDLE_VERSION, "");
                    if (bundleVersion.startsWith("${")) {
                        MacroInfo info = new MacroInfo();
                        info.projectDiff = diff;
                        info.bsn = builder.getBsn();
                        info.macro = bundleVersion;
                        bsns.add(info);
                    }
                } catch (Exception e) {
                }
            }
        }
    }
    return bsns;
}
Also used : Builder(aQute.bnd.osgi.Builder) ArrayList(java.util.ArrayList) Baseline(aQute.bnd.differ.Baseline) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

Baseline (aQute.bnd.differ.Baseline)27 Info (aQute.bnd.differ.Baseline.Info)15 DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)15 Jar (aQute.bnd.osgi.Jar)15 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)13 Processor (aQute.bnd.osgi.Processor)11 Builder (aQute.bnd.osgi.Builder)9 Diff (aQute.bnd.service.diff.Diff)6 ArrayList (java.util.ArrayList)5 ProjectBuilder (aQute.bnd.build.ProjectBuilder)4 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)2 Tree (aQute.bnd.service.diff.Tree)2 Version (aQute.bnd.version.Version)2 ReporterAdapter (aQute.libg.reporter.ReporterAdapter)2 WorkspaceReleaseDialog (bndtools.release.ui.WorkspaceReleaseDialog)2 IOException (java.io.IOException)2 List (java.util.List)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 Project (aQute.bnd.build.Project)1