Missing output files after running Ant script from Eclipse

I have a simple web application developed in the Eclipse Luna. The directory structure of the application is like:

Project name is SchoolSchedule.

Under the project name, there are Java Resources, build, WebContent folders, and the build.xml file.

Under Java Resources, it is the "src" folder and my Java code package name is under the "src" folder.

Under the WebContent, there are META-INF, WEB-INF and my jsp files Under the WEB-INF, there are web.xml file and the "lib" directory.

The build.xml is at the project root. This web application runs successfully and produces expected results.

I created an Ant script to compile, build a WAR file, and deploy the WAR. But, even the basic task does not work. I right click on the build.xml --> run as ... --> Ant build. In the console, I can see all the echo messages and no error. However, I do not see any new directories created (I "refresh" the project.). No "class" files compiled from the Java code and not to mention build and deploy those tasks.

There is something I did not get it right. Please help. Here is my Ant script:

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

<project name="AntWarWebApp" basedir="." >

<echo>Define properties</echo> 
<property name="name" value="SchoolSchedule"/>
<property name="src" location="src"/>
<property name="web" location="WebContent"/>
<property name="build" location="build"/>
<property name="classDir" location="${build}/src"/>
<property name="distDir" location="${build}/dist"/>
<property name="warDir" location="${build}/war"/>

<property name="tomcat.webapps" value="C:apache-tomcat-7.0.70webapps" />

<echo>time stamp</echo> 
<tstamp prefix="build-info">
    <format property="current-date" pattern="d-MMMM-yyyy" locale="en" />
    <format property="current-time" pattern="hh:mm:ss a z" locale="en" />
    <format property="year-month-day" pattern="yyyy-MM-dd" locale="en" />
</tstamp>

<echo>clean up previous build directories</echo>    
<target name="clean" description="Delete old build directories">
    <delete dir="${distDir}"/>
    <delete dir="${warDir}"/>
    <delete dir="${classDir}"/>
</target>

<echo>create directories</echo>
<target name="init" depends="clean">
    <mkdir dir="${build}"/>
    <mkdir dir="${classDir}"/>
    <mkdir dir="${warDir}"/>
    <mkdir dir="${distDir}"/>
    <mkdir dir="${warDir}/WEB-INF"/>
    <mkdir dir="${warDir}/WEB-INF/classes"/>
</target>

<echo>start compiling</echo>        
<target name="compile" depends="clean, init" description="Compile main 
      source tree java files">
 <javac srcdir="${src}" destdir="${classDir}" />
    <classpath>
        <fileset dir="${basedir}/WebContent/WEB-INF/lib">
              <include name="*" />
        </fileset>
    </classpath>        
</target>

<echo>start building WAR file</echo>    
<target name="buildwar" depends="clean, init, compile">
    <war basedir="${wardir}" destfile="${distDir}/${name}.war"
     webxml="${wardir}/WEB-INF/web.xml">
        <webinf dir="${wardir}/WEB-INF/">
            <include name="**/*.jar" />
        </webinf>
        <manifest>
            <attribute name="Built-On" value="${build-info.current-date}" />
            <attribute name="Built-At" value="${build-info.current-time}" />
        </manifest>
    </war>
</target>
    <echo>end building WAR file</echo>   

<target name="deploy" depends="init, compile, buildwar" description="Deploy application">
   <delete dir="${tomcat.webapps}/*.war" />  
    <echo>copy WAR file to Tomcat deploy directory</echo>
    <copy file="${distdir}/*.war" todir="${tomcat.webapps}" />
</target>

</project>

Aren't you supposed to have some kind of top-level element

<project>
 ....
</project>

around all this?

链接地址: http://www.djcxy.com/p/44414.html

上一篇: 使用SQL查询分隔列表?

下一篇: 从Eclipse运行Ant脚本后缺少输出文件