Integrating JProfiler with your ant script (read about ant at
ant.apache.org)
is easy. Just use the profile task
that is provided in {JProfiler installation directory}/bin/ant.jar
instead of the java task. The profile task
drop in replacement for the the java as it supports
all its attributes and nested tasks. In addition, it has a number of
additional attributes that govern how the application is profiled.
Note: At least ant 1.6.3 is required for the profile task to work. To make the profile task available to ant, you must first insert a taskdef element that tells ant where to find the task definition. Here is an example of using the task in an ant build file: <taskdef name="profile" classname="com.jprofiler.ant.ProfileTask" classpath="C:\Program Files\jprofiler10\bin\ant.jar"/> <target name="profile"> <profile classname="MyMainClass" offline="true" sessionid="80"> <classpath> <fileset dir="lib" includes="*.jar" /> </classpath> </profile> </target> The taskdef definition must occur only once per ant-build file and can appear anywhere on the top level below the project element. Note: it is not possible to copy the ant.jar archive to the lib folder of your ant distribution. You have to reference a full installation of JProfiler in the task definition. |
Besides the attributes of the java task,
the profile task supports the following additional attributes:
|
If the generated snapshots have heap dumps in them,
you can then use the analyze ant task to
prepare the heap dump analysis in advance.
This is an alternative to calling the jpanalyze executable directly as described for
offline profiling.
Here is an example of using the task in an ant build file: <taskdef name="analyze" classname="com.jprofiler.ant.AnalyzeTask" classpath="C:\Program Files\jprofiler10\bin\ant.jar"/> <target name="analyze"> <analyze> <fileset dir="output" includes="*.jps" /> </analyze> </target> This will prepare heap dump analyses for all snapshot files in the "output" directory. Besides the file set for the snapshot files to by analyzed, the analyze task supports the following additional attributes:
|