我正在 Eclipse 中创建一个动态 IProject。这个 IProject 的行为类似于 eclipse 中的“带有 JAR 档案的新插件”项目。然后我指向这个外部jar文件的引用。顺便说一句,我提取然后链接到临时 IProject。
<linkedResources>
<link>
<name>SampleTestSuite</name>
<type>2</type>
<location>D:/eclipse-rcp-indigo/tests/SampleTestSuite</location>
</link>
</linkedResources>
现在,我打算制作这个 IProject Run-As JUnit。我想在 JUnit 之后删除提取和链接的 jar 文件。这是我在下面运行 JUnit 的代码,但在文件删除后它会抛出错误,因为linkedresource 将不存在。任何想法如何监视 JUnit 是否已经完成以便删除链接资源?
Activator.getDisplay().syncExec(new Runnable() {
public void run() {
Job job = new Job("Test Runner JUnit") {
@Override
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask("Launching JUnit", 100);
try {
ILaunch launch = new Launch(launchConfiguration,
"run", null);
launch.setAttribute(
"org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING",
DebugPlugin.getDefault().getLaunchManager()
.getEncoding(launchConfiguration));
DebugPlugin.getDefault().getLaunchManager()
.addLaunch(launch);
launchDelegate.launch(launchConfiguration, "run",
launch, monitor);
} catch (CoreException e) {
return e.getStatus();
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
job.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
System.out.println("Job completed successfully");
// delete the file here
} else
System.out
.println("Job did not complete successfully");
}
});
job.setPriority(Job.INTERACTIVE);
job.schedule();
}
});