The aim of this tutorial is to give a quick introduction to Ant. We will look at the basics of a build file and go through some of the options available. Ant buildfile is very similar to nmake/name. Leave any questions or problems as comments and I will endeavour to answer them.
Assumptions
This article assumes that you have a compatible version of java (JDK) and Ant installed.
As an example we will use a simplified version of buildfile that is used to build the Web Services Example Using Axis2 and Tomcat.
1. <?xml version="1.0" encoding="UTF-8"?> 2. <project basedir="." default="build" name="Axis2TomcatHelloWorld"> 3. <property environment="env"/> 4. <property name="debuglevel" value="source,lines,vars"/> 5. <property name="target" value="1.5"/> 6. <property name="source" value="1.5"/> 7. <property name="AXIS2_HOME" value="D:/downloads/axis2-1.4.1-bin/axis2-1.4.1"/> 8. <property name="HelloWorldAar" value="axis2tomcathelloworld.aar"/> 9. <path id="Axis2TomcatHelloWorld1.classpath"> 10. <pathelement location="client_bin"/> 11. <pathelement location="web_bin"/> 12. <fileset dir="D:\downloads\axis2-1.4.1-bin\axis2-1.4.1"> 13. <include name="**/*.jar"/> 14. </fileset> 15. </path> 16. <target name="init"> 17. <mkdir dir="web_bin"/> 18. <copy includeemptydirs="false" todir="web_bin"> 19. <fileset dir="web_src" excludes="**/*.launch, **/*.java"/> 20. </copy> 21. <mkdir dir="client_bin"/> 22. <copy includeemptydirs="false" todir="client_bin"> 23. <fileset dir="client_src" excludes="**/*.launch, **/*.java"/> 24. </copy> 25. </target> 26. <target name="build" depends="build-service, build-client"/> 27. <target name="clean"> 28. <delete dir="web_bin"/> 29. <delete dir="client_bin"/> 30. <delete file="${HelloWorldAar}"/> 31. </target> 32. <target name="build-service" depends="init"> 33. <echo message="${ant.project.name}: ${ant.file}"/> 34. <javac debug="true" debuglevel="${debuglevel}" destdir="web_bin" source="${source}" target="${target}"> 35. <src path="web_src"/> 36. <classpath refid="Axis2TomcatHelloWorld1.classpath"/> 37. </javac> 38. </target> 39. <target name="build-client" depends="init"> 40. <antcall target="wsdl2java"/> 41. <javac debug="true" debuglevel="${debuglevel}" destdir="client_bin" source="${source}" target="${target}"> 42. <src path="client_src"/> 43. <classpath refid="Axis2TomcatHelloWorld1.classpath"/> 44. </javac> 45. </target> 46. </project> |
0 comments:
Post a Comment