日期:2014-05-16  浏览次数:20497 次

网络相册开发(6)——ant 自动生成数据库

在工程目录下创建libs/hibernate/ ,放入

hibernate-tools-3.2.0.ga.jar

jtidy-4aug2000r7-dev.jar

?

build.properties

project.name=sw
project.version=1.0
basedir=.

build.dir =${basedir}/build
web.dir = ${basedir}/WebRoot
lib.dir = ${basedir}/libs
sql.dir = ${basedir}/sql
config.dir=${basedir}/config

main.dir = ${basedir}/src
test.dir = ${basedir}/test

classes.dir = ${build.dir}/main/classes
test.classes.dir = ${build.dir}/test/classes

web.inf.dir = ${web.dir}/WEB-INF
web.lib.dir = ${web.inf.dir}/lib

database.dir = ${build.dir}/database
database.file = ${database.dir}/data
database.alias = sw
database.port= 3306

?

build.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== 
     2008-1-20                                                      

     friends   
     description
                   
     zhengfuchun                                                              
     ====================================================================== -->
<project name="sw" default="help">
	<description>
            description
    </description>
	<property file="build.properties" />


	<path id="classpath.compile">
		<fileset dir="${web.lib.dir}">
			<include name="*.jar" />
		</fileset>

	</path>

	<path id="classpath.compile.test">
		<fileset dir="${web.lib.dir}/">
			<include name="*.jar" />
		</fileset>
		<fileset dir="${lib.dir}/test">
			<include name="*.jar" />
		</fileset>
		<fileset dir="${lib.dir}/jetty">
			<include name="*.jar" />
		</fileset>
		<pathelement path="${classes.dir}" />
	</path>


	<path id="classpath.junit.test">
		<path refid="classpath.compile.test" />
		<pathelement path="${test.classes.dir}" />
	</path>

	<path id="classpath.hibernate">
		<pathelement path="${classes.dir}" />
		<fileset dir="${web.lib.dir}/">
			<include name="*.jar" />
		</fileset>
		<fileset dir="${lib.dir}/hibernate">
			<include name="*.jar" />
		</fileset>
	</path>


	<!-- ================================= 
          target: compile              
         ================================= -->
	<target name="compile" description="description">
		<deltree dir="${classes.dir}" />
		<mkdir dir="${classes.dir}" />
		<javac srcdir="${main.dir}"
		       memoryinitialsize="32m"
		       memorymaximumsize="128m"
		       verbose="true"
		       encoding="UTF-8"
		       destdir="${classes.dir}"
		       source="1.6"
		       fork="true"
		       classpathref="classpath.compile"
		       debug="on" />
		<mkdir dir="${classes.dir}/META-INF"/>
		<copydir dest="${classes.dir}/META-INF" src="${main.dir}/META-INF" />
	</target>


	<!-- ================================= 
          target: compile-test              
         ================================= -->
	<target name="compile-test" description="description">
		<deltree dir="${test.classes.dir}" />
		<mkdir dir="${test.classes.dir}" />
		<javac srcdir="${test.dir}"
		       fork="true"
		       verbose="true"
		       encoding="UTF-8"
		       destdir="${test.classes.dir}"
		       classpathref="classpath.compile.test"
		       debug="on" />
	</target>


	<!-- ================================= 
          target: hibernate-dbexport              
         ================================= -->
	<taskdef name="hibernatetool"
	         classname="org.hibernate.tool.ant.HibernateToolTask"
	         classpathref="classpath.hibernate" />
	<!-- ================================= 
          target: generate-db              
         ================================= -->
	<target name="gene