Hi.
I have upgraded using the 1.6 method of doing compile time annotations, and I am runing into a problem trying to build a jar containing my annotations processor.
I get the error from maven (mvn package)
[INFO] Compilation failure
error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider annotations.processing.processors.CodeAnnotationPr ocessor not found
I have the following directory structure
src
--main
----java
------annotations
--------processing
----------processors
------------CodeAnnotationProcessor.java
----------annotations
------------CodeAnnotation.java
----resources
------META-INF
--------service
----------javax.annotation.processing.Processor
I build this with the following with maven
|
Code:
|
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>mygroup</groupId>
<artifactId>annotations-processor</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<name>annotations-processor</name>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.4.2</version>
<scope>system</scope>
<systemPath>C:/Java/jdk1.6.0_10/lib/tools.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project> |
The javax.annotation.processing.Processor file contains
|
Code:
|
annotations.processing.processors.CodeAnnotationProcessor |
Any my
|
Code:
|
package annotations.processing.processors;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedSourceVersion;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement;
import javax.lang.model.SourceVersion;
import java.util.Set;
@SupportedAnnotationTypes(
"annotations.processing.annotations.CodeAnnotation")
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class CodeAnnotationProcessor extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
return true;
}
} |
And my CodeAnnotation is as follows
|
Code:
|
package annotations.processing.annotations;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface CodeAnnotation {
} |
Thank you.