Ant 构建 打包 发布

[b]Ant[/b]
[b]一.简介[/b]
[align=left]Ant,构建,打包,编译自动化工具。[/align][b]二.下载地址[/b][align=left] [url]http://ant.apache.org/[/url][/align][b]三.例子[/b][align=left]
[img]http://dl.iteye.com/upload/attachment/0082/0495/4983a729-2f74-3b61-8a85-b9446fe39677.jpg[/img][/align][align=left]图1.1 项目架构[/align]

#project name
app.NAME=OWNUSESYSTEM
app.name=OwnUseSystem

#tomcat home
tomcat.dir=D:/software/apache-tomcat-7.0.29-windows-x64/apache-tomcat-7.0.29

#compile path
build.dir=build
build.classes.dir=${build.dir}/classes

#source code path
source.dir=src
#config path
resource.dir=config
#output file
log.file=D:/ming.txt
#java path
java.lib.dir=C:/Program Files (x86)/Java/jdk1.6.0_13/jre/lib
#WebContent path
WebContent.dir=WebContent
WebContent.WebInf.dir=${WebContent.dir}/WEB-INF
WebContent.DB.dir=${WebContent.dir}/DB
WebContent.WebInf.classes.dir=${WebContent.WebInf.dir}/classes
WebContent.WebInf.lib.dir=${WebContent.WebInf.dir}/lib

#dist
dist.dir=ming
dist.db.dir=${dist.dir}/db

#sqlserver configuration
sqlserver.dbname=owern
sqlserver.username=sa
sqlserver.password=123


<?xml version="1.0" encoding="utf-8" ?>
<project name ="OwnUseSystem" default ="run" basedir ="."><!--默认调用run-->
<property file="build.properties"></property><!--引入文件用来 配置路径-->
<path id="compile_path"><!--定义环境变量-->
<fileset dir="${WebContent.WebInf.lib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${tomcat.dir}/lib">
<include name="servlet-api.jar"/>
</fileset>
<pathelement path="${build.classes.dir}" />
</path>
<target name="create" depends="clean"><!--创建文件目录-->
<echo message="create ming build "></echo>
<mkdir dir="${build.dir}"/><!--创建编译文件夹-->
<mkdir dir="${build.classes.dir}"/><!--创建编译文件夹 classes-->
<mkdir dir="${dist.dir}"/><!--create ming-->
<mkdir dir="${dist.db.dir}"/><!--创建ming文件夹 db-->
<mkdir dir="${WebContent.WebInf.classes.dir}"/><!--创建webinf classes-->
</target>
<target name="copyConfig" depends="create">
<copy todir="${build.classes.dir}">
<fileset dir="${resource.dir}" >
<include name="**/*.properties" />
<include name="**/*.xml" />
<!--<exclude name="applicationContext.xml" />-->
</fileset>
</copy>
<copy todir="${dist.db.dir}">
<fileset dir="${resource.dir}">
<include name="init.sql"/>
</fileset>
</copy>
<!-- execute the sql script -->
<sql
driver="com.mysql.jdbc.Driver"
url="jdbc:sqlserver://localhost/${sqlserver.dbname}"
userid="${sqlserver.username}"
password="${sqlserver.password}"
src="${dist.db.dir}/init.sql"
classpathref="compile.classpath">
</sql>
</target>
<target name="compile" depends="copyConfig">
<javac srcdir="${source.dir}" destdir="${build.classes.dir}" classpathref="compile_path">
<compilerarg line="-encoding UTF-8 "/>
</javac>
<copy todir="${build.classes.dir}">
<fileset dir="${source.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</copy>
<copy todir="${WebContent.WebInf.classes.dir}">
<fileset dir="${build.classes.dir}">
</fileset>
</copy>
</target>
<target name="war" depends="compile"><!--打war包-->
<war warfile="${dist.dir}/${app.name}.war" webxml="${WebContent.WebInf.dir}/web.xml">
<fileset dir="${WebContent.dir}"></fileset>
</war>
</target>
<target name="deploy" depends="war">
<echo message="deploy the project to a web server" />
<copy todir="${tomcat.dir}/webapps">
<fileset file="${dist.dir}/${app.name}.war"></fileset>
</copy>
</target>
<target name="run" depends="deploy"><!--启动tomcat-->
<echo message="start tomcat" />
<exec executable="cmd" dir="${tomcat.dir}/bin" failonerror="false"
output="${log.file}" append="true" >
<!-- <arg value="/c" /> -->
<env key="CATALINA_HOME" path="${tomcat.dir}"/>
<arg value="/c startup.bat" />
</exec>
</target>
<target name="clean"><!--清除构建目录-->
<echo message="basedir is ${basedir}"></echo>
<delete dir="${dist.dir}"></delete><!--清除目标路径-->
<delete dir="${WebContent.WebInf.classes.dir}"></delete>
<!--清除webcontent class路径-->
<delete dir="${build.dir}"></delete><!--清除编译路径-->
<delete file="${tomcat.home}/webapps/${app.name}.war" /><!--删除war包-->
<delete dir="${tomcat.home}/webapps/${app.name}" /><!--删除项目-->
</target>

</project>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值