use of aQute.bnd.build.Project in project bnd by bndtools.
the class LauncherTest method testRunKeep.
// public static void testLocalLaunch() throws Exception {
// Project project = getProject();
// ProjectLauncher l = project.getProjectLauncher();
// l.setTrace(true);
// l.getRunProperties().put("test.cmd", "exit");
// //assertTrue(project.check());
// assertEquals(42, l.start(null));
// }
/**
* Test if we can keep the framework state.
*/
public static void testRunKeep() throws Exception {
//
// First set persistence after clearing the storage
//
Project project = getProject();
project.setProperty("-runkeep", "false");
ProjectLauncher l = project.getProjectLauncher();
l.setTrace(true);
l.getRunProperties().put("test.cmd", "setpersistence");
assertEquals(55, l.launch());
//
// Check that we really clear by clearing and checking state
// this must fail with -2
//
project = getProject();
project.setProperty("-runkeep", "false");
l = project.getProjectLauncher();
l.setTrace(true);
l.getRunProperties().put("test.cmd", "getpersistence");
assertEquals(-2, l.launch());
//
// We now try to set the state again with a cleared framework
//
project = getProject();
project.setProperty("-runkeep", "false");
l = project.getProjectLauncher();
l.setTrace(true);
l.getRunProperties().put("test.cmd", "setpersistence");
assertEquals(55, l.launch());
//
// And now it should have been saved if we do not clear
// the framework
//
project = getProject();
project.setProperty("-runkeep", "true");
l = project.getProjectLauncher();
l.setTrace(true);
l.getRunProperties().put("test.cmd", "getpersistence");
assertEquals(65, l.launch());
}
use of aQute.bnd.build.Project in project bnd by bndtools.
the class LauncherTest method testSimple.
public static void testSimple() throws Exception {
Project project = getProject();
ProjectLauncher l = project.getProjectLauncher();
l.setTrace(true);
l.getRunProperties().put("test.cmd", "exit");
// assertTrue(project.check());
assertEquals(42, l.launch());
}
use of aQute.bnd.build.Project in project bnd by bndtools.
the class LauncherTest method testTester.
public static void testTester() throws Exception {
Project project = getProject();
project.clear();
project.build();
ProjectTester pt = project.getProjectTester();
pt.addTest("test.TestCase1");
pt.addTest("test.TestCase2:m1");
assertEquals(2, pt.test());
}
use of aQute.bnd.build.Project in project bndtools by bndtools.
the class BndtoolsBuilder method hasUpstreamChanges.
/*
* Check if any of the projects of which we depend has changes.
* We use the generated/buildfiles as the marker.
*/
private boolean hasUpstreamChanges() throws Exception {
for (IProject upstream : dependsOn) {
if (!upstream.exists())
continue;
Project up = Central.getProject(upstream);
if (up == null)
continue;
IResourceDelta delta = getDelta(upstream);
DeltaWrapper dw = new DeltaWrapper(up, delta, buildLog);
if (dw.hasBuildfile()) {
buildLog.full("Upstream project %s changed", up);
return true;
}
}
return false;
}
use of aQute.bnd.build.Project 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;
}
Aggregations