Get your ANT together with Subversion and SQL. March 13, 2008
Posted by paperlessme in Ant, Oracle, Software, script, sql.Tags: Ant, sql, SQLPlus, Subversion, svnkit
trackback
Never underestimate the power of an ant
. It has been observed to easily push along a bread crumb ten times its size. When it does several such tasks in a row, an ant can get some real work done.
The ANT script below shows that it does not take much to get data exported from Subversion. Then, one can do whatever other tasks are needed with the exported data. In this example, another task does SQL Plus processing with the exported file. For instance, the file could contain SQL code for creating/replacing a package.
Before plunging into the script, let’s set up the ANT environment for these tasks. Drop svnkit.jar and svnkit-cli.jar (download from svnkit, a subversion java tool at ) into your ANT_HOME/lib directory.
Next, place the incanto.jar, supporting the Oracle <sqlplus> task (download from incanto ) into the same ANT_HOME/lib directory. (You will find the above jar files when you open the downloaded files, and their names could be slightly different.)
By configuring some ANT properties (used below) in a file beforehand, we are ready to fire off this ANT script:
. <taskdef name=”sqlplus” classname=”net.sf.incanto.Sqlplus”/>
. <property file=”${antProps}”/>
.
<target name=”svn.export”>
<echo message=”Exporting source from ${svn.url} to ${svn.exportPath }”/>
<java classname=”org.tmatesoft.svn.cli.SVN” dir=”${svn.exportPath}” fork=”true”>
<arg value=”co”/>
<arg value=”–username”/>
<arg value=”${svn.user}”/>
<arg value=”–password”/>
<arg value=”${svn.password}”/>
<arg value=”${svn.url}/${your.svn.branch}/XYZ”/>
<classpath>
<pathelement location=”${ant.lib.path}/svnkit.jar” />
<pathelement location=”${ant.lib.path}/svnkit-cli.jar” />
</classpath>
</java>
</target>
<target name=”do.example” depends=”svn.export”>
<!– Create/replace ‘yourSql.pkb’ package exported above –>
<sqlplus logon=”${db.user}/${db.password}”
silent=”false” failonerror=”true” resultproperty=”sql.returncode”
start=”${svn.exportPath}/XYZ/yourSql.pkb”>
</sqlplus></target>
Note that the Subversion client install is not needed with this example. In the case when the Subversion client is already installed, then we can use the <svn> task for the export. It requires a different set of jar files (from subclipse).
<!– load the svn task –>
<taskdef name=”svn” classname=”org.tigris.subversion.svnant.SvnTask”/>
.
<svn username=”${svn.user}” password=”${svn.password}”>
<export srcUrl=”${svn.url}/${your.svn.branch}/XYZ/youSql.pkb” destPath=”${svn.exportPath}” revision=”HEAD” />
</svn>
Now we got our ANT together. Power to the ant!
Comments»
No comments yet — be the first.