views:

53

answers:

1

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.

A: 

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:

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

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)

seanizer