在POM.xml中插入MAVEN_OPTS [英] Insert MAVEN_OPTS in the POM.xml
问题描述
我必须增加Java堆空间才能编译我的项目.我发现的唯一方法是修改mvn.bat并设置:
I must increase java heap space to compile my project. The only way I found is modify mvn.bat and set:
set MAVEN_OPTS=-XX:PermSize=256m -XX:MaxPermSize=256m -Xms1300M -Xmx1300M
所有同事都必须更改文件的区域设置. 我想将所有内容保留在我的项目中,而不是本地化.我可以插入POM.xml或其他文件吗?
than all colleagues must change the file localy. I want keep all inside my project, not localy. Can I insert in the POM.xml or other file?
推荐答案
设置MAVEN_OPTS通常会为运行构建的JVM提供参数,这些参数会向下传递给编译器,因为它是内联运行的.您可能已经注意到,用于测试的maven-surefire-plugin
通常会分叉一个单独的进程,因此将选项传递给插件必须绑定在pom.xml中.
Setting MAVEN_OPTS usually provides arguments to the JVM running the build, and these are passed down to the compiler because it runs inline. You have probably already noted that the maven-surefire-plugin
used for test usually fork a separate process so passing options to the plugin is bound inside the pom.xml.
如果您还分叉编译过程并在其中添加标志,该操作如下面的示例所示.
What if you fork the compilation process also and add the flags there, such as the below example.
请注意fork和编译器args
Notice the fork and the compiler args
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
<compilerArgument>-verbose -bootclasspath ${java.home}\lib\rt.jar</compilerArgument>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
这篇关于在POM.xml中插入MAVEN_OPTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!