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\jprofiler7\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.
Attribute | Description | Required |
---|---|---|
offline | Whether the profiling run should be in offline mode. Corresponds to the offline library parameter. Either true or false. | No, offline and nowait cannot both be true |
nowait | Whether profiling should start immediately or whether the profiled JVM should wait for a connection from the JProfiler GUI. Corresponds to the nowait library parameter. Either true or false. | |
sessionid | Defines the session id from which profiling settings should be taken. Has no effect if neither nowait nor offline are set because in that case the profiling session is selected in the GUI. Corresponds to the id library parameter. |
Required if
|
configfile | Defines the config file from which the profiling settings should be read. If not set or empty, the default config file location will be taken ($HOME/.jprofiler8/config.xml). Has no effect if neither nowait nor offline are set because in that case the profiling session is selected in the GUI. Corresponds to the config library parameter. | No |
port | Defines the port number on which the profiling agent should listen for a connection from the JProfiler GUI. This must be the same as the port configured in the remote session configuration. If not set or zero, the default port (8849) will be used. Has no effect if offline is set because in that case there's no connection from the GUI. Corresponds to the port library parameter. | No |
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\jprofiler7\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:
Attribute | Description | Required |
---|---|---|
format | One of "dir", "tar" or "tgz". By default, the directory format is used. These options correspond to the heap dump analysis saving options in the general settings. | No |
removeunreferenced | Corresponds to the "Remove unreferenced and weakly referenced objects" option in the heap walker options dialog. Either true or false. | No |
retained | Corresponds to the "Calculate retained sizes" option in the heap walker options dialog. Either true or false. If set to true, removeunreferenced will be set to to true as well. | No |