Working With Ant Scripts

In this section:

This section describes the different ways of using Ant scripts.

Publishing iIA from iIT Using the Ant Script

How to:

You can build and publish an application using the Ant Script.

Procedure: How to Publish iIA from iIT Using the Ant Script

To publish iIA from iIT using the Ant script:

  1. Open the generated build.xml file by double-clicking it in the Integration Explorer view.

    If you are familiar with Apache Ant, then you should be able to recognize iWay Ant Tasks, Ant Properties, and eventually find it easier to create your own deployment scripts.

  2. Opening the build.xml file from the tool bar by clicking Run, selecting Run As, and clicking Ant Build, as shown in the following image.

    The dialog lists multiple deployment options available for you. You can select one option or a number of options in sequence.

  3. Click on the build [default] and upload checkboxes to build and upload the application to the local iSM server (ensure the server is running), as shown in the following image.
  4. Click Run.

    A confirmation dialog appears.

  5. Click Unblock.

    A success message of the build and upload operation appears in the console view.

Invoking With Remote Ant Scripts

How to:

This section develops Ant scripts that create a backup directory under the iWay Home directory. The script is added to an application as a file resource and then invokes the remote Ant script using the iwscript iWay Ant task.

Procedure: How to Invoke Remote Ant Scripts

To invoke a remote Ant script, you must first create an Ant script by creating a new integration project and opening the XML editor.

  1. From the iWay Home directory, right-click XML, select New, and click Other, as shown in the following image.

    The New XML file wizard is located under the XML section.

    After opening the XML file and writing the project XML tag, the XML editor is replaced with the Ant editor. The following image shows a sample remote Ant file.

    The target, “mkdir”, uses the environment variable on the remote machine to find the iWay home directory and creates a backup directory there.

  2. Create a new application and add the remote.xml file to it as a file resource, as shown in the following image.
  3. Save the application.
  4. Modify the local build.xml file to call the remote Ant target on remote.xml. You must also add a “do_all” target, to perform the following tasks in order:
    • undeploy
    • build
    • upload
    • deploy
    • remote script invocation
  5. Execute the new “do_all” target by right-clicking the do_all node in the Outline tab, selecting Run As, and clicking Ant Build, as shown in the following image.

    The execution log appears, as shown in the following image.

    The new backup directory is successfully created on the remote machine. This is a permanent change to the iWay Installation, and will stay even if the Ant application is deleted.

    Note: You must be careful with remote Ant script invocations since it is a strong feature which may produce irreversible results.

Publishing Templates from Ant

How to:

You can publish templates to the same local server, using a different template name.

Procedure: How to Publish Templates from Ant

To publish templates from Ant:

  1. Edit the build.xml file.
  2. Run the Ant build by right-clicking the addtemplate node, selecting Run As, and clicking Ant Build, as shown in the following image.

    The new template with_logging appears on the iSM console.

Deleting Deployments or Templates from Ant Scripts

When an application is uploaded to iSM, the application receives a version and cannot be deleted except from the iSM console. However, deployments and templates are not versioned, and can be deleted from Ant using the "iwdelete" iWay Ant task.

The following example shows an Ant target that removes a deployment or a template named “fred”.

Multi-server Deployment Using Ant Script

You can add new targets to an Ant script that performs the following in order:

The following example shows how the additional targets appear.

<target name="do_all" depends="undeploy, build, upload, deploy , script"/>
	<!-- - - - - - - - - - - - - - - - - - 
          target: push_everywhere , calls 'push' for a list of servers                      
      - - - - - - - - - - - - - - - - - -->
    <target name="push_everywhere" depends="build">
        <antcall target="push">
         	<param name="server" value="portnoy7"/>
         </antcall>
        <antcall target="push">
         	<param name="server" value="gitlin-xp"/>
         </antcall>
   </target>
	<!-- - - - - - - - - - - - - - - - - - 
          target: push , combines a sequence of iway ant tasks 
      - - - - - - - - - - - - - - - - - -->
		<target name="push" description="upload application and template, and
deploy them">
			<iwupload 
				serverURL="http://${server}:9000" 
				userName="${server.user}" 
				password="${server.password}"
			/>
			<iwaddtemplate 
				templateName="${new.template.name}" 
				fileName="${template.file.name}" 
				serverURL="http://${server}:9000" 
				userName="${server.user}" 
				password="${server.password}"
			/>
			
			<iwdeploy 
				templateName="${new.template.name}" 
				deploymentName="${deployment.name}" 
				serverURL="http://${server}:9000" 
				userName="${server.user}" 
				password="${server.password}"
			/>
		</target>

Note: The user name and password are the same across the enterprise installations of iWay. If they were not the same, the script would be more involved.

The following image shows the trace for running the script, where both application and template were uploaded and deployed together on both servers.


iWay Software