---
title: "Ant：远程部署起项目来还是比较好用的"
author: "toprogrammer"
date: "2010-06-08T14:34:22Z"
tags: []
categories: ["编程语言"]
slug: "ant"
draft: false
lastmod: "2010-06-09T13:28:05Z"
id: 686987
url: "https://toprogrammer.iteye.com/blog/686987"
---

一.先下载最新的ant---http://ant.apache.org/

二.解压到C盘根目录下(这个要以根据需求调整),配置"ANT_PATH",并在PATH中添加：c:\ant\bin

三.检查jdk，JAVA_PATH,确保JAVA_PATH正确(否则会出错)

四.编写build.xml,放在ant目录下(根据需求调整)


<?xml version="1.0"?>
<project name="cppmec_bid" default="compile" basedir="D:\PRO\cppmec_bid">
	<!-- 加载属性文件  -->
    <property file="ant.properties"/>
	
	<!-- 配置属性  -->
	<property name="app.name"  value="cppmec"/>
	<property name="src.dir"   value="${basedir}\src"/>
	<property name="class.dir" value="${basedir}\webapp\WEB-INF\classes"/>
	<property name="lib.dir"   value="${basedir}\webapp\WEB-INF\lib"/>       
	<path id= "classpath"> 
          <fileset  dir="${lib.dir}"> 
                <include  name="*.jar"/> 
          </fileset> 
    </path>
	
	<!-- 编译目标  任务是javac编译  -->
	<target name="compile" depends="init">
		<javac destdir="${class.dir}" srcdir="${src.dir}">
		  	    <classpath   refid= "classpath"/> 
		</javac>
	</target>

	<!-- 初始化目标  任务是创建目录  -->
	<target name="init" depends="clean">
           <mkdir dir="${class.dir}"/>
    </target>
	
	<!-- 清除目标  任务是清除创建的目录  -->
    <target name="clean">
            <delete dir="${class.dir}"/>
    </target>
</project>



五.DOS进入ant目录(build.xml文件目录)下，输入ant命令，编译成功。