我正在尝试将使用注释处理器生成源的构建移动到 Maven。我尝试如下配置 maven-compiler-plugin:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<fork>true</fork>
<compilerArgument>-s ${project.build.directory}/target/generated-sources/annotation-processing</compilerArgument>
</configuration>
</plugin>
</plugins>
但是 javac 失败了
[INFO] Compilation failure
Failure executing javac, but could not parse the error:
javac: invalid flag: -s /home/robert/workspaces/betbrain/sportsengine.common/sportsengine.bean.test/target/target/generated-sources/annotation-processing
Usage: javac <options> <source files>
use -help for a list of possible options
据我所知,-s 应该在源文件之前传递给 javac,但是 maven 之后传递它。
如何将-s
标志正确传递给 maven-compiler-plugin?
更新:maven-annotation-plugin似乎不起作用。
当配置为
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<outputDirectory>${generated.sources.directory}</outputDirectory>
<processors>
<processor>xxx.annotation.EnforceJavaBeansConventionsProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>
执行失败
[INFO] [processor:process {execution: process}]
error: Annotation processor 'xxx.annotation.EnforceJavaBeansConventionsProcessor' not found
1 error