Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

How to use ant to create a war file

  • 28-07-2008 11:38PM
    #1
    Registered Users, Registered Users 2 Posts: 1,559 ✭✭✭


    Im trying to learn to use ant.

    I want to be able to use it to create a war file of a jsp and servlet web application.

    I gave it a try anyway and made a build.xml file and ran ant makewar.
    So it did make the war which I put in the tomcat webapps directory.

    Then I ran tomcat and saw that the directories belonging to the application weren't structured properly.
    There was no jsp directory , the classes directory was not inside web-inf but out on its own and there was no jsp directory.

    I cant find any tutorials on how to create a directory structure within a war using ant.

    Can someone help?

    cheers.

    Heres the build.xml file I created so far with the stuff wrong in it ie. no directory structure.
    <?xml version="1.0"?>
      <project name="Ant Tutorial" basedir="." default="compile">
    
      <property name="build" location="C:/tomcat6.0.14/webapps/Login1/build"/>
      <property name="warname" location="C:/tomcat6.0.14/webapps/Login1/Login.war"/>
    
      <target name="create" depends="delete">
        <mkdir dir="${build}"/>
    
      </target>
    
      <target name="delete">
    
        <delete dir="${build}"/>
    
      </target>
    
      <target name="compile" depends="create">
        <javac srcdir="web-inf/classes" destdir="${build}"/>
        
      </target>
    
      <target name="makewar" depends="compile">
        
        <war destfile="${warname}" basedir="${build}" webxml="web-inf/web.xml">
    	
    	
        <include name="**/*.*"/>
        <exclude name="**/*Test*"/>
      
    
    
    
    	
    	
    	</war>
      </target>
    
    </project>
    


Comments

  • Registered Users, Registered Users 2 Posts: 6,240 ✭✭✭hussey


    http://www.roseindia.net/jboss/buildingwebapplicationwithant.shtml

    all you need

    but looks like you are missing the copying of files
    <copy todir="${warDir}/WEB-INF/classes">
    <fileset dir="${classdir}" includes="**/*.class" /> 
    </copy>
    
    <copy todir="${warDir}/WEB-INF">
    <fileset dir="${deploymentdescription}" includes="web.xml" /> 
    </copy>
    
    <copy todir="${warDir}">
    <fileset dir="${web}" includes="**/*.*" /> 
    </copy>
    


  • Registered Users, Registered Users 2 Posts: 1,559 ✭✭✭quinnd6


    That is excellent thank you very much


Advertisement