Ant

Java ANT Projects

Java ANT Project 1

Java ANT Examples

Java ANT EXAMPLE

How do I get started to use ant, Can you give me a "Hello World" ant Script?

adplus-dvertising
Previous Home Next

when you using Apache ant then first time you must download the most recent version of ant and after you download the ant, then you can use to unzip the file .The following are the steps :-

  1. After you install the j2sdk 1.4 or above. Actually the initial java version is using in Ant 1.4 and above.
  2. Set to JAVA_HOME an ANT_HOME to the directory your installed them respectively.
  3. Put %JAVA_HOME%/bin;%ANT_HOME%/bin on your Path. Use ${JAVA_HOME}/bin:${ANT_HOME}/bin on UNIX. yes, you can use forward slash on windows.
How to create a program of ANT.

Create a Simple program to calculate a multipale of two variables.

Use of Build.xml files.

Step1: If you want to test the build.xml file then you using to the Junit Liabrary files and compile file code is

<!-- Creates Javadoc -->
<target name="docs" depends="compile">
<javadoc packagenames="src" sourcepath="${src.dir}"
destdir="${docs.dir}">
<!-- Define which files / directory should get 
		  included, we include all -->
<fileset dir="${src.dir}">
	<include name="**" />
		</fileset>
		</javadoc>
	</target>

Step2: If you create a documet file then you using xml code is



<!-- Creates Javadoc -->
<target name="docs" depends="compile">
	<javadoc packagenames="src" sourcepath="${src.dir}"
	   destdir="${docs.dir}"><!-- Define which files / 
	   directory should get included,we include all -->
		 <fileset dir="${src.dir}">
			<include name="**" />
				</fileset>
     </javadoc>
</target>

Step3: If you create a jar file then you using code


<!--Creates the deployable jar file  -->
<target name="jar" depends="compile">
	<jar destfile="${dist.dir}\program1.jar" basedir=
"${build.dir}">
	 <manifest>
		<attribute name="Main-Class" value="test.Main"/>
			 </manifest>
	</jar>
</target>
<target name="main" depends="compile, jar, docs">
		<description>Main target</description>
</target>

Step4: If you create a mkdir file then using to the code:

<!-- Creates the  build, docs and dist directory-->
  <target name="makedir">
	  <mkdir dir="${build.dir}" />
		<mkdir dir="${docs.dir}" />
		<mkdir dir="${dist.dir}" />
  </target>

<!-- Creates the  build, docs and dist directory-->
	<target name="makedir">
		<mkdir dir="${build.dir}" />
		<mkdir dir="${docs.dir}" />
		<mkdir dir="${dist.dir}" />
	</target>
Previous Home Next