In the project, ant is used to write the most basic build. xml file.

Source: Internet
Author: User
Tags create directory echo message

The simplest method of writing build. xml files in the project.
Project source directory.

Project
-Src
-Web
Ant
-Ant. bat
-Bulid. xml
-Project. War (location of the compiled war)
========================================================== ========================================================== ========================================================== ================

<? XML version = "1.0" encoding = "UTF-8"?>

<! --
# $ ID: Build. XML, V 1.4 07:25:33 luyang exp $
#
# Copyright (c) All Rights Reserved.
-->

<Project name = "Project Build" default = "makewar" basedir = ".">

<! -- =========== Prerequisite properties ================== -->
<Property file = "./common. properties"/>

<! -- Set the properties for source directories -->
<Property name = "src. All. dir" value = "../project/src"/>
<Property name = "Web. All. dir" value = "../project/Web"/>

<Property name = "src. Output. dir" value = "./Dist/src"/>
<Property name = "Web. Output. dir" value = "./Dist/Web"/>

<! -- Compile libraries directory -->
<Property name = "compile. Lib. dir" value = "$ {web. Output. dir}/WEB-INF/lib"/>
<Property name = "compile.tar get. dir" value = "$ {web. Output. dir}/WEB-INF/classes"/>

<! -- Compilation classpath -->
<Path id = "compile. classpath">
<Fileset dir = "$ {compile. Lib. dir}">
<Include name = "**/*. Jar"/>
</Fileset>
</Path>

<! -- =========== Executable targets ======================== -->

<! --
The "init" target evaluates "available" expressions as necessary
To modify the behavior of this script and print some information on
Screen
-->
<Target name = "init">
<Echo message = "--------- $ {project. Name }$ {project. Version} ---------"/>
<Echo message = ""/>
<Echo message = "Java. Class. Path =$ {java. Class. Path}"/>
<Echo message = "Java. Home =$ {java. Home}"/>
<Echo message = "user. Home =$ {user. Home}"/>
<Tstamp>
<Format property = "year" pattern = "YYYY"/>
<Format property = "date" pattern = "yyyy/mm/DD"/>
</Tstamp>
</Target>

<! -- Remove directory -->
<Target name = "clean" depends = "init" Description = "delete old build and DIST directories">
<Delete dir = "$ {SRC. Output. dir}"/>
<Delete dir = "$ {web. Output. dir}"/>
</Target>

<! -- Create directory -->
<Target name = "prepare" depends = "init">
<Mkdir dir = "$ {SRC. Output. dir}"/>
<Mkdir dir = "$ {web. Output. dir}"/>
</Target>

<! -- Copysource to output directory -->
<Target name = "copy" depends = "prepare">
<Copy todir = "$ {SRC. Output. dir}">
<Fileset dir = "$ {SRC. All. dir}"/>
</Copy>
<Copy todir = "$ {web. Output. dir}">
<Fileset dir = "$ {web. All. dir}" excludes = "**/*. Class"/>
</Copy>

<Delete dir = "$ {web. Output. dir}/WEB-INF/classes"/>
<Mkdir dir = "$ {web. Output. dir}/WEB-INF/classes"/>
</Target>

<! -- Compile -->
<Target name = "compile" depends = "copy" Description = "compile sources">
<Javac destdir = "zookeeper compile.tar get. dir}" srcdir = "$ {SRC. Output. dir}" Source = "1.4" target = "1.4">
<Include name = "**/*. Java"/>
<Classpath refID = "compile. classpath"/>
</Javac>

<Copy todir = "$ {web. Output. dir}/WEB-INF/classes">
<Fileset dir = "$ {SRC. Output. dir}" includes = "**/*. properties"/>
</Copy>
<Delete file = "$ {web. Output. dir}/WEB-INF/lib/servlet. Jar"/>
</Target>

<! -- Make war -->
<Target name = "war" Description = "make war">
<Jar destfile = "./Project. War" basedir = "$ {web. Output. dir}"/>
</Target>

<! -- Make jar
<Target name = "jar" Description = "make jar"> <jar destfile = "./Project. Jar" basedir = "zookeeper compile.tar get. dir}"/>
</Target>
-->

<Target name = "mkwar" depends = "init, clean, prepare, copy, compile, war"/>
</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.