Eclipse quickly fingers the use of Ant

xiaoxiao2021-03-06  14

Ant is a very great batch command executor under the Java platform, which is very convenient to automatically complete compilation, test, packaging, deployment, etc., greatly improve development efficiency. If you haven't started using Ant yet, then you will start learning to use, so that your development level is a new level.

Ant has been integrated in Eclipse, we can run Ant directly in Eclipse.

Take the Hello project established as an example, create the following directory structure:

Create a build.xml and placed in the root directory. Build.xml defines the batch command to be executed. Although Ant can also use other file names, compliance can be more standardized and easy to communicate with others.

Typically, the SRC stores the Java source file, Classes stores compiled Class files, lib stores all JAR files for compilation and running, Web stores JSP, etc., DISS is stored, the packaged JAR file, and the DOC stores the API document.

Then create a build.xml file in the root directory, enter the following:

**************** **************************************************** ONE or more Tests Failed! Check the outprut ... **************************************************** ********************* < Target name = "doc" depends = "pack" description = "create API Doc"> Hello, Test ]]>

All rights "]]> The above XML defines INIT, Compile, Test (Test), DOC (Generated Document), Pack (Package) task, can be used as a template.

Select Hello Engineering, then select "Project", "Properties", "Builders", "New ...", select "Ant Build":

Fill in Name: Ant_Builder; BuildFile: Build.xml; Base Directory: $ {workspace_loc: / hello} (press "Browse Workspace" to select the root directory), search for the eclipse directory due to the junit.jar package, find junit.jar Put it into the Hello / Lib directory and add to the ClassPath in Ant:

Then hook Ant_build in the Builder panel, remove Java Builder:

Compiled again, you can see the output of Ant on the console:

Buildfile: f: /eclipse-projects/hello/build.xmlinit: Compile: [mkdir] create Dir: f: / eclipse-projects / hello / class [javac] compiling 2 Source Files to f: / Eclipse-Projects / Hello / ClasseStest: [MKDIR] Created Dir: f: / eclipse-projects / hello / report [junit] Running Example.Hellotest [JUnit] Tests Run: 1, Failures: 0, Errors: 0, Time Elapsed: 0.02 Secpa: [MKDIR] Created Dir: f: / Eclipse-Projects / Hello / Dist [Jar] Building Jar: f: /eclipse-projects/hello/dist/hello.jardoc: [mkdir] created Dir: f: / eclipse-projects / Hello / DOC [javadoc] Generating Javadoc [javadoc] Javadoc execution [javadoc] Loading source files for package example ... [javadoc] Constructing Javadoc information ... [javadoc] Standard Doclet version 1.4.2_04 [javadoc] Building tree for all the packages and Classes ... [javadoc] Building Index for all the packages and classes ... [javadoc] building index for all classes ... [javadoc] generating f: /eclipse-projects/hello/doc/stylesheet.css ... [javadoc] Note: Custom Tags That Could Override Future Standard tags:. (.) @todo To avoid potential overrides, use at least one period character in custom tag names [javadoc] Note:. Custom tags that were not seen: @todoBUILD SUCCESSFULTotal time: 11 secondsAnt in order to perform initialization, compile, test , Package, generate a series of tasks, which greatly improves development efficiency. When developing J2EE projects, you can also add tasks such as deployment. And, even if the Eclipse environment is separated, the environment variable is configured correctly, configure the environment variable Ant_home = , Path = ...;% ANT_HOME% / BIN, switch to the Hello directory at the command line prompt, simply type Ant can be.

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

New Post(0)