我在使用maven-compiler-plugin(v3.2)设置permsize或maxpermsize时失败了。
我尝试过以下方式:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<meminitial>1024m</meminitial>
<maxmem>2024m</maxmem>
<compilerArgument>-XX:PermSize=128m</compilerArgument>
</configuration>
</plugin>
导致错误。
Caused by: org.codehaus.plexus.compiler.CompilerException: invalid flag: -XX:MaxPermSize=256m -XX:PermSize=128m
at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:191)
at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)
... 22 more
Caused by: java.lang.IllegalArgumentException: invalid flag: -XX:MaxPermSize=256m -XX:PermSize=128m
at com.sun.tools.javac.api.JavacTool.processOptions(JavacTool.java:231)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:199)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:68)
at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:115)
... 24 more
我的另一种尝试是按照示例http://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html中的方式添加它。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<meminitial>1024m</meminitial>
<maxmem>2024m</maxmem>
<compilerArguments>
<Xms>128m</Xms>
<Xmx>1024m</Xmx>
<XX:MaxPermSize>256m</XX:MaxPermSize>
<XX:PermSize>128m</XX:PermSize>
</compilerArguments>
</configuration>
</plugin>
导致相同的错误:
Caused by: org.codehaus.plexus.compiler.CompilerException: invalid flag: -XX:MaxPermSize
at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:191)
at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)
... 22 more
Caused by: java.lang.IllegalArgumentException: invalid flag: -XX:MaxPermSize
at com.sun.tools.javac.api.JavacTool.processOptions(JavacTool.java:231)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:199)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:68)
at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:115)
... 24 more
那么,为什么这个标志无效?如果我将其添加到MVN_OPTS变量中时是否已经考虑了优雅性?