我有一个从 AbstractProcessor 扩展的 Java 注释处理器。
我有两个支持的选项,addResDir
和 verbose
,我试图像这样设置它们:我
-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
EDIT
毕竟,事实证明这是一个 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,而它当然应该是两个字符串。映射版本
也没有帮助,因为
<Averbose>true</Averbose>
<AaddResDir>src/main/webapp</AResDir>
生成输出:
[... , -Averbose, true, -AaddResDir, src/main/webapp]
While javac 需要语法
[... , -Averbose=true, -AaddResDir=src/main/webapp ]
并且
<Averbose=true />
<AaddResDir=src/main/webapp />
是无效的 XML。
(请参阅 配置Maven插件指南)
而且恐怕没有办法改变这个,呃。
编辑:
我现在已经提交了错误报告。
I have a Java Annotation Processor that extends from AbstractProcessor.
I have two supported options, addResDir
and verbose
, and I am trying to set them like this:
-AaddResDir=src/main/webapp -Averbose=true
I have also tried this:
-AaddResDir=src/main/webapp,verbose=true
While a single parameter works, e.g.
-AaddResDir=src/main/webapp
I can't get the multiple parameters to work and I can't find any relevant docs. Do I need to parse the parameters manually in APT?
The only thing I have is the output of javac -help
:
-Akey[=value] Options to pass to annotation processors
EDIT
It turns out to be a maven problem, after all. Here is my maven config:
<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>
Unfortunately, maven sends the argument to Javac as a single string in the args array, while it should of course be two Strings. The Map Version <compilerAguments>
is no help either, because
<Averbose>true</Averbose>
<AaddResDir>src/main/webapp</AResDir>
generates the output:
[... , -Averbose, true, -AaddResDir, src/main/webapp]
While javac requires the syntax
[... , -Averbose=true, -AaddResDir=src/main/webapp ]
and
<Averbose=true />
<AaddResDir=src/main/webapp />
is invalid XML.
(See Mapping Maps from the Guide to Configuring Maven Plugins)
And I am afraid there is no way to change this, argh.
EDIT:
I have now filed a bug report.
发布评论
评论(1)
目前还没有真正的答案。
该错误已提交:MCOMPILER-135
,我已经提交了三个不同的补丁,最后一个引入了 属性:
此解决方案是最灵活的解决方案,因为它支持多种不同的参数语法格式。
(如果现有参数
也是 Properties 类型,我的问题就可以解决)There is no real answer as of yet.
The bug is filed: MCOMPILER-135
and I have submitted three different patches, the last of which introduces a variable of type Properties:
This solution is the most flexible one because it supports many different parameter syntax formats.
(If the existing parameter
<compilerArguments>
were also of type Properties my problem would be solved)