【发布时间】:2011-02-09 04:38:40
【问题描述】:
我尝试编译包含生成源代码的注释的代码。我使用maven-compiler-plugin 和build-helper-maven-plugin。我的 POM 是这样的:
<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,但它的行为如上所述。
【问题讨论】:
标签: maven-2 annotations