1. Ant build.xml example
Java代码
<project name="version" basedir="." default="generate.service">
<property environment="env"/>
<property name="dest.dir" value="build" />
<property name="dest.dir.classes" value="${dest.dir}/classes" />
<property name="axis2.home" value="${env.AXIS2_HOME}" />
<property name="repository.path" value="E:/Server/apache-tomcat-6.0.26/webapps/axis2/WEB-INF/services" />
<path id="build.class.path">
<fileset dir="${axis2.home}/lib">
<include name="*.jar" />
</fileset>
</path>
<target name="clean">
<delete dir="${dest.dir}" />
</target>
<target name="prepare">
<mkdir dir="${dest.dir}" />
<mkdir dir="${dest.dir.classes}" />
<mkdir dir="${dest.dir.classes}/META-INF" />
</target>
<target name="generate.service" depends="clean,prepare">
<copy file="src/META-INF/services.xml" tofile="${dest.dir.classes}/META-INF/services.xml" overwrite="true" />
<javac srcdir="src" destdir="${dest.dir.classes}" includes="org/**/**">
<classpath refid="build.class.path" />
</javac>
<jar basedir="${dest.dir.classes}" destfile="${dest.dir}/version.aar" />
<copy file="${dest.dir}/version.aar" tofile="${repository.path}/version.aar" overwrite="true" />
</target>
</project>
2. Ant target of Java
Java代码
<target name="run" depends="generate.SampleServiceClient">
<java fork="true" classname="org.apache.axis2.axis2userguide.SampleClient">
<classpath>
<path refid="build.class.path"/>
<path location="E:/reference/WebService/axis/Test/sample/client/build/SampleService.jar"/>
</classpath>
</java>
</target>
3. 使用ant和ivy编译一个项目时,运到 "problem: failed to create task or type antlib:org.apache.ivy.ant:settings" 时,需要将ivy-2.2.0.jar加到CLASSPATH中。