2

我有一个从AbstractProcessor扩展的 Java 注释处理器。

我有两个受支持的选项,addResDirverbose,我正在尝试像这样设置它们:

-AaddResDir=src/main/webapp -Averbose=true

我也试过这个:

-AaddResDir=src/main/webapp,verbose=true

虽然单个参数有效,例如

-AaddResDir=src/main/webapp

我无法使多个参数起作用,也找不到任何相关文档。我需要在 APT 中手动解析参数吗?

我唯一拥有的是输出javac -help

-Akey[=value]   Options to pass to annotation processors

编辑

毕竟,这是一个 Maven 问题。这是我的 Maven 配置:

<plugin>
    <inherited>true</inherited>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.1</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <optimize>true</optimize>
        <debug>true</debug>
        <compilerArgument>-AaddResDir=src/main/webapp -Averbose=true</compilerArgument>
    </configuration>
</plugin>

不幸的是,maven 将参数作为 args 数组中的单个字符串发送给 Javac,而它当然应该是两个字符串。地图版本<compilerAguments>也无济于事,因为

<Averbose>true</Averbose>
<AaddResDir>src/main/webapp</AResDir>

生成输出:

[... , -Averbose, true, -AaddResDir, src/main/webapp]

虽然 javac 需要语法

[... , -Averbose=true, -AaddResDir=src/main/webapp ]

<Averbose=true />
<AaddResDir=src/main/webapp />

是无效的 XML。

(请参阅配置 Maven 插件指南中映射映射

恐怕没有办法改变这一点,啊。


编辑:

我现在已经提交了一个错误报告

4

1 回答 1

0

目前还没有真正的答案。

该错误已提交:MCOMPILER-135

我已经提交了三个不同的补丁,其中最后一个引入了Properties类型的变量:

<additionalCompilerArguments>
    <property> <name>-Akey=value</name> </property>
    <property> <name>-verbose</name> </property>
    <property> <name>-Xmaxerrs</name> <value>1000</value> </property>
</additionalCompilerArguments>

此解决方案是最灵活的解决方案,因为它支持许多不同的参数语法格式。

(如果现有参数<compilerArguments>也是 Properties 类型,我的问题将得到解决)

于 2010-09-16T12:47:50.790 回答