---
title: "ant 使用说明"
author: "simon_zhang"
date: "2006-11-24T14:58:00Z"
tags: []
slug: "ant"
draft: false
lastmod: "2006-11-24T14:58:00Z"
id: 64920
url: "https://mogee.iteye.com/blog/64920"
---

###  build.propersties  
##源程序路径  
src=./src  
##所用的包  
lib=./lib  
devlib=./devlib  
wars=./wars  
##web应用目录  
webapp=./webapp  
debug=on  
##配置文件路径  
config=./config  
##classes路径  
classes.dir=./build/classes  
##部署路径  
j2ee.deploy=D:/bea/user\_projects/domains/mydomain/applications

##build.xml源码  
&lt;project name="CTWeb" default="all" basedir="."&gt;  
    &lt;property file="build.properties" /&gt;  
    &lt;path id="classpath"&gt;  
        &lt;pathelement location="${classes.dir}/" /&gt;  
        &lt;fileset dir="${lib}" includes="\*\*/\*.jar" /&gt;  
    &lt;/path&gt;  
    &lt;target name="prepare"&gt;  
        &lt;mkdir dir="${wars}" /&gt;  
        &lt;mkdir dir="${webapp}/WEB-INF/classes" /&gt;  
        &lt;mkdir dir="${webapp}/WEB-INF/lib" /&gt;  
    &lt;/target&gt;

    &lt;target name="compile" depends="prepare"&gt;  
        &lt;javac srcdir="${src}" destdir="${classes.dir}" deprecation="off" debug="${debug}" encoding="GBK" fork="true" memoryInitialSize="64m" memoryMaximumSize="128m"&gt;  
            &lt;classpath refid="classpath" /&gt;  
        &lt;/javac&gt;  
        &lt;copy todir="${classes.dir}" overwrite="true"&gt;  
            &lt;fileset dir="${src}"&gt;  
                &lt;include name="\*\*/\*.xml" /&gt;  
                &lt;include name="\*\*/\*.properties" /&gt;  
            &lt;/fileset&gt;  
        &lt;/copy&gt;  
    &lt;/target&gt;

    &lt;target name="war" depends="compile"&gt;  
        &lt;copy todir="${webapp}/WEB-INF/classes" overwrite="true"&gt;  
            &lt;fileset dir="${classes.dir}" /&gt;  
            &lt;fileset dir="${config}" /&gt;  
        &lt;/copy&gt;

        &lt;copy todir="${webapp}/WEB-INF/lib" overwrite="true"&gt;  
            &lt;fileset dir="${lib}" /&gt;  
        &lt;/copy&gt;

        &lt;jar jarfile="${wars}/webapp.war"&gt;  
            &lt;fileset dir="${webapp}"&gt;  
                &lt;include name="\*\*/\*" /&gt;  
            &lt;/fileset&gt;  
        &lt;/jar&gt;

    &lt;/target&gt;

    &lt;target name="jar" depends="compile"&gt;  
        &lt;jar jarfile="${wars}/webapp.jar"&gt;  
            &lt;fileset dir="${webapp}/WEB-INF/classes"&gt;  
                &lt;include name="\*\*/\*" /&gt;  
            &lt;/fileset&gt;  
        &lt;/jar&gt;  
    &lt;/target&gt;

    &lt;target name="all" depends="war"&gt;  
        &lt;copy todir="${j2ee.deploy}" overwrite="true"&gt;  
            &lt;fileset file="${wars}/webapp.war" /&gt;  
        &lt;/copy&gt;

    &lt;/target&gt;  
    &lt;target name="clean" description="clean create directory"&gt;  
        &lt;delete dir="./war" /&gt;  
        &lt;delete dir="${webapp}/WEB-INF/classes" /&gt;  
        &lt;delete dir="${webapp}/WEB-INF/lib" /&gt;  
        &lt;delete dir="${j2ee.deploy}/webapp.war" /&gt;  
    &lt;/target&gt;  
    &lt;target name="Weblogicstart" description=""&gt;  
        &lt;exec dir="D:/bea/user\_projects/domains/mydomain" executable="cmd.exe"&gt;  
            &lt;arg line="/c startWebLogic.cmd" /&gt;  
        &lt;/exec&gt;  
    &lt;/target&gt;  
    &lt;target name="Weblogicstop" description=""&gt;  
        &lt;exec dir="D:/bea/user\_projects/domains/mydomain" executable="cmd.exe"&gt;  
            &lt;arg line="/c stopWebLogic.cmd" /&gt;  
        &lt;/exec&gt;  
    &lt;/target&gt;  
&lt;/project&gt;