ArticleDirectory
- 0. 1. To http://ant.apache.org/bindownload.cgi
- 0.2. Added System Variables
- 0.3. test installation
0. install 0. 1. to the http://ant.apache.org/bindownload.cgi under the ant, I used version is 1.70, extract the download file to your working directory, here to D: \ ant_home for example 0.2. new system variable
New system change volume: ant_home, content: D: \ ant_home \ apache-ant-1.70. Add the ant Bin object to the PATH environment variable: % ant_home % \ bin. To enable ant to support JUnit, You Need To directly change JUnit. jar is placed in ant's lib project. Remember to change the original settings of JUnit in classpath, for example, % ant_home \ Lib \ JUnit. jar, although there are other ways to set, but this is the fastest and most simple method. For Windows 2000/XP, set [system variables] in [System Content/advanced/environment variables] to complete the preceding settings,
Example: 0.3. test installation
Run cmd to go to the command line interface and run
<textarea readonly name="code" class="csharp">Ant</textarea> The following prompt is displayed, indicating that the installation is successful.
<textarea readonly name="code" class="csharp">E: \ srcgen \ webwork> ant <br/> buildfile: Build. XML does not exist! <Br/> build failed</textarea> Step 1: create the working directory anttest
D: \ Documents ents \ workspace \ anttest
Step 2: Create helloworld. Java
Package test. ant; <br/> public class helloworld {<br/> Public static void main (string [] ARGs) {<br/> // todo auto-generated method stub <br/> system. out. println ("helloword !! "); <Br/>}< br/>
Step 3:
In the anttest directoryPackage test. antCreate the Directory D: \ Documents ents \ workspace \ anttest \ SRC \ test \ ant and put helloworld. Java in it.
Step 4: Create build. xml
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <project name = "helloworld" default = "run" basedir = ". "> </P> <p> <property name =" src "value =" src "/> <br/> <property name =" DEST "value =" classes "/> <br/> <property name = "hello_jar" value = "hello1.jar"/> </P> <p> <target name = "init"> <br/> <mkdir dir = "$ {DEST}"/> <br/> </Target> </P> <p> <target name = "compile" depends = "init"> <br /> <javac srcdir = "$ {SRC}" destdir = "$ {DEST}" includeantruntime = "on"/> <br/> </Target> </P> <p> <target name = "build" depends = "compile"> <br/> <jar jarfile = "$ {hello_jar}" basedir = "$ {DEST}"/> <br/> </Target> </P> <p> <target name = "run" depends = "build"> <br/> <Java classname = "test. ant. helloworld "classpath =" $ {hello_jar} "/> <br/> </Target> </P> <p> <target name =" clean "> <br/> <delete dir = "$ {DEST}"/> <br/> <delete file = "$ {hello_jar}"/> <br/> </Target> </P> <p> <target name = "Rerun" depends = "clean, run "> <br/> <ant target =" clean "/> <br/> <ant target =" run "/> <br/> </Target> </P> <p> </Project> <br/>
Step 5: Go to CMD and execute ant
If you want to run the clean and rerun commands in build, you can run the following command:
Call clean:
Ant clean
Call Rerun:
Ant rerun