1. 打包文件内容
<?xml version="1.0" encoding="UTF-8"?>
<project name="newbssqyl" basedir="." default="makewar">
<property name="classpath_lib" value="WebContent/WEB-INF/lib" />
<property name="sources" value="${basedir}/src"/>
<path id="classpath">
<fileset dir="${classpath_lib}">
<include name="*.jar"/>
</fileset>
</path>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.6"/>
<property name="source" value="1.6"/>
<target name="init">
<property name="build" value="build/destination/webapp"></property>
<property name="src" value="src"></property>
<mkdir dir="${build}"/>
<mkdir dir="${build}\WEB-INF"/>
<mkdir dir="${build}\WEB-INF\classes"/>
<mkdir dir="${build}\WEB-INF\lib"/>
<copy todir="${build}">
<fileset dir="${basedir}\WebContent">
<include name="WEB-INF/**" />
<include name="**" />
</fileset>
</copy>
</target>
<target name="complie" depends="init">
<javac srcdir="${src}" destdir="${build}/WEB-INF/classes" classpathref="classpath">
</javac>
</target>
<target name="makewar" depends="complie">
<war warfile="${build}/newbssqyl.war" webxml="${build}/WEB-INF/web.xml">
<lib dir="${build}/WEB-INF/lib">
<include name="**" />
</lib>
<classes dir="${build}/WEB-INF/classes"/>
<fileset dir="${build}"/>
</war>
</target>
</project>
2. 将文件放到项目根目录中
\newbssqyl
3.运行命令
E:\刘庆\AntProjectTest\test\newbssqyl>ant makewar
Buildfile: E:\刘庆\AntProjectTest\test\newbssqyl\build.xml
init:
complie:
[javac] E:\刘庆\AntProjectTest\test\newbssqyl\build.xml:34: warning: 'includ
eantruntime' was not set, defaulting to build.sysclasspath=last; set to false fo
r repeatable builds
makewar:
[war] Building war: E:\刘庆\AntProjectTest\test\newbssqyl\build\destinatio
n\webapp\newbssqyl.war
BUILD SUCCESSFUL
Total time: 1 minute 59 seconds
E:\刘庆\AntProjectTest\test\newbssqyl>
OK 生成成功
修正文件
<?xml version="1.0" encoding="UTF-8"?>
<project name="newbssqyl" basedir="." default="makewar">
<property name="classpath_lib" value="WebContent/WEB-INF/lib" />
<property name="sources" value="${basedir}/src"/>
<path id="classpath">
<!--添加lib 中的jar 包到软件中-->
<fileset dir="${classpath_lib}">
<include name="*.jar"/>
</fileset>
<!--添加lib 之外的包-->
<fileset dir="D:\Tomcat 6.0\lib">
<include name="*.jar" />
</fileset>
</path>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.6"/>
<property name="source" value="1.6"/>
<target name="init">
<property name="build" value="build/destination/webapp"></property>
<property name="src" value="src"></property>
<mkdir dir="${build}"/>
<mkdir dir="${build}\WEB-INF"/>
<mkdir dir="${build}\WEB-INF\classes"/>
<mkdir dir="${build}\WEB-INF\lib"/>
<copy todir="${build}">
<fileset dir="${basedir}\WebContent">
<include name="WEB-INF/**" />
<include name="**" />
</fileset>
</copy>
</target>
<target name="complie" depends="init">
<!--添加源文件内容和编码utf-8 因为默是系统的本地时间-->
<javac srcdir="${src}" destdir="${build}/WEB-INF/classes" encoding="utf-8" classpathref="classpath">
</javac>
</target>
<!--生成war 包结构-->
<target name="makewar" depends="complie">
<war warfile="${build}/newbssqyl.war" webxml="${build}/WEB-INF/web.xml">
<lib dir="${build}/WEB-INF/lib">
<include name="**" />
</lib>
<classes dir="${build}/WEB-INF/classes"/>
<fileset dir="${build}"/>
</war>
</target>
</project>
分享到:
相关推荐
我的开发环境是Eclipse,ant.xml是放在项目下的ant(新建),也可以修改project的basedir.
ant的使用,附件是build.xml,配置是怎么为web项目打包为war。
ant的构建文件。打成war包,并且自动部署到tomcat上,只需要重新启动Tomcat项目就已经发布运行了。可以用ant命令执行此文件,也可以用eclipse执行。
ant默认执行build.xml文件 ant是使用的java文件编写,所以具有跨平台的特性。 再使用ant执行build.xml时必须在java的jre下的lib下的ext安装路径 把servlet-api.jar拷贝进去。 重新使用build.xml 命令打包即可.不然...
ant默认执行build.xml文件 ant是使用的java文件编写,所以具有跨平台的特性。 再使用ant执行build.xml时必须在java的jre下的lib下的ext安装路径 把servlet-api.jar拷贝进去。 重新使用build.xml 命令打包即可.不然...
使用Ant技术对java项目进行打包,打成war包用来部署到web服务器
gwt_ant_build脚本研习 目录 build.xml源文件 构建工程war的分析 自定义的build工程文件
若文件名为hello.xml时,读者还需要对命令做少许改变,改为:ant –f hello.xml sayHelloWorld、ant –buildfile hello.xml sayHelloWorld或ant –file hello.xml sayHelloWorld。 接下来开始向读者讲解本节的重点...
1. Ant是什么?2. 安装Ant3. 运行Ant4. 编写build.xml5. 内置task(internet)6. EAR task(internet)7. WAR task(internet)8. JUnit task(internet)
每个ant脚本(缺省叫build.xml)中设置了一系列任务(target):比如对于一个一般的项目可能需要有以下任务。 * 任务1:usage 打印本脚本的帮助信息(缺省) * 任务2:clean 清空初始化环境 * 任务3:javadoc <-- ...
站点生成和报告 (Site Generation and Reporting) 3.6. 小结 4. 定制一个Maven项目 4.1. 介绍 4.1.1. 下载本章样例 4.2. 定义Simple Weather项目 4.2.1. Yahoo! Weather RSS 4.3. 创建Simple Weather...
build.xml ant 构建文件提供了各种要生成的目标。 因此,您可以利用它并使用 ant 构建文件和ant 工具来生成 WAR 文件。 ## 部署 一旦生成了 WAR 文件,只需将它放到您喜欢的 WAR 容器的适当目录中即可使其工作。 ...
Helloworld战争Java WAR项目/模板项目的示例包含: Helloworld Servlet(使用注释) 静态html文件示例最基本的web.xml 编译时servlet-api.jar(因此不需要Java EE) 用于构建WAR的Ant build.xml 使用slf4j-api和sl4j...
事实上,在Eclipse中使用Jocky时,Jocky也是首先针对所选工程生成Ant的Build文件(默认名称jocky_build.xml),然后再通过Ant完成混淆编译。 以下是Jocky在Eclipse中自动生成的Ant Build 文件示例: 1 ...
Ant介绍以及基本使用指南,jar,war打包语法,打包的注意事项,及bulid.xml的做成。
目录里面的 web.xml 文件里 的配置)。 下面是重新创建 cruisecontrol.war 的步骤: 假使我们用 Tomcat 4.1.30 作为JSP 服务器,该版本的Tomcat 支持 JSP1.2 规范,因此需要修 改%CC_HOME%\reporting\jsp\...
POM:POM(pom.xml)是Maven的核心文件,它是指示Maven如何工作的元数据文件,类似于Ant中的build.xml文件。POM文件位于每个工程的根目录中。 GroupId:groupId是一个工程的在全局中唯一的标识符,一般地,它就是...
also contains a build.xml file from which the WAR file can be built using Ant. Use the dist target to compile the sources and build the WAR file: > ant dist Each chapter WAR file has an index file ...
15.2. Importing XML Configuration 16. Auto-configuration 16.1. Gradually Replacing Auto-configuration 16.2. Disabling Specific Auto-configuration Classes 17. Spring Beans and Dependency Injection 18. ...