Installing ant:
Download the binaries from http://jakarta.apache.org/ant/index.html, unzip them to a suitable directory.
Append /path/to/ant/bin to the PATH environment variable.
Append the .jar files in /path/to/ant/lib/ to the CLASSPATH environment variable. Set JAVA_HOME to point to the location of the JDK installation on the machine that the software is being installed on. Append /path/to/jdk/lib/* to the CLASSPATH environment variable.
Sample Directory Structure:
`Application
|--- bin = Compiled byte code directory all the compiled file will be placed here
|--- src = Java application source files
|--- lib = External library files (eg. jar files )
|--- build.xml = build description file
Sample build.xml
<project name="Project Name" default="test" basedir=".">
<description> Project description </description>
<target name="clean">
<delete dir="bin"/>
</target>
<!-- Create the build directory structure used by compile -->
<target name="init" depends="clean">
<!-- Create the time stamp -->
<tstamp/>
<mkdir dir="bin"/>
</target>
<path id="compile.classpath">
<fileset dir="lib/">
<include name="**/*.jar"/>
</fileset>
<pathelement path ="bin/;${classpath}"/>
</path>
<!-- Compile the java code from ${src} into ${build} -->
<target name="compile" depends="init" description="compile the source">
<javac srcdir="src/" destdir="bin/">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="test" depends="compile" description="Execute class">
<java classname="JavaTestClassName" fork="true" failonerror="true" >
<classpath refid="compile.classpath"/>
</java>
</target>
</project>
No comments:
Post a Comment