You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stefan Meisner Larsen <st...@meisner-larsen.dk> on 2010/04/23 21:57:41 UTC
How do I use my own AnnotationProcessor with maven-annotation-plugin
Hi,
I am trying to get the maven-annotation-plugin working for me. I have
created an AnnotationProcessor, which in located in
dk.danlon.ewp.common.annotations.AnnotationProcessor which is in a seperate
maven project and installed in local repository.
I have tried to add my annotation processor as a PluginDependecy, but it
seems to be ignored.
Any help appreciated.
The pom.xml comes after the output below:
When I run 'mvn compile' I get the following:
stefan@stefan-vaio:~/trifork/workspace/ewp$ mvn compile
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building ewp
[INFO] task-segment: [compile]
[INFO]
------------------------------------------------------------------------
[INFO] snapshot org.bsc.maven:maven-processor-plugin:1.3.3-SNAPSHOT:
checking for updates from maven-annotation-plugin
Downloading:
http://maven-annotation-plugin.googlecode.com/svn/trunk/mavenrepo/org/bsc/maven/maven-processor-plugin/1.3.3-SNAPSHOT/maven-processor-plugin-1.3.3-SNAPSHOT.pom
Downloading:
http://maven-annotation-plugin.googlecode.com/svn/trunk/mavenrepo/org/bsc/maven/maven-processor-plugin/1.3.3-SNAPSHOT/maven-processor-plugin-1.3.3-SNAPSHOT.jar
[INFO] snapshot dk.danlon:ewpap:0.0.1-SNAPSHOT: checking for updates from
maven-annotation-plugin
[INFO] [processor:process {execution: process}]
[INFO] Source directory:
/home/stefan/trifork/workspace/ewp/target/generated-sources/apt added
[INFO] javac option: -cp
[INFO] javac option:
/home/stefan/trifork/workspace/ewp/src/main/resources:/home/stefan/trifork/workspace/ewp/target/classes
[INFO] javac option: -proc:only
[INFO] javac option: -processor
[INFO] javac option: dk.danlon.ewp.common.annotations.AnnotationProcessor
[INFO] javac option: -s
[INFO] javac option:
/home/stefan/trifork/workspace/ewp/target/generated-sources/apt
[INFO] diagnostic error: Annotation processor
'dk.danlon.ewp.common.annotations.AnnotationProcessor' not found
[ERROR] execute error
java.lang.Exception: error during compilation
at
org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:188)
at
org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:101)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at
org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] error during compilation
[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Fri Apr 23 21:32:11 CEST 2010
[INFO] Final Memory: 7M/109M
[INFO]
------------------------------------------------------------------------
stefan@stefan-vaio:~/trifork/workspace/ewp$
My pom.xml looks like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dk.danlon</groupId>
<artifactId>ewp</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>ewp</name>
<url>http://maven.apache.org</url>
<pluginRepositories>
<pluginRepository>
<id>maven-annotation-plugin</id>
<url>
http://maven-annotation-plugin.googlecode.com/svn/trunk/mavenrepo</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<!-- Run annotation processors on src/main/java sources -->
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>1.3.3-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>dk.danlon</groupId>
<artifactId>ewpap</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>dk.danlon.ewp.common.annotations.AnnotationProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>
<!-- Disable annotation processors during normal compilation -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Cheers,
Stefan M Larsen