代码之家  ›  专栏  ›  技术社区  ›  Sean Patrick Floyd

java6:如何向APT传递多个参数

  •  2
  • Sean Patrick Floyd  · 技术社区  · 14 年前

    我有一个从 AbstractProcessor .

    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配置:

    <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>
    

    <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。

    (见 Mapping Maps Guide to Configuring Maven Plugins

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


    我现在有了 filed a bug report .

    1 回复  |  直到 14 年前
        1
  •  0
  •   Sean Patrick Floyd    14 年前

    目前还没有真正的答案。

    缺陷被归档: MCOMPILER-135

    the last of which Properties :

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

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

    (如果现有参数 <compilerArguments> 我的问题也会得到解决)