Recently I started working on a huge project that was using Maven as build and deployment tool, when I tried to build the project, I got the ugly java.lang.OutOfMemoryError.
To fix this, you will have to increase the maven heap size memory, good thing is that it can be done easily by using maven options.
Above command will increase the memory for maven and your build should be going fine.
If you run the export command on terminal, then it’s valid for that session only. So if you want maven to run with this option always, you should include it in your user profile. For example .bash_profile in Mac OS.
Note that export command sytax is different on different operating systems, so use the syntax that is correct for your OS.