与Maven编译器,插件Maven的注释处理 [英] Maven annotation processing with maven-compiler-plugin
问题描述
我尝试编译我的code包含生成源$ C $ C注释。我用的是 Maven的编译器插件
和建立辅助-Maven的插件
。我POM正在寻找这样的:
I try to compile my code that contains annotations that generate source code. I use the maven-compiler-plugin
and build-helper-maven-plugin
. My POM is looking like that:
<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编译
, $ {} project.build.directory /生成的来源/公寓
是添加为源目录,生成的源代码都在正确的目录中生成。但我得到的,因为缺少生成的类引用的编译器错误。这就像在编译过程中不包含生成的源目录。
When I run mvn compile
, ${project.build.directory}/generated-sources/apt
is added as a source directory, and the generated sources are generated in the correct directory. But I get compiler errors because of missing references to the generated classes. It's like the generated source directory is not included in the compilation process.
我也尝试的apt-Maven的插件
不产生任何东西。和 Maven的注解插件
,但它的行为如上面描述的。
I also try apt-maven-plugin
which does not generate anything. And maven-annotation-plugin
but it behaves as describe above.
推荐答案
你能尝试与Maven编译器插件的最新版本( 2.3.2
)?
Can you try with the latest version of maven compiler plugin (2.3.2
)?
还有建立辅助-Maven的插件
不是必需的,因为它看起来像您使用的是 Maven的编译器插件
本身以产生从注释的源。
Also build-helper-maven-plugin
is not required since it looks like you are using the maven-compiler-plugin
itself to generate the sources from the annotation.
这篇关于与Maven编译器,插件Maven的注释处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!