Eclipse JDT-APT Project
What is the JDT-APT project?
The JDT-APT project provides plugins that add Java 5 annotation processing support to Eclipse. A Java annotation processor is a compiler plug-in that can gather information about source code as it is being compiled, generate additional Java types or other resource files, and post warnings and errors. Eclipse 3.2 provided support for annotation processors using the Java 5 Mirror APIs, and Eclipse 3.3 added support for processors using the Java 6 annotation processing APIs.
You can view the presentation given at JavaOne 2005 during a session on APT that describes some of the goals and technical details here. At EclipseCon 2006 we made a presentation on APT do's and don'ts, and at EclipseCon 2007 this was developed into a tutorial on writing annotation processors for Eclipse, including some sample code and more discussion of techniques to achieve good performance. At EclipseCon 2008 we gave a presentation on annotations (which briefly mentions annotation processors but does not go into depth) that may be of interest to those looking for background material or for alternative strategies to annotation processing.
Additional frequently asked questions and their answers can be found in our FAQ.
What is APT?
APT stands for Annotation Processing Tool. Sun shipped an API for APT in JDK 1.5, which can be viewed at http://java.sun.com/j2se/1.5.0/docs/guide/apt/mirror/index.html. Sun also included a commandline implementation of APT in JDK 1.5. You can find documentation for it at http://java.sun.com/j2se/1.5.0/docs/guide/apt/index.html. In JDK 6, the API was modified considerably and standardized through JSR-269, and the Sun implementation was built into the javac compiler rather than requiring a standalone tool.
To quote from Sun's documentation:
apt is a command-line utility for annotation processing. It includes
a set of reflective APIs and supporting infrastructure to process
program annotations (JSR 175). These reflective APIs provide a
build-time, source-based, read-only view of program structure. They
are designed to cleanly model the JavaTM
programming language's type system after the addition of
generics (JSR 14).
So, APT provides a means for generating files and compiling new java classes based on annotations found in your source code.
JDT-APT is not based on Sun's implementation, but rather is a separate implementation of the APT APIs that runs entirely within Eclipse.
How do I get started?
If all you need to do is use an annotation processor, you may not need to do anything at all! Many project creation wizards will automatically install and enable the necessary processors. To check whether this is the case, or to install and enable your own processors, use the Java Compiler > Annotation Processing pane of the project properties.
For details, see the Getting Started guide in the Eclipse documentation (Help > Help Contents > JDT Plug-in Developer Guide > Programmer's Guide > JDT Annotation Processing).
How can I contribute?
If you're interested in contributing, start by checking out the code in the eclipse.jdt.core Git repository. See the instructions here.
You can also check out the mailing list, email@example.com, or post questions to the Java Development Tools (JDT) forum. The mailing list is primarily for announcements and discussion by people working on the APT tooling in Eclipse; if you have technical questions, it is best to use the forum.