Quantcast

Wait for build to complete and check if errors

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Wait for build to complete and check if errors

Derek Morris-2
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,
--
Subs
_______________________________________________
cdt-dev mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Wait for build to complete and check if errors

Wieant Nielander
> 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?

As far as I can see the workspace.build() call is not asynchronous,
isn't the problem perhaps that you are doing a CLEAN_BUILD. This
normally only clears the build state for a project, but if you happen to
have 'Build Automatically' enabled it probably does trigger a build that
appears to be asynchronous.
_______________________________________________
cdt-dev mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Wait for build to complete and check if errors

Alex Chapiro-3
In reply to this post by Derek Morris-2
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,

_______________________________________________
cdt-dev mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Wait for build to complete and check if errors

Derek Morris-2
Wieant, Alex,

Thank for your information. The code below was just what I needed.

Thanks,

Alex Chapiro wrote:

> 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,
>
> _______________________________________________
> cdt-dev mailing list
> [hidden email]
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>


--
Subs
_______________________________________________
cdt-dev mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Loading...