我尝试编译包含生成源代码的注释的代码。我使用maven-compiler-plugin
和build-helper-maven-plugin
。我的POM正在寻找这样的:使用maven-compiler-plugin进行Maven注解处理
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<generatedSourcesDirectory>${project.build.directory}/generated-sources/apt</generatedSourcesDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/apt</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
当我运行mvn compile
,${project.build.directory}/generated-sources/apt
添加为源目录,生成的源在正确的目录中生成。但是由于缺少对生成的类的引用,导致编译器错误。这就像生成的源目录不包含在编译过程中。
我也尝试apt-maven-plugin
它不会产生任何东西。并且maven-annotation-plugin
但它的行为如上所述。
我有同样的问题,它工作正常使用`2.3.2`,有一个“虚假的错误”关于'失踪symbol`定义,但它的只是在第一遍生成* Metamodel * – dcestari 2011-02-24 00:01:42