Ant introduction and installation and configuration

Source: Internet
Author: User
-. 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


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.