Ant Learning Note (vi) ant compiles the Web project and hits it as a war package while adding database operations

Source: Internet
Author: User
Tags mkdir create database


Build.xml

<?xml version= "1.0" encoding= "UTF-8"?> <project> <property name= "src.dir" location= "src" ></ property> <property name= "Build.dir" location= "Build" ></property> <property name= "Build.classes" location= "${build.dir}/classes" ></property> <property name= "Build.war" location= "${build.dir}/war" ></property> <property name= "web.name" value= "Hello" ></property> <property name= "Web.root" Value= "WebContent" ></property> <property name= "web. Web-inf "location=" ${web.root}/web-inf "></property> <property name=" Web.lib "location=" ${web. Web-inf}/lib "></property> <property environment=" env "></property> <path id=" Compile "> &L T;fileset dir= "${web.lib}" includes= "*.jar" ></fileset> <fileset dir= "${env. Catalina_home}/lib "includes=" *.jar "></fileset> </path> <target name=" init "> <delete dir=" ${ Build.dir} "></delete> <mKdir dir= "${build.dir}"/> <mkdir dir= "${build.classes}"/> <mkdir dir= "${build.war}"/> </target> <target name= "Compile" depends= "init" > <javac destdir= "${build.classes}" srcdir= "${src.dir}" classpathref= " Compile "></javac> </target> <target name=" war "depends=" compile "> <war destfile=" ${build.war }/${web.name}.war "> <fileset dir=" ${web.root} "includes=" **/*.* "></fileset> <lib dir=" ${web.lib} " ></lib> <webinf dir= "${web.
	
	Web-inf} "></webinf> <classes dir=" ${build.classes} "></classes> </war> </target> <presetdef name= "Sql-admin" > <sql userid= "root" password= "root" url= "jdbc:mysql://localhost:3306/hibernate ? useunicode=true&characterencoding=utf-8 "driver=" Com.mysql.jdbc.Driver "> <classpath refid=" Compile " ></classpath> </sql> </presetdef> <target name= "Init-mysql" > <sql-admin> <!
				--You can customize the SQL file to perform <transaction src= "Sql.sql" > <transaction> drop Database ant_test;
				Create Database ant_test; GRANT all on ant_test.* to "ant_test" @ "localhost" identified by ' 123 ' </transaction> </sql-admin> </t Arget> <target name= "Deploy" depends= "war" > <copy todir= "${env. Catalina_home}/webapps "> <fileset dir=" ${build.war} "includes=" ${web.name}.war "></fileset> </ Copy> </target> </project>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.