In our enterprise application we are seeking a dynamic way to collect data from our Java classes. We created a custom annotation interface (@interface
) with a name
property. We would like to collect the value of this property from all annotated classes.
I managed to create an AnnotationProcessorFactory
and an AnnotationProcessor
for the custom annotation. Since we are using Maven 2, I added the following to the plugins in the pom.xml
of the main project.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.0-alpha-5</version>
<configuration>
<factory>our.company.api.component.lister.ComponentAnnotationProcessFactory</factory>
</configuration>
</plugin>
This resides in the main project which has several sub-projects. The factory and the custom processor are in one of these sub-projects. The custom annotations are scattered through all of the sub-projects that is why I put the plugin in the pom.xml
of the main project.
The problem is when I issue the mvn apt:process
command I got a warning about the annotations without processors and our custom annotation is among them. I assume this means that the plugin cannot find the factory class.
What should I do so the plugin could find the factory and the processor file?
EDIT:
The project hierarchy is very simple:
main_project
|-sub_project1
|...
|-sub_projectn
The plugin is in the pom.xml
of the main_project
. Just assume that the factory and processor are in sub_project1
and the custom annotations are in sub_project2
, sub_project3
, ..., sub_projectn