What is "ant" ANT

xiaoxiao2021-03-06  69

Ant Official Website: http://ant.apache.org/ant introduction Ant is a sub-project of the Apache project, is a Java-based build tool. ANT is similar to the Make tool, but there is no shortcoming of traditional Make tools. Traditional MAKE often can only be used on a platform. Ant itself implements the Java class. The project's profile to be constructed is described in XML format. It can easily implement multi-platform compilation, which is ideal for Build Large Works. 1. Installation Configuration Ant: Ant can be downloaded from http://ant.apache.org, the latest version is 1.5.3 (this is an introduction to version 1.5.2). After downloading, the directory is directly decompressed, the directory is as follows: Ant - bin // Contains Launcher Scripts | - LIB // Contains Ant Jars Plus Necessary Dependencies | - DOCS // Contains Documentation | - Ant2 // A Brief Description of Ant2 Requirements | || - Image // Various Logos for HTML Documentation | || - Manual // Ant Documentation (A Must Read) | - ETC Requires Environment Variables: Ant_Home: Ant Install the directory java_home: JDK installation directory PATH: Plug the% Ant_HOME% / bin directory to the PATH variable so that the ANT is run directly from the command line to assume the ANT is installed in C: / Ant JDK D: /J2SDK1.4.0 is in command The following command is executed: set Ant_home = C: / ANTSET JAVA_HOME = D: /J2SDK1.4.0Set Path =% PATH%; C: / Ant / BIN When working at Win2000 Command Tips, each time you must perform it. After setting, after exiting the command prompt, the values ​​of these variables will return to the original look. To avoid these troubles, you can set in the control panel / system / advanced / environment variable. Once the above setting is complete, Ant can be used. 2. Establish an engineering description file BUILD.XML is very convenient to build a large-scale project with ANT, each project corresponds to a build.xml file, which contains path information and tasks related to this project.

Here is an example of build.xml: The project to build is as follows: Struts_Demo - JSP | - SRC | - Web-INF | - Classes | || - LIB | || - Web.xml | - Build.xml Each build.xml file contains a Project and at least one target.

Target contains task elements, tasks are an executable code, and each task element has an ID property to facilitate reference in the file. Ant has built-in task sets available, such as Property, Javac, and War used in the above file, complete setting properties, compile and package tasks, respectively. Of course, if you need it, you can also write your own task. Build.xml's root element is Progject, which has three attributes name default basedir, where default is required. Name Specifies the name of the project, basedir represents the base path of the project, set to "." indicates the path where build.xml is located. Default represents the default target, if you do not specify a Target, use the Default Target.Property task to set the properties, one project can set a lot of properties, the properties are named and values, and the property is set to be referenced later. Set the attribute of a name to dist.name, its value is struts_demo, use $ {dist.name} reference when used, indicate string struts_demo. sets the properties of a name to src, which is a path, set with location. If the Location content begins with / or / or d: / c: /, it indicates the absolute path, otherwise indicates the relative path, which can set the path of the class with the PATH or CLASSPATH, which is referenced when referenced by the PROTO. Set the most commonly used ANT built-in task: MKDir: Create a directory, DIR = Directory to create Delete: Delete file or folder DIR = Document or folder Javac to delete: Compile Java source file, Java source file In the folder specified by Srcdir, the generated .class file is organized in the folder specified in the DESTDIR according to the Package statement. To pay attention to the directory organization of the source file to match the package statement: package the web application, DESTFILE specifies the file name generated after packaging, and WebXML specifies the web.xml file used. put all the files in the BaseDir directory in the build.xml example in the package, the property depends in the target of the target represents the target that must be done before this target, for example DIST's Depends = Compile means that you must compile with Compile before you pack it with a DIST.

转载请注明原文地址:https://www.9cbs.com/read-85369.html

New Post(0)