[闭月羞花猫]项目中,最简单的build.xml文件的书写方式

luyang1016 2007-06-15 04:19:03
闲来无事,写了几篇关于web开发过程中,一些基础的应用。
希望能够对初学者有所帮助。

不足的地方,也希望高手能够给与指正。

项目中,最简单的build.xml文件的书写方式。
项目source目录。

project
- src
- web
ant
- ant.bat
- bulid.xml
- project.war (编译出来的war 的位置)
====================================================================================================================================

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

<!--
# $Id: build.xml,v 1.4 2005/11/17 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.target.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="${compile.target.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="${compile.target.dir}"/>
</target>
-->

<target name="mkwar" depends="init, clean, prepare, copy, compile, war" />
</project>
...全文
210 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
luyang1016 2007-06-15
  • 打赏
  • 举报
回复
luyang1016@hotmail.com
gloomyfish 2007-06-15
  • 打赏
  • 举报
回复
猫,把你msn留下给我!
shan1119 2007-06-15
  • 打赏
  • 举报
回复
顶你来了.
freshlovesky 2007-06-15
  • 打赏
  • 举报
回复
顶!

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧