Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ajdt-dev] Finding build errors in IProject programatically

Hi Dawid,

I can't say exactly why this isn't working for you. I was just able to
reproduce something similar on my end.  One thing that comes to mind
is that are you sure the AJ build is actually occurring?  If there is
a classpath error, the AJBuilder may stop before completing the build,
whereas the JDT builder may be a little more robust.

If you can't get this working by looking at the project, another thing
try would be to use a ResourceVisitor and ask each compilation unit
directly for syntax errors.

something like

		public boolean visit(IResource resource) {
			if (resource.getType() == IResource.FILE) {
				// find markers
				return false;
			}
			return true;
		}


And you can be more sophisticated and only go down source folders and
only look at java/aj files.

Hope this helps.

On Sun, Mar 1, 2009 at 9:14 AM, Dawid Pytel <pytel.dawid@xxxxxxxxx> wrote:
> Hi,
>
> I'd like to write unit tests that will build some predefined
> AspectJ projects and test if there are no errors. I used
> org.eclipse.ajdt.core.tests and AJDTCoreTestCase as an example.
>
> I load and build projects using
> AJDTCoreTestCase.createPredefinedProject(...) method. It works but I
> can't get information about problems (e.g. syntax errors). I tried
> standard JDT way - using IMarker and findMarkes method:
>
> IProject project = createPredefinedProject("AspectJProject");
>
> System.out.println("Errors:");
> IMarker[] errors = project.findMarkers(null /*all markers*/, true,
>                IResource.DEPTH_INFINITE);
> for (IMarker error : errors) {
>        System.out.println(error.getAttribute(IMarker.MESSAGE));
> }
>
> I tested it on simple project with syntax error. When project is
> AspectJ Project no error appears. But after removing AspectJ
> capability the proper error (marker) is returned from findMarkers
> method.
>
> Inspecting code I found out that only classpath errors are notified
> using markers in AspectJ projects.
>
> My question: is there any way to get a list of compilation problems
> having only IProject element?
>
> Best regards,
>  David Pytel
>
> _______________________________________________
> ajdt-dev mailing list
> ajdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/ajdt-dev
>


Back to the top