use of aQute.bnd.build.ProjectLauncher in project bndtools by bndtools.
the class AbstractOSGiLaunchDelegate method launch.
@Override
public void launch(ILaunchConfiguration configuration, String mode, final ILaunch launch, IProgressMonitor monitor) throws CoreException {
// Register listener to clean up temp files on exit of launched JVM
final ProjectLauncher launcher = getProjectLauncher();
IDebugEventSetListener listener = new IDebugEventSetListener() {
@Override
public void handleDebugEvents(DebugEvent[] events) {
for (DebugEvent event : events) {
if (event.getKind() == DebugEvent.TERMINATE) {
Object source = event.getSource();
if (source instanceof IProcess) {
ILaunch processLaunch = ((IProcess) source).getLaunch();
if (processLaunch == launch) {
// Not interested in any further events =>
// unregister this listener
DebugPlugin.getDefault().removeDebugEventListener(this);
// *may* cause LinkageErrors.
try {
launcher.cleanup();
} catch (Throwable t) {
logger.logError("Error cleaning launcher temporary files", t);
}
LaunchUtils.endRun((Run) launcher.getProject());
}
}
}
}
}
};
DebugPlugin.getDefault().addDebugEventListener(listener);
// Now actually launch
super.launch(configuration, mode, launch, monitor);
}
use of aQute.bnd.build.ProjectLauncher in project bnd by bndtools.
the class LauncherTest method testTimeoutActivator.
public static void testTimeoutActivator() throws Exception {
Project project = getProject();
project.clear();
ProjectLauncher l = project.getProjectLauncher();
l.setTimeout(100, TimeUnit.MILLISECONDS);
l.setTrace(false);
assertEquals(ProjectLauncher.TIMEDOUT, l.launch());
}
use of aQute.bnd.build.ProjectLauncher in project bnd by bndtools.
the class LauncherTest method testNoReferences.
public static void testNoReferences() throws Exception {
Project project = getProject();
project.setProperty("-runnoreferences", true + "");
ProjectLauncher l = project.getProjectLauncher();
l.setTrace(true);
l.getRunProperties().put("test.cmd", "noreference");
assertEquals(15, l.launch());
}
use of aQute.bnd.build.ProjectLauncher in project bnd by bndtools.
the class LauncherTest method testCleanup.
/**
* Tests if the properties are cleaned up. This requires some knowledge of
* the launcher unfortunately. It is also not sure if the file is not just
* deleted by the onExit ...
*
* @throws Exception
*/
public static void testCleanup() throws Exception {
Project project = getProject();
File target = project.getTarget();
IO.deleteWithException(target);
project.clear();
assertNoProperties(target);
final ProjectLauncher l = project.getProjectLauncher();
l.setTrace(true);
Thread t = new Thread() {
@Override
public void run() {
try {
Thread.sleep(1000);
l.cancel();
} catch (Exception e) {
// Ignore
}
}
};
t.start();
l.getRunProperties().put("test.cmd", "timeout");
l.launch();
assertNoProperties(target);
}
use of aQute.bnd.build.ProjectLauncher in project bnd by bndtools.
the class LauncherTest method testSpaces.
/**
* Try launching a workspace with spaces
*/
public static void testSpaces() throws Exception {
File f = new File("t m p");
try {
File cnf = new File(f, "cnf");
File demo = new File(f, "demo");
IO.copy(IO.getFile("../cnf"), IO.getFile(f, "cnf"));
IO.copy(IO.getFile("../demo"), IO.getFile(f, "demo"));
IO.copy(IO.getFile("../biz.aQute.launcher"), IO.getFile(f, "biz.aQute.launcher"));
IO.copy(IO.getFile("../biz.aQute.junit"), IO.getFile(f, "biz.aQute.junit"));
Workspace ws = Workspace.getWorkspace(f);
Project p = ws.getProject("demo");
p.setTrace(true);
p.build();
try {
ProjectLauncher l = p.getProjectLauncher();
l.setTrace(true);
l.getRunProperties().put("test.cmd", "exit");
assertEquals(42, l.launch());
} finally {
p.close();
ws.close();
}
} finally {
IO.delete(f);
}
}
Aggregations