Understanding Build Files

The Ant build file for the command-line interface must contain the import, project, target, and AMXAdminTask elements.

import Element

The import element identifies the task definition file, which defines the path to the libraries required by AMXAdminTask.

Set the file attribute to CONFIG_HOME/admin/amxadmin/samples/admin-scripts-base.xml . For example:
<import file="C:/Documents and Settings/AMX-User/ApplicationData/amx-3/data/admin/amxadmin/samples/admin-scripts-base.xml"/>

project Element

The project element declares the default build target for the build.xml file. taskdef and target are subelements of the project. The optional default attribute allows you to specify a default target. You can choose any target from the build file to be the default target.

<project default="target">
  <taskdef ... />
  <target name="target" ... />
</project>

target Element

The target element specifies the actions performed for an execution of the command line interface via the AMXAdminTask subelement. In a target you can provide a depends attribute containing a list of targets. Each target will be run in order until one fails or the list completes.

<target name="target">
  <AMXAdminTask ... />
</target>

Example Build File

The following build file defines targets to upload a distributed application archive, create an application, map an application to a node, create a resource template, create a resource instance and install it in a node, and deploy an application.
<project default="all">

	<dirname property="admin.samples.directory" file="CONFIG_HOME/admin/enterpriseName/samples"/>

    <!-- This import defines the custom AMXAdminTask. -->
    <import file="${admin.samples.directory}/admin-scripts-base.xml"/>
    
    <!-- Predefine ${dataFile} to apply the targets in this script with different parameters. -->
    <property name="dataFile" value="userProvided dataFile"/>
    
    <!-- Predefine ${instanceProperties} to control a different Administrator server with this script. -->
    <property name="remote-properties.file" value="${admin.samples.directory}/remote_props.properties"/>

	
	<!-- Default task for this build file -->
	<target name="all" 
		depends="upload.daa, create.app, edit.properties, wire.application, distribute.app, 
  deploy.app, start.app"
		description="Default target group, execute following targets: upload.daa, create.app, 
  edit.properties, wire.application, distribute.app, deploy.app, start.app"/>
	

	<!-- Upload DAA specified in the data file -->
	<target name="upload.daa" description="Uploading Application">
		<AMXAdminTask 
			action="add" 
			objectSelector="DAA" 
			remote="true" 
			propsFile="${remote-properties.file}" 
			dataFile="${dataFile}" 
			overwrite="false" merge="true" createIfNotExists="true" 
			force="false" failOnError="false" /> 
	</target>  		

	<!-- create the application -->
	<target name="create.app" description="Creating Application">
		<AMXAdminTask remote="true" propsFile="${remote-properties.file}" 
			action="add" dataFile="${basedir}/jv.phonebook.soa.deployment-config.xml" 
			objectSelector="Environment//Application" 
			overwrite="false" merge="true" 
			createIfNotExists="true" force="false" failOnError="true" />
	</target>


	<!-- configure properties of the application, and create resource instances if needed -->
	<target name="edit.properties" description="Editing Properties">
	
		<!-- create resource template -->
		<AMXAdminTask remote="true" propsFile="${remote-properties.file}" 
			action="add" dataFile="${dataFile}"
			objectSelector="ResourceTemplate" overwrite="false" merge="true"
			createIfNotExists="true" force="false" failOnError="true" /> 
		
		<!-- add all require resource instances -->
		<AMXAdminTask remote="true" propsFile="${remote-properties.file}" 
			action="add" dataFile="${dataFile}" 
			objectSelector="Environment/Node/ResourceInstance" 
			overwrite="false" merge="true" 
			createIfNotExists="true" force="false" failOnError="true" />
			
		<!-- install instances added above -->
		<AMXAdminTask remote="true" propsFile="${remote-properties.file}" 
			action="install" dataFile="${dataFile}" 
			objectSelector="Environment/Node/ResourceInstance" 
			overwrite="false" merge="true" 
			createIfNotExists="true" force="false" failOnError="true" />
			
		<!-- override values for properties -->
		<AMXAdminTask remote="true" propsFile="${remote-properties.file}" 
			action="edit" dataFile="${dataFile}" 
			objectSelector="Environment//Application/Property | 
   			Environment//Application//PromotedService//Binding/Property |  
   			Environment//Application//PromotedReference//Binding/Property" 
			overwrite="false" merge="true" 
			createIfNotExists="true" force="false" failOnError="true" />
			
		
	</target>

	<!-- create wires to other applications -->
	<target name="wire.application" description="Wiring Application">
		<AMXAdminTask remote="true" propsFile="${remote-properties.file}" 
			action="set" dataFile="${dataFile}" 
			objectSelector="//PromotedReference/Wire" 
			overwrite="false" merge="true" 
			createIfNotExists="true" force="false" failOnError="true" />
	</target>

 
	<target name="distribute.app" description="Distributing Application">
	<AMXAdminTask
			action="set"
			objectSelector="Environment//Application//Component/Node | 
   			Environment//Application//PromotedService//Binding/Node | 
  			 Environment//Application//PromotedReference//Binding/Node"
			remote="true"
			propsFile="${remote-properties.file}"
			dataFile="${dataFile}"
			overwrite="false"
			merge="true"
			createIfNotExists="true"
			force="false"
			failOnError="false"/>
	
	</target>


	<!-- deploy the application -->
	<target name="deploy.app" description="Deploying Application">
		<AMXAdminTask remote="true" propsFile="${remote-properties.file}" 
			action="deploy" dataFile="${dataFile}" 
			objectSelector="Environment//Application" 
			overwrite="false" merge="true" 
			createIfNotExists="true" force="false" failOnError="true" 
			/>
	</target>

	<target name="start.app" description="Starting Application">
		<AMXAdminTask remote="true" propsFile="${remote-properties.file}" 
			action="start" dataFile="${dataFile}" 
			objectSelector="Environment//Application" 
			overwrite="false" merge="true" 
			createIfNotExists="true" force="false" failOnError="true" />
	</target>

</project>
<project default="all">
	<dirname property="admin.samples.directory" file="CONFIG_HOME/admin/enterpriseName/samples"/>

    <!-- This import defines the custom AMXAdminTask. -->
    <import file="${admin.samples.directory}/admin-scripts-base.xml"/>
    
    <!-- Predefine ${dataFile} to apply the targets in this script with different parameters. -->
    <property name="dataFile" value="userProvided dataFile"/>
    
    <!-- Predefine ${instanceProperties} to control a different Administrator server with this script. -->
    <property name="remote-properties.file" value="${admin.samples.directory}/remote_props.properties"/>

	<target name="all" depends="upload.daa, create.app, map.app.to.node, create.rt, 
  create.ri, install.ri, deploy.app"/>	

	<target name="upload.daa">
		<AMXAdminTask
			propsFile="${remote-properties.file}"
			action="add"
			dataFile="dateMgr_data.xml"
			objectSelector="DAA"
			failOnError="true"/>		
	</target>

	<target name="create.app">
		<AMXAdminTask
			remote="true"
			propsFile="${remote-properties.file}"
			action="add"
			dataFile="dateMgr_data.xml"
			objectSelector="Environment//Application"
			failOnError="true"/>
	</target>
	

	<target name="map.app.to.node">
		<AMXAdminTask
			remote="true"
			propsFile="${remote-properties.file}"
			action="set"
			dataFile="dateMgr_data.xml"
			objectSelector="Environment//Application/Node"
			failOnError="true"/>
	</target>

  
 <target name="create.rt">
		<AMXAdminTask
			remote="true"
			propsFile="${remote-properties.file}"
			action="add"
			dataFile="dateMgr_data.xml"
			objectSelector="ResourceTemplate"
			failOnError="true"/>
	</target>

	<target name="create.ri">
		<AMXAdminTask
			remote="true"
			propsFile="${remote-properties.file}"
			action="add"
			dataFile="dateMgr_data.xml"
			objectSelector="Environment/Node/ResourceInstance"
			failOnError="true"/>
	</target>

	<target name="install.ri">
		<AMXAdminTask
			remote="true"
			propsFile="${remote-properties.file}"
			action="install"
			dataFile="dateMgr_data.xml"
			objectSelector="Environment/Node/ResourceInstance"
			failOnError="true"/>
	</target>

	<target name="deploy.app">
		<AMXAdminTask
			remote="true"
			propsFile="${remote-properties.file}"
			action="deploy"
			dataFile="dateMgr_data.xml"
			objectSelector="Environment//Application"
			failOnError="true"/>
	</target>

</project>