- Ant uses a build file called as "build.xml" with mostly property tags and target tags a sample is given below.
- The root element of the build file is the project element.The project element has a required attribute called as default which defines the default target to execute.
- Under the root element there are various child elements.
- The "target" element represents various jobs which we can execute
- Each "target" element has a required attribute called as name which acts as identification for targets.
- "Property" elements assign a value to a name, which can de-referenced elsewhere in build file
- In our build file we have assigned mysql parameters to a value.
- The first target simply executes all the other targets, which is done by including the names of the other targets in the depends attribute of the target.
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="publisher" default="all" basedir=".">
<property name="mysql.params" value="-u gaurav -pgaurav -D publisher" />
<target name="all" depends="cleandb, createdb, insertdb"></target>
<target name="cleandb">
<exec executable="C:\wamp64\bin\mysql\mysql5.7.14\bin\mysql" input="cleandb.sql">
<arg line="${mysql.params}" />
</exec>
</target>
<target name="createdb">
<exec executable="C:\wamp64\bin\mysql\mysql5.7.14\bin\mysql" input="createdb.sql">
<arg line="${mysql.params}" />
</exec>
</target>
<target name="insertdb">
<exec executable="C:\wamp64\bin\mysql\mysql5.7.14\bin\mysql" input="insertdb.sql">
<arg line="${mysql.params}" />
</exec>
</target>
</project>
d
No comments:
Post a Comment