[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| 
Re: [cdt-dev] Wait for build to complete and check if errors
 | 
You can use something like that:
    public static boolean buildAndWaitForEnd() {
        IProgressService progressService = workbench.getProgressService();
        final IRunnableWithProgress runnable = new 
IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws 
InvocationTargetException {
            IJobManager jobManager = Job.getJobManager();
            IWorkbench workbench = PlatformUI.getWorkbench();
                try {
ResourcesPlugin.getWorkSpace().build(IncrementalProjectBuilder.FULL_BUILD, 
monitor);
                } catch (CoreException e) {
                    throw new InvocationTargetException(e);
                }
                if (!monitor.isCanceled()) {
                    try {
jobManager.join(ResourcesPlugin.FAMILY_MANUAL_BUILD, monitor);
jobManager.join(ResourcesPlugin.FAMILY_AUTO_BUILD, monitor);
                    } catch (InterruptedException e) {
                        // continue
                    }
                }
            }
        };
        try {
            progressService.busyCursorWhile(runnable);
            return true;
        }
        .....
        return false;
    }
If you initiated your build indirectly (as an AUTO_BUILD, you have to 
correct a bit this code.
Subs wrote:
Hi,
In my plugin, I have created some C/C++ projects (essentially, an
Import) and then build the workspace using:
  workspace.build(IncrementalProjectBuilder.CLEAN_BUILD, monitor).
I want to wait for the build to complete and then check to see if
there were any build errors. How can I detect when the build has
completed? The call above starts a build asynchronously.
To check for errors, I am iterating through each project in the
workspace and calling:
  project.findMaxProblemSeverity();
Is this the 'right' way to check for build errors? Is there a better way?
Thanks,