Reputation: 1646
While using the Maven Ant Task artifact:deploy
, I'm encountering the error java.lang.OutOfMemoryError: Java heap space
.
I'm only getting the error if the size of the file being deployed is greater than 25 MB. My artifacts are not greater than 50 MB in size.
What could the reason be? And, what can I do to fix it?
<artifact:deploy file="@{app.name}.jar">
<pom file="@{pom.file}"/>
<remoteRepository url="http://xxx.com:xxx/xxx-webapp/content/repositories/xxx-releases/">
<authentication username="xxx" password="xxx" />
</remoteRepository>
</artifact:deploy>
Most online results indicate that it's something to do with the JVM default heap size and that it can be fixed by setting the appropriate environmental variables.
However, I would want the Ant scripts to run on any computer and not to depend on the environmental variables.
Is there a way to configure these settings in the Ant scripts or the
POM
file?
The install-provider
task (http://maven.apache.org/ant-tasks/examples/install-deploy.html) seems to work for some people. I keep getting download errors when I use it.
It turns out that I'm not getting the Java heap error when I run my Maven Ant task on a different machine (which probably has more memory allocated to the JVM heap). Hence, I haven't attempted the solution mentioned by @Attila, though it seems to be going in the right direction.
Upvotes: 2
Views: 2000
Reputation: 450
please try to increase VM memory, eg.: -Xmx512m if you are using ANT, you can add it to the ANT_OPTS environment variable: ANT_OPTS="-Xmx512m"
Upvotes: 1
Reputation: 28762
Once ant is running, you cannot change the heap size of the JVM runing ant. So your only option is to run the task that comsumes a large amount of memory in a separate JVM, specifying enough heap space. Note this relies on the task allowing you to fork a new JVM to execute the task
Update: I could not find a way to specify to fork the maven (deploy) task, but this page specifies how you can define a macro to run maven using the java task (note that this relies on maven beeing installed and properly configured on the machine) (see the "Using the Java Task" section)
Upvotes: 1