A configuration/metadata generator for java.util.ServiceLoader-style service providers
Java annotation processors and other systems use java.util.ServiceLoader to register implementations of well-known types using META-INF metadata. However, it is easy for a developer to forget to update or correctly specify the service descriptors.
AutoService generates this metadata for the developer, for any class annotated with @AutoService , avoiding typos, providing resistance to errors from refactoring, etc.
AutoService will generate the file META-INF/services/javax.annotation.processing.Processor in the output classes folder. The file will contain:
In the case of javax.annotation.processing.Processor, if this metadata file is included in a jar, and that jar is on javac’s classpath, then javac will automatically load it, and include it in its normal annotation processing environment. Other users of java.util.ServiceLoader may use the infrastructure to different ends, but this metadata will provide auto-loading appropriately.
In Maven, you can write:
Alternatively, you can include the processor itself (which transitively depends on the annotation) in your compile-time classpath. (However, note that doing so may pull unnecessary classes into your runtime classpath.)
A collection of source code generators for Java. Contribute to google/auto development by creating an account on GitHub.
SOURCE: Auto service http://github.com/google/auto/tree/master/service Auto service