ant脚本

写了个常用ant脚本,占地儿

<?xml version="1.0" encoding="UTF-8"?>
<project name="Test" default="main" basedir=".">
<!-- =================================== -->
<!-- -->
<!-- ============================================= -->
<!-- put the ant properties to a properties file -->
<property file="*./build.properties"></property>
<!-- ================================================== -->

<!-- reference system envireonment variable ======-->

<!-- ===================================================-->
<!-- reference system envireonment variable -->
<!--<property name="tomcat.home" value="${env.JAVA_HOME}"/>-->
<!-- ===================================================-->

<property name="tomcat.home" value="D:/Program Files/Apache Software Foundation/Tomcat 5.5"/>
<property name="servlet.jar" value="${tomcat.home}/common/lib/servlet-api.jar"/>
<property name="jsp.jar" value="${tomcat.home}/common/lib/jsp-api.jar"/>

<property name="src.dir" location="./WEB-INF/src"></property>
<!--<property name="project.src" location="./src"></property>-->
<property name="build.dir" location="./WEB-INF/classes"/>

<!-- war file's name ====================================== -->
<property name="war.file" value="warfilename"></property>
<property name="war.file.name" value="${war.file}.war"/>
<!--======================================================== -->
<property name="deploy.dir" value="${tomcat.home}/webapps"/>
<property name="war-dist.dir" value="${tomcat.home}/webapps"/>
<!-- ============================================== -->
<!-- project's classpath -->
<!-- ============================================== -->
<path id="project.class.path">
<fileset dir="./WEB-INF/lib/">
<include name="**/*.jar"/>
</fileset>
<pathelement path="${servlet.jar}"/>
<pathelement path="${jsp.jar}"/>

<!-- allow to add other fileset -->
<pathelement path="${src.dir}"/>
<!-- <pathelement path="${project.src}"/> -->
</path>


<!-- ============================================== -->
<!-- ant's Target: Clean, to clear the class files -->
<!-- ============================================== -->
<target name="clean" description="delete the class files">
<delete dir="${build.dir}" includeEmptyDirs="true" />
</target>
<!-- ============================================== -->
<!-- ant's Target: Init, Create Build.Src directory -->
<!-- ============================================== -->
<target name="init" depends="clean" description="create build directory" >
<mkdir dir="${build.dir}"/>
</target>
<!-- ==================================================== -->
<!-- ant's Target: cleanWebApp, to clear war files -->
<!-- ==================================================== -->
<target name="cleanWebApp" description="delete the web application war file">
<delete file="${deploy.dir}/${war.file.name}" />
<delete dir="${deploy.dir}/${war.file}" includeEmptyDirs="true" />
</target>

<!-- ==================================================== -->
<!-- ant's Target: compile, to compile the project -->
<!-- ==================================================== -->
<target name="compile" depends="clean,init" description="compile the project">
<javac destdir="${build.dir}" debug="on" deprecation="on">
<src path="${src.dir}"></src>
<!--<src path="${project.src}"></src>-->
<include name="**/*.java"/>
<classpath refid="project.class.path"/>
</javac>
<copy todir="${build.dir}" preservelastmodified="true">
<fileset dir="${src.dir}">
<include name="**/*.xml" />
<include name="**/*.properties" />
</fileset>
<!--
<fileset dir="${project.src}">
<include name="**/*.xml" />
<include name="**/*.properties" />
</fileset> -->
</copy>
</target>

<!-- ===================================================== -->
<!-- ant's Target: war, compress the project to a war file -->
<!-- ===================================================== -->
<target name="war" depends="cleanWebApp,compile" description="compress the project to a war file">
<war warfile="${war-dist.dir}/${war.file.name}" webxml="./WEB-INF/web.xml">
<fileset dir="./" includes="**/*.*" excludes="*.war, **/*.nbattrs, web.xml, **/WEB-INF/**/*.*, **/project-files/**/*.*"/>
<webinf dir="./WEB-INF" includes="**/*" excludes="web.xml, **/*.jar, **/*.class"/>
<lib dir="./WEB-INF/lib"/>
<classes dir="${build.dir}"/>
<classes dir="${src.dir}">
<include name="**/*.properties"/>
</classes>
</war>
</target>
<!-- ===================================================== -->
<!-- ant's Target: deploy, to deploy the project for tomcat -->
<!-- ===================================================== -->
<target name="deploy" depends="war" description="deploy the project">
<copy todir="${deploy.dir}">
<fileset dir="./" includes="${war.file.name}"/>
</copy>
</target>

<!-- ===================================================== -->
<!-- ant's Target: deploy, to deploy the project -->
<!-- ===================================================== -->
<target name="main" depends="clean,init,cleanWebApp,compile,war,deploy" description="the default task of project"></target>
</project>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值