Maven: How to specify Javac plugin argument with maven-compiler-plugin?

半腔热情 提交于 2019-12-03 17:31:17

In light of this discussion: MCOMPILER-178 and this patch: pull request, and since a space doesn't seem to be a character allowed in XML-names, I would suspect that you have to just drop all the double-quotes, and keep all the spaces.

This here:

myOption=foo"bar"baz

is string concatenation in bash (or whatever shell your are using). It stores the string "foobarbaz" in variable myOption. If you use double quotes in an option in bash, then it simply means: "bash, please treat the entire thing between the quotes as a single argument, don't split it into an array of string arguments". For example, if you run the following bash script:

#!/bin/bash

echo $1
echo $2
echo $3

with these arguments:

$ ./testArgs.sh hello -World:"blah blah blah" foobar

you will get this output:

hello
-World:blah blah blah
foobar

The -World:blah blah blah part is a single string, the quotes are not preserved.

Maven is not bash. POM is an XML file, it has tags, some of the tags are filled with text. XML doesn't care about bash's syntax for string concatenation or argument-parsing. If I understood the above discussion correctly, they passed the content of the xml-tags directly to the compiler, without any modifications.

Therefore, my best guess would be to just drop the double quotes:

<arg>-Xplugin:MyPlugin myArg</arg>

If this doesn't help, then I misunderstood the discussion linked above entirely, or maybe you are using a maven version that works differently.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!