4

I faild in setting the permsize or maxpermsize with the maven-compiler-plugin (v3.2).

I tried it like this:

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

Which results in an error

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

My other attempt was adding it like in the example 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>

Resulting in the very same error:

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

so, why is this flag invalid? If it is gracefully taken into account when I add it to the MVN_OPTS variable?

2
  • These flags are rather JVM arguments than compiler arguments, aren't they?
    – Tome
    Nov 20, 2014 at 9:08
  • Are you absolutely sure your JVM supports those arguments? Hotspot or OpenJDK?
    – Mike
    Nov 20, 2014 at 9:09

3 Answers 3

6

From the javac documentation:

-Joption Pass option to the java launcher called by javac. For example, -J-Xms48m sets the startup memory to 48 megabytes.

Based on the above:

<compilerArgs>
  <arg>-J-XX:PermSize=128m</arg>
  <arg>-J-XX:MaxPermSize=256m</arg>
</compilerArgs>
1
  • I regret. This didn't not work neither. The only thing possible is to add it to the maven_opts or the VM Arguments in Eclipse. Only saving this to the maven-compiler-plugin did not help.
    – feder
    Mar 23, 2015 at 10:52
1

First there is a hint concerning the parameters in the docs

Sets the arguments to be passed to the compiler if fork is set to true. Example:

<compilerArgs>
  <arg>-Xmaxerrs=1000</arg>
  <arg>-XX:PermSize=128m</arg>
</compilerArgs>

which means if you need them for you build you have to do this either via MAVEN_OPTS or you can define them in .mavenrc (linux) or mavenrc_pre.bat (Windows).

3
  • Is it possible that JDK 1.7 doese not support these flags?! Cannot be! I still get the error after adding the compilerArgs. If I add these values to the Default VM Arguments, then it works.
    – feder
    Nov 20, 2014 at 10:00
  • Be aware of the fork flag!
    – khmarbaise
    Nov 20, 2014 at 10:52
  • Yes, I toggled that value before. Still same error. Thanks anyways.
    – feder
    Nov 20, 2014 at 11:21
0

You can just add

export MAVEN_OPTS=-Xmx512m

in your ~/.bash_profile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.