tags:

views:

8

answers:

1

Hello

I've got an ant file which looks like this:

<?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> 

The idea being to create an ear with the content of my web app. When I run this (run as with order as in the file, from galileo) I get this:

    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

Why isn't the output:

init:

compile:

createWar:

createEar:

cleanUp:
    BUILD SUCCESSFUL
    Total time: 15 seconds

?

Thanks

+1  A: 

I think it may have to do with the depends targets. when you run create ear, you first run compile, and then create war, which also depends on compile and so on.

virgium03
That's it. I found that adding <target name="all" depends="init,compile,createWar,createEar,cleanUp"/> as a target and removing the other depends worked. Thanks
Mark Lewis
create ear will only depend on create war, and cleanup will only depend on create ear. also, i think cleanup should delete all the compiled files and not compile, create war, ear and should be run before compile.
virgium03
glad it works now. make corrections to the cleanup target too.
virgium03