我有一個從AbstractProcessor延伸的Java註釋處理器。Java 6:如何將多個參數傳遞給APT
我有兩個支持的選項,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
編輯
它原來是一個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>
不幸的是,行家發送參數javac的作爲args數組中的一個字符串,雖然它當然應該是兩個字符串。地圖版本<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 />
是invali d XML。
(請參閱從Guide to Configuring Maven PluginsMapping Maps)
而且恐怕也沒有辦法改變這個,哎呀。
編輯:
我現在filed a bug report有。
事實上,我認爲你的問題重複[MCOMPILER-130(http://jira.codehaus.org/browse/ MCOMPILER-130)在http://stackoverflow.com/questions/3358242/is-it-possible-to-get-maven-to-accept-maxerrs-for-its-compiler-plugin之後被提出。但是地圖語法確實不會爲您節省。 – 2010-09-13 17:18:08
不,我不會說這是一個騙局,因爲註釋參數有不同的語法,並且沒有解決方法。 – 2010-09-13 18:14:53
我認爲你是對的,問題是不同的。 – 2010-09-13 21:14:02