Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up environment variable in ant script

Tags:

java

ant

I am using ant for building my projects, This project needs more memory then default JVM size, So I have added following line of code in the build.xml file.

<!-- setting up this value as project need this much memory to compile.-->
<property environment="env" />
<property name="env.ANT_OPTS" value="-Xms1024m -Xmx204888m"  />

But above line of code does not seems to have any effect as I am still getting the heap size problem. So I have decided to use a batch script for launching the build. The line of code in the given batch file is below

set ANT_OPTS=-Xms512m -Xmx778m
ant -f agora-build.xml

This batch script successfully launch and executes the ant script. But this is not what I am looking for. Is there a way exists, so that I can setup this argument in the ant script itself?

What should i do?

Thanks, VSD

like image 773
Vijay Shanker Dubey Avatar asked Sep 08 '10 01:09

Vijay Shanker Dubey


2 Answers

If you set the option in the build script, the JVM is already up and configured; the only way to set JVM-level options from within a build file is to have Ant spawn another JVM (using the java task as a launcher, or the ant task).

You can also set ANT_OPTS as an environment variable; that will affect all Ant builds you run and pass the provided options to the JVM that Ant runs in.

like image 178
mlschechter Avatar answered Sep 17 '22 23:09

mlschechter


If you are running the Ant script in Eclipse

Right Click -> Run As -> External Tools Configuration

(Add the build if it isn't there already)

Go to the JRE tab and add the Xms and Xmx arguments to the VM arguments section.

*edit: "-Xmx204888m" I hope 2 of those 8's are typo's

like image 34
Sean Avatar answered Sep 17 '22 23:09

Sean