2010-10-07 61 views
1

我有一個Ant文件看起來像這樣:Ant目標是輸出過很多次

<?xml version="1.0" encoding="UTF-8"?> 
<project name="p" default="compile" basedir="."> 
<path id="compile.cliClasspath"> 
    <fileset dir="./WebContent/WEB-INF/lib"> 
     <include name="*.jar" /> 
    </fileset> 
</path> 

<target name="init"> 
    <!-- Create the time stamp --> 
    <tstamp /> 
</target> 

<target name="compile" description="compile the source" > 
    <javac srcdir="./src/" destdir="C:\TEMP\build"> 
     <classpath refid="compile.cliClasspath" /> 
    </javac> 
</target> 

<target name="createWar" depends="compile" description="create web archive"> 
    <war destfile="C:\TEMP\client.war" 
      webxml="./WebContent/WEB-INF/web.xml" 
      needxmlfile="true" 
      basedir="./WebContent" 
      excludesfile="./WebContent/WEB-INF/application.xml"> 
     <lib dir="./WebContent/WEB-INF/lib" /> 
     <classes dir="C:\TEMP\build" /> 
    </war> 
</target> 

<target name="createEar" depends="compile, createWar" description="create enterprise archive"> 
    <ear destfile="C:\TEMP\Client.ear" 
      appxml="./WebContent/WEB-INF/application.xml" 
      includes="C:\TEMP\Client.war" /> 
</target> 

<target name="cleanUp" depends="compile, createWar, createEar" description="clean up"> 
    <delete includeemptydirs="true"> 
     <fileset dir="C:\TEMP\build" includes="**/*" /> 
    </delete> 
</target> 
</project> 

的想法是要創建我的web應用程序的內容的耳朵。當我(在文件中運行與秩序,從伽利略)運行此我得到這個:

Buildfile: C:\Client-was7.xml 
     <snip>init: 

compile: 
     [javac] Compiling 47 source files to C:\TEMP\build 

compile: 
     [javac] Compiling 47 source files to C:\TEMP\build 

createWar: 
     [war] Building war: C:\TEMP\Client.war 

compile: 
     [javac] Compiling 47 source files to C:\TEMP\build 

createWar: 
     [war] Building war: C:\TEMP\Client.war 

createEar: 

compile: 
     [javac] Compiling 47 source files to C:\TEMP\build 

createWar: 
     [war] Building war: C:\TEMP\Client.war 

createEar: 

cleanUp: 
BUILD SUCCESSFUL 
Total time: 15 seconds 

爲什麼不是輸出:

 
init: 

compile: 

createWar: 

createEar: 

cleanUp: 
    BUILD SUCCESSFUL 
    Total time: 15 seconds 

謝謝

回答

3

我認爲這可能與取決於目標有關。當你運行create ear時,你首先運行compile,然後創建war,這也取決於compile等等。

+0

就是這樣。我發現添加作爲目標,並刪除其他依賴工作。謝謝 – volvox 2010-10-07 14:59:09

+0

創造耳朵只會依靠創造戰爭,而清理只會依靠創造耳朵。另外,我認爲清理應該刪除所有編譯的文件,而不是編譯,創建戰爭,應該在編譯之前運行。 – virgium03 2010-10-07 15:00:49

+0

現在很開心。也要更正清理目標。 – virgium03 2010-10-07 15:02:40