Here is a sample build file:
<?xml version="1.0"?> <!DOCTYPE project [ <!ENTITY jagtasks SYSTEM "file:./jagtasks.xml"> ]> <project name="sample" default="refresh_svu" basedir="."> <!-- include Jaguar task definitions --> &jagtasks; <!-- global properties for this build --> <property name="jaguar.host" value="SANDVIK2K1" /> <property name="jaguar.port" value="2000" /> <property name="jaguar.user" value="jagadmin" /> <property name="jaguar.password" value="easerver6" /> <!-- connect --> <target name="connect"> <jag_connect host="${jaguar.host}" port="${jaguar.port}" user="${jaguar.user}" password="${jaguar.password}" /> </target> <!-- refresh package ejbtut --> <target name="refresh_ejbtut" depends="connect"> <jag_refresh entity="Package:ejbtut" /> </target> <!-- restart the server --> <target name="restart_server" depends="connect"> <jag_restart /> </target> <!-- shutdown the server --> <target name="shutdown_server" depends="connect"> <jag_shutdown /> </target> </project>
This sample imports the EAServer jagtasks.xml file to declare the jagant tasks. The jagtasks.xml file is located in the EAServer config subdirectory. The syntax shown in the sample imports the file from the same directory; to run build files using this syntax, copy jagtasks.xml to the same directory as your build file, place a copy of your build file in the EAServer config subdirectory, or edit the path specified by the system entity declaration, for example:
<!ENTITY jagtasks SYSTEM "file:../config/jagtasks.xml">
To run jagant with the sample build file, enter this command all on one line:
jagant -buildfile sample.xml refresh_ejbtut
In this example, jagant is invoked with the specified build file. The target, refresh_ejbtut, refreshes the package named ejbtut by invoking the jag_refresh command. You can run other targets in the sample using the same syntax.
Most targets in the sample depends on the connect target. This dependency ensures the connection is established when the target runs. The connect target invokes the jag_connect command to open a connection with the server. The host name, port number, user name and password are defined as Ant properties in the build file.
You can override these property values at the command line
using the Ant -D
option. This
is typically done to specify the password, so that it is not stored
directly in the build file. For example (entered all on one line):
jagant -Djaguar.host=eclipse -Djaguar.port=9005 -Djaguar.password=jagpass -buildfile sample.xml refresh_ejbtut
This command connects to the server with a host name “eclipse” on port 9005, with the user name admin@system and the password “jagpass.” The default user of admin@system is still used because it was not overridden at the command line.