Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

How to use ant to create a war file

Options
  • 28-07-2008 11:38pm
    #1
    Registered Users Posts: 1,552 ✭✭✭


    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 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 Posts: 1,552 ✭✭✭quinnd6


    That is excellent thank you very much


Advertisement