Application Project Deployment - Apache Ant

Users who choose to script the deployment process using Apache ANT will find a rich set of ANT tasks to do so. When a user in IIT creates an application project a sample build.xml is created which ANT users can modify to script the process. This file is delivered to the user as part of the bundle as shown below.

Application Project - build.xml

Figure #1: Deployment Apache ANT Integration

 

To get started, click on the build.xml file as shown below and right-click the item as shown below.

 

build.xml - right mouse click

Figure #2: Creating an ANT run configuration.

 

gggggg

Figure #3: ANT Tasks defined in build.xml.

As we can see there are several ANT tasks available which can be executed. The target execution order can be set by clicking on the checkbox next to the ANT task . The order of the click defines the order of execution. When done, click on the Run button to execute. 

 

 

The Test Drive

Now since we have introduced the basics lets perform a walk though. The iWay ANT libraries rely on resources provided through the ISM runtime. Normally this is provided by having the iWay runtime installed on the same machine as the running script.

Setting up the Environment

To get started set the IWAY8 environment variable to the location of IWAYHOME. On a Windows machine this is normally set to:


IWAY8=C:\Program Files (x86)\iway8\

 

The default build.xml assumes that the iWay Server is installed locally and that both the userid and/or password have remained the same. If any of these properties have changed the following code snippet needs to be changed.

	<property name="server.url" value="http://localhost:9000" />
	<property name="server.user" value="iway"/>
	<property name="server.password" value="ENCR(3237324531043128310632252993121)"/>
	

 

At this point we can either use IIT to execute the ANT tasks or drop down into a command shell. For our test run we will navigate to the root directory of the application and drop into a command shell.

Building an Application

To build the iWay Application Project enter the following command:

c:\IIT\workspace\mydemo\bundle.iab>ant
Buildfile: c:\IIT\workspace\mydemo\bundle.iab\build.xml

build:
  [iwbuild] Building Application "bundle" in c:\IIT\workspace\mydemo\bundle.iab/bundle.iab

BUILD SUCCESSFUL
Total time: 3 seconds
c:\IIT\workspace\mydemo\bundle.iab>


If we look into the application directory, we now have a "bundle.iia" as shown below:

c:\IIT\workspace\mydemo\bundle.iab>dir
 Volume in drive D is Data
 Volume Serial Number is BE42-230D

 Directory of c:\IIT\workspace\mydemo\bundle.iab

11/19/2018  06:32 PM    <DIR>          .
11/19/2018  06:32 PM    <DIR>          ..
11/20/2018  11:12 AM               632 .iwresource
11/19/2018  03:19 PM             2,410 build.xml
11/20/2018  11:12 AM               274 bundle.iab
11/21/2018  01:30 PM             9,006 bundle.iia
11/19/2018  06:32 PM             1,935 bundle.pdf
               5 File(s)         14,257 bytes
               2 Dir(s)  252,279,369,728 bytes free

c:\IIT\workspace\mydemo\bundle.iab>

 

Publishing an Application

Now to deploy the application we must first upload it to an iWay server. We can do this by entering the following command ant upload as shown below:

c:\IIT\workspace\mydemo\bundle.iab>ant upload
Buildfile: c:\IIT\workspace\mydemo\bundle.iab\build.xml

upload:
 [iwupload] Uploading Application "bundle" at c:\IIT\workspace\mydemo\bundle.iab to http://localhost:9000
 [iwupload] Logging in as iway...
 [iwupload] log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.HttpClient).
 [iwupload] log4j:WARN Please initialize the log4j system properly.
 [iwupload] log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
 [iwupload] Done.

BUILD SUCCESSFUL
Total time: 1 second

c:\IIT\workspace\mydemo\bundle.iab>

 

Deploying an Application

The application is now available for deployment. To deploy the iWay application enter the following command:
ant deploy as shown below:

c:\IIT\workspace\mydemo\bundle.iab>ant deploy
Buildfile: c:\IIT\workspace\mydemo\bundle.iab\build.xml

deploy:
 [iwdeploy] Deploying Application "bundle" to http://localhost:9000 as "bundle" using template "raw".
 [iwdeploy] Logging in as iway...
 [iwdeploy] log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.HttpClient).
 [iwdeploy] log4j:WARN Please initialize the log4j system properly.
 [iwdeploy] log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
 [iwdeploy] Done.

BUILD SUCCESSFUL
Total time: 1 second

c:\IIT\workspace\mydemo\bundle.iab>

 

Starting an Application

To start the iWay Application enter the following, ant start as shown below.


c:\IIT\workspace\mydemo\bundle.iab>ant start
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.0_131\lib\tools.jar
Buildfile: c:\IIT\workspace\mydemo\bundle.iab\build.xml

start:
  [iwstart] Logging in as iway...
  [iwstart] Checking status...
  [iwstart] log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.HttpClient).
  [iwstart] log4j:WARN Please initialize the log4j system properly.
  [iwstart] log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
  [iwstart] Deployed application "bundle" on http://localhost:9000 is down
  [iwstart] Issuing start...
  [iwstart] Checking status...
  [iwstart] Application deployment bundle is active.

BUILD SUCCESSFUL
Total time: 8 seconds

c:\IIT\workspace\mydemo\bundle.iab>

 

Stopping an Application

To stop the iWay Application enter the following, ant stop as shown below.

c:\IIT\workspace\mydemo\bundle.iab>ant stop
Buildfile: c:\IIT\workspace\mydemo\bundle.iab\build.xml

stop:
   [iwstop] Logging in as iway...
   [iwstop] Checking status...
   [iwstop] log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.HttpClient).
   [iwstop] log4j:WARN Please initialize the log4j system properly.
   [iwstop] log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
   [iwstop] Deployed application "bundle" on http://localhost:9000 is up
   [iwstop] Issuing stop...
   [iwstop] Checking status...
   [iwstop] Application deployment bundle is stopped.

BUILD SUCCESSFUL
Total time: 4 seconds

c:\IIT\workspace\mydemo\bundle.iab>

 

These are just a few tasks which can scripted using Apache ANT.  For a more in depth description of the scripting capabilities please refer to the iWay SDK a standalone build system which enables organizations to implement DevOps patterns.

 

Sample ANT code generated by IIT

<?xml version="1.0" ?>
<project name="iaa" default="build" basedir=".">
	<property environment="env"/>
	<property name="iway.home" location="${env.IWAY8}"/>
	<property name="new.template.name" value="uploaded" />
	<property name="template.file.name" value="missing.ita" />
	<property name="publishedtemplate.name" value="publishedtemplate" />	
	<property name="server.url" value="http://localhost:9000" />
	<property name="server.user" value="iway"/>
	<property name="server.password" value="ENCR(3237324531043128310632252993121)"/>
	<property name="templateFile.path" value="${basedir}/../../mytemplate.ita" />
	

	<import file="${iway.home}/etc/manager/deployment/iia/iway-ant-tasks.xml" optional="true" />

	<!-- A sample target for building an IAA -->
	<target name="build" description="Build an application archive">
		<iwbuild />
	</target>


	<!-- A sample target for uploading an IAA -->
	<!-- Add applicationFile parameter to upload an IIA other than the local one -->
	<!--     (Example: applicationFile="c:\my_application.iia") -->
	<target name="upload" description="Upload an application archive to the server"> 
		<iwupload 
			serverURL="${server.url}" 
			userName="${server.user}" 
			password="${server.password}"
		/>
	</target>

	<!-- A sample target for deleting a deployed IIA -->
	<target name="undeploy" description="Undeploy an application">
		<iwdelete 
			serverURL="${server.url}" 
			userName="${server.user}" 
			password="${server.password}"
		/>
	</target>

	<!-- A sample target for deploying an IIA -->
	<target name="deploy" description="Deploy an application">
		<iwdeploy 
			serverURL="${server.url}" 
			userName="${server.user}" 
			password="${server.password}"
		/>
	</target>
	
	<!-- A sample target for deploying an IIA -->
	<target name="deploywithlocaltemplate" description="Deploy an application using template">
		<iwdeploy 
			serverURL="${server.url}" 
			userName="${server.user}" 
			password="${server.password}"
			templateArchiveFile="${templateFile.path}"
		/>
	</target>
	
	<target name="deploywithpublishedtemplate" description="Deploy an application using a published template">
		<iwdeploy 
			serverURL="${server.url}" 
			userName="${server.user}" 
			password="${server.password}"
			templateName="${publishedtemplate.name}"
		/>
	</target>
	
	<!-- A sample target for starting a deployed IIA -->
	<target name="start"  description="Start deployed application">
		<iwstart 
			serverURL="${server.url}" 
			userName="${server.user}" 
			password="${server.password}"
		  /> 
	</target>

	<!-- A sample target for stopping a deployed IIA -->
	<target name="stop" description="Stop deployed application">
		<iwstop 
			serverURL="${server.url}" 
			userName="${server.user}" 
			password="${server.password}"

		  />
	</target>

	<!-- A sample target for uploading a Template -->
	<target name="addtemplate" description="Upload an application archive to the server">
		<iwaddtemplate 
			templateName="${new.template.name}" 
			fileName="${template.file.name}" 
			serverURL="${server.url}" 
			userName="${server.user}" 
			password="${server.password}"
		/>
	</target>

</project>