use of org.eclipse.core.resources.WorkspaceJob in project bndtools by bndtools.
the class CnfWatcher method processEvent.
private void processEvent(IResourceChangeEvent event) {
try {
final Workspace workspace = Central.getWorkspaceIfPresent();
if (workspace == null) {
// this can happen during first project creation in an empty workspace
logger.logInfo("Unable to get workspace", null);
return;
}
final IProject cnfProject = WorkspaceUtils.findCnfProject(ResourcesPlugin.getWorkspace().getRoot(), workspace);
if (cnfProject == null)
return;
IResourceDelta delta = event.getDelta();
if (delta.findMember(cnfProject.getFullPath()) == null)
return;
Collection<Project> allProjects = workspace.getAllProjects();
if (allProjects.isEmpty())
return;
Project p = allProjects.iterator().next();
DeltaWrapper dw = new DeltaWrapper(p, delta, new BuildLogger(0));
if (dw.hasCnfChanged()) {
workspace.clear();
workspace.forceRefresh();
workspace.getPlugins();
BndtoolsBuilder.dirty.addAll(allProjects);
WorkspaceJob j = new WorkspaceJob("Update errors on workspace") {
@Override
public IStatus runInWorkspace(IProgressMonitor arg0) throws CoreException {
try {
MarkerSupport ms = new MarkerSupport(cnfProject);
ms.deleteMarkers("*");
ms.setMarkers(workspace, BndtoolsConstants.MARKER_BND_WORKSPACE_PROBLEM);
return Status.OK_STATUS;
} catch (Exception e) {
return new Status(IStatus.ERROR, BndtoolsBuilder.PLUGIN_ID, "updating errors for workspace", e);
}
}
};
j.schedule();
}
} catch (Exception e) {
logger.logError("Detecting changes in cnf failed, ignoring", e);
}
}
use of org.eclipse.core.resources.WorkspaceJob in project bndtools by bndtools.
the class BndConfigurator method getBuildParticipant.
@Override
public AbstractBuildParticipant getBuildParticipant(final IMavenProjectFacade projectFacade, MojoExecution execution, IPluginExecutionMetadata executionMetadata) {
return new MojoExecutionBuildParticipant(execution, true, true) {
@Override
public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception {
// build mojo like normal
final Set<IProject> build = super.build(kind, monitor);
// now we make sure jar is built in separate job, doing this during maven builder will throw lifecycle errors
new WorkspaceJob("Executing " + projectFacade.getProject().getName() + " jar:jar goal") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
execJarMojo(projectFacade, monitor);
projectFacade.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
return Status.OK_STATUS;
}
}.schedule();
return build;
}
};
}
use of org.eclipse.core.resources.WorkspaceJob in project bndtools by bndtools.
the class AddFilesToRepositoryWizard method performFinish.
@Override
public boolean performFinish() {
WorkspaceJob job = new WorkspaceJob("Adding files to repository") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
return performFinishAddFiles(monitor);
}
};
job.schedule();
return true;
}
Aggregations