-. Ant Introduction
Ant is a make-like tool used to compile, run, and test Java programs.
In the process of building, packaging, and publishing, almost everything can be handled by ANT tasks. 2. installation and configuration of ant
You can download the pre-compiled ant from the jakata website and decompress it to any directory;
Set your environment variable, ant_home, to the decompressed directory;
Set the java_home environment variable to point to the JDK root directory. 3. When ant is used to manage the project, it automatically loads a project configuration file called build. xml. If you want to give the project configuration file another name, you can use the buildfile tag to run ant, as shown below:
Ant-buildfile project_configuration.xml
Main features:
Use the XML file as the configuration file, that is, build. xml;
Seamless integration with JUnit to achieve system testing, compilation, and release functions;
Powerful and detailed report functions;
Flexible control: allows you to customize a combination of tasks to be executed. Main node of build. xml: proejct Project
Name specifies the project name
Default specifies the default target (task)
Basedir specifies the system's basic path property, which is similar to a global variable.
Name variable name
Value variable value
Property access method: $ {property} built-in property:
Basedir project path.
Ant. File build file path.
Ant. Version
Ant. Project. Name project name
Ant. java. Version JVM version
Target, that is, the task
Name specifies the target name
Depends specifies the target
If conditions can achieve the purpose of controlling the process
Unless
Description
A short task.
Reference
Use the refID attribute to reference the built-in ID commands defined in other sections:
<Tstamp/> Creation Time
<Mkdir dir = "$ {var}"/> create a directory
Compile the file:
<Javac srcdir = "$ {SRC}" destdir = "$ {classes}" DEBUG = "off">
<Classpath refID = "appclasspath"/>
<Include name = "**/*. Java"/>
</Javac>
Execution file:
<Exec executable = "$ {base. dir}/email. Bat">
</Exec> JUnit command:
<JUnit>
<Classpath refID = "appclasspath"/>
<Classpath>
<Pathelement location = "$ {base. dir}/defaultroot/WEB-INF/classes"/>
</Classpath>
<Formatter type = "XML"/>
<Test name = "JUnit. Tests. alltests" haltonfailure = "no" OUTFILE = "result"/>
</JUnit>
<Junitreport todir = "./Report">
<Fileset dir = ".">
<Include name = "result. xml"/>
</Fileset>
<Report format = "noframes" todir = "./Report"/>
</Junitreport> 4: Run antant [Options] [target [TARGET2 [target3]...]
Options:
-Logfile <File> use given file for log
-L <File>''
-Buildfile <File> use given buildfile
-File <File>''
-F <File>''
-D <property >=< value> use value for given property
-Propertyfile <Name> load all properties from file with-d
Properties taking precedence