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];
}
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;
}
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();
}
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;
}
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;
}
Aggregations