xml Eclipse动态Web项目的简单Ant构建脚本#java #ant #snippet
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml Eclipse动态Web项目的简单Ant构建脚本#java #ant #snippet相关的知识,希望对你有一定的参考价值。
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="package" name="PROJECT_NAME">
<!--
This script assumes:
1) CATALINA_HOME environment variable points to tomcat's directory
2) Following Folder Structure
./ (project root)
|- src/ (project.src.dir - source folder)
|- build/
| |- classes/ (project.classes.dir)
|- WebContent/ (project.web.dir)
| |- lib/ (project.lib.dir)
|- PROJECT_NAME.war (project.war)
3) JAVA_HOME is set and point to JDK 1.6 and above
-->
<property environment="env" />
<property name="TOMCAT_HOME" value="${env.CATALINA_HOME}" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.6" />
<property name="source" value="1.6" />
<property name="project.name" value="${ant.project.name}" />
<property name="project.web.dir" value="WebContent" />
<property name="project.src.dir" value="src" />
<property name="project.classes.dir" value="build/classes" />
<property name="project.lib.dir" value="${project.web.dir}/WEB-INF/lib" />
<property name="project.war" value="${project.name}.war" />
<property name="project.runtime.lib" value="${TOMCAT_HOME}/lib" />
<property name="project.deploy.location" value="${TOMCAT_HOME}/webapps" />
<path id="classpath.runtime">
<fileset dir="${project.runtime.lib}" includes="*.jar" />
</path>
<path id="classpath.lib">
<fileset dir="${project.lib.dir}" includes="*.jar" />
</path>
<path id="project.classpath">
<pathelement location="${project.classes.dir}" />
<path refid="classpath.runtime" />
<path refid="classoath.lib" />
</path>
<target name="init">
<mkdir dir="${project.classes.dir}" />
<copy includeemptydirs="false" todir="${project.classes.dir}">
<fileset dir="src">
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${project.classes.dir}" />
<delete dir="${project.war}" />
</target>
<target depends="init" name="build" description="Compiling all java files in ${project.src.dir}">
<echo message="${project.name}: ${ant.file}" />
<javac debug="true" debuglevel="${debuglevel}" destdir="${project.classes.dir}" includeantruntime="false" source="${source}" target="${target}">
<src path="src" />
<classpath refid="project.classpath" />
</javac>
</target>
<target depends="build" name="package" description="Packagign all files into ${project.war}">
<war destfile="${project.war}" index="true" needxmlfile="fasle">
<classes dir="${project.classes.dir}" />
<lib dir="${project.lib.dir}" />
<fileset dir="${project.web.dir}">
<include name="**/*.*" />
</fileset>
</war>
</target>
<target depends="package" name="deploy" description="Copying ${project.war} to ${project.deploy.location}">
<copy file="${project.war}" todir="${project.deploy.location}" />
</target>
</project>
以上是关于xml Eclipse动态Web项目的简单Ant构建脚本#java #ant #snippet的主要内容,如果未能解决你的问题,请参考以下文章
用eclipse创建动态web项目手动生成web.xml方法
Eclipse Java 动态 Web 项目的 Web.xml 中的错误 [创建新项目时]
build.xml是啥
用ant怎么把web项目打成war或者是jar包
eclipse导入web项目,web.xml报错
eclipse下开发简单的Web Service