javaeclipseantcoding-stylecompilationunit

Eclipse Java Compiler Warnings as ant task


I want the eclipse Java Compiler Warnings available as an ant task (ie without eclipse) - ideally as ant plugins - but I want the cruise control ant task to fail if an eclipse warning shows up. For the following warnings

I assume this means that the eclipse abstract syntax tree would have to be used - and an eclipse compilation unit would have to be created.

The question is: (1) Has this been done? (2) If it hasn't - then given a

org.eclipse.jdt.core.dom.CompilationUnit

object - how do you (ie in code examples) get the warnings out of this CompilationUnit?

(I KNOW about PMD, checkstyle etc - none of these EXACTLY match the eclipse preferences for coding style. I want an ant task that exactly matches the eclipse coding style)


Solution

  • What version of eclipse?

    It is possible to launch the JDT compiler via ant. See:

    http://help.eclipse.org/ganymede/topic/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm

    See 'Using the ant javac adapter'

    Warnings and errors are attached to resources (such as files or CompilationUnits) in the Eclipse workspace. They are known as 'markers'. It may be easier to get the warnings as markers rather than via the compilation process directly.

    Another avenue to look into is launching a PDE build but I think this is overkill for your requirements and such build scripts can get very difficult to maintain with time.