Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2009, 12:11 PM
Member
 
Join Date: Jul 2009
Posts: 2
Rep Power: 0
Milesy is on a distinguished road
Default Compile time Annotation Processing - Maven build problem
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.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Tags
annotation, annotations, compile, maven

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Annotation Processing in Eclipse Ganymede mcfrog Eclipse 2 07-23-2009 07:42 AM
Maven plugin for eclipse + "Updating Maven Dependencies" problem?? sbutt Eclipse 0 04-20-2009 07:26 PM
compile problem chrisbremen New To Java 8 11-13-2008 07:20 PM
Java 1.5 compile time error ank_k New To Java 4 11-13-2008 12:12 PM
Help with Compile time errors bri1547 New To Java 2 08-25-2008 12:22 AM


All times are GMT +2. The time now is 04:59 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org