<!--(1)建立一个项目,默认的操作为target=all. -->
<project name="proj" default="all" basedir=".">
<!--(2)建立一些属性,以供下边的操作用到 -->
<property name="root" value="./" />
<property name="deploy_path" value="d:/deploy" />
<property name="srcfile" value="d:/srcfile" />
<target name="all" depends="compile,deploy"/>
<!--(3)对数据库的操作 demo.ddl中写的是sql语句 driver,url,userid,password随具体情况设置-->
<!-- Oracle -->
<target name="db_setup_oracle" description="Database setup for Oracle">
<antcall target="check_params_results"/>
<sql driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@192.168.0.1:1521:oa"
userid="oa" password="oa"
onerror="continue"
print="yes"
src="./demo.ddl"/>
</target>
<!--(4)javac编译 -->
<target name="compile">
<javac srcdir="${srcfile}"
destdir="${root}/oa/"
includes="*.java"
classpath="${CLASSPATH};${CLIENT_CLASSES}/utils_common.jar" <!--CLASSPATH和CLIENT_CLASSES是环境变量-->
/>
</target>
<target name="deploy" depends="compile">
<!-- Create the time stamp -->
<tstamp/>
<!--(5)删除目录-->
<!--(6)建立目录-->
<delete dir="${root}/dist/"/>
<mkdir dir="${root}/dist/"/>
<delete dir="${deploy_path}"/>
<mkdir dir="${deploy_path}"/>
<!--(7)拷贝文件群-->
<copy todir="${root}/dist/">
<fileset dir="${root}/oa/">
<include name="*.class"/>
</fileset>
</copy>
<!--(8)jar为一个包-->
<jar jarfile="${deploy_path}/classjar.jar" basedir="${root}/dist" update="yes"></jar>
<!--(9)拷贝单个文件(上边是文件群,这是单个文件)-->
<copy file="${deploy_path}/classjar.jar" todir="${root}/dist/"/>
</target>
<!--(10)运行(args中是参数,随应用程序的具体情况有所不同)->
<target name="simplesql" depends="compile,db_setup_oracle">
<java classname="examples.jdbc.oracle.simplesql"
fork="yes" failonerror="yes"
args="-user zrb
-password zrb
"/>
</project> |