Part 2: The ANT Build file

As mentioned previously, the ANT build file is just an XML file.

There are a number of important features in the file.

1. Declare properties
You will have a number of variables that will be used frequently throughout the build file, eg. database logon username, password, Oracle SID, etc. These should all be declared at the top of the build file.

<?xml version=”1.0″ encoding=”UTF-8″?>
<project name=”Demo Database build” default=”about-ant” basedir=”.”>
Build file for test database.

<!– declare properties –>
<property name=”build.dir” location=”.”/>
<property name=”” location=”${build.dir}\development” />
<property name=”db.user” value=”username” />
<property name=”db.pwd” value=”password” />
<property name=”db.tnsname” value=”MYSERVER” />
<property name=”db.sid” value=”xyz001″ />
<property name=””     location=”${}\run_ounit_tests.sql”/>
<property name=””     location=”${}\dev_build.sql”/>
<property name=”db.failing.tests.script” location=”${}\no_of_failing_plsql_tests.sql”/>

2. Logon to SQL*PLUS
So you can call your sql file to build the database

<!– rebuild database –>
<echo message=”Logging on to SQLPLUS”/>
<exec executable=”sqlplus”
<arg value=”-S” />
<arg line=”${db.user}/${db.pwd}@’${db.sid}'”/>
<arg value=”@${}”/>

3. Load test data with SQL*LOADER.

<!– load test data –>
<echo message=”Loading Test data with SQLLoader”/>
<exec executable=”sqlldr”
<arg line=”${db.user}/${db.pwd}@’${db.sid}'”/>
<arg value=”control=data\customer.ctl”/>

4. Run unit tests
Call sql file with executes UTPLSQL tests

<!– run unit tests –>
<echo message=”Running Unit tests”/>

<exec executable=”sqlplus”
description=”Run test via sqlplus.”>
<arg value=”-S”/>
<arg line=”${db.user}/${db.pwd}@’${db.sid}'”/>
<arg value=”@${}”/>

5. Interogate results of unit tests
Query UTPLSQL for the results of the test

<echo message=”Look for test results from UTPLSQL”/>
<exec executable=”sqlplus”
description=”Retrieve the number of failing unit tests into a property.”>
<arg value=”-S” />
<arg line=”${db.user}/${db.pwd}@’${db.sid}'”/>
<arg value=”@${db.failing.tests.script}”/>

6. Email the results back to you

<echo message=”Send email saying that Daily Build has run”/>
<mail mailhost=”mailhost.server” mailport=”25″ subject=”Test Database build”>
<from address=””/>
<replyto address=””/>
<to address=””/>
<message>The TEST database daily build has completed</message>

On to Part 3

Leave a Reply

Your email address will not be published. Required fields are marked *