Example. Set memory used by JVM in Ant
<project name="MemoryMap" default="compile" basedir=".">
<property name="sourcedir" value="${basedir}/src"/>
<property name="targetdir" value="${basedir}/build"/>
<property name="librarydir" value="${basedir}/lib"/>
<path id="libraries">
<fileset dir="${librarydir}">
<include name="*.jar"/>
</fileset>
</path>
<target name="clean">
<delete dir="${targetdir}"/>
<delete dir="${librarydir}"/>
</target>
<target name="prepare" depends="clean">
<mkdir dir="${sourcedir}"/>
<mkdir dir="${targetdir}"/>
<mkdir dir="${librarydir}"/>
</target>
<target name="compile" depends="prepare">
<javac srcdir="${sourcedir}" destdir="${targetdir}" debug="true"
fork="true" memoryMaximumSize="1024m" memoryInitialSize="256m">
</javac>
</target>
</project>
In this example,
<property name="sourcedir"> is used to specify the location of source directory
<propertyname="targetdir"> is used to specify the location of target directory
<property name="librarydir"> is used to define the location of library directory
<path id="libraries"> is used to put any jar file in the lib directory
The target <targetname="clean"> is used to delete the target directory and library directory from base directory.
The target <targetname="prepare"> is used to create the source directory, target directory and library directory.
<target name="compile"> is used to compile the source code.
fork="true" is used if you don't run Java code in a separate JVM to the ant script, you can get some pretty strange errors that are difficult to diagnose.
For NoClassDefFoundError, the problem was fixed by setting fork=true in the java target.
The memoryMaximumSize="1024m" for the underlying VM, if using fork mode; ignored otherwise.
Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
memoryInitialSize="256m" is used for the underlying VM, if using fork mode; ignored otherwise.
Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m).
No comments:
Post a Comment
Note: only a member of this blog may post a comment.