Eclipse Quick Pick Guide (3)

xiaoxiao2021-03-06  34

5. Using Ant Ant in Eclipse is a great batch command executor under the Java platform, which can easily automate compile, test, packaging, deployment, etc. A series of tasks, greatly increase the 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, put it in the root directory. Build.xml Defines the batch command to be executed by Ant. 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 Output ... ************************************************************ *************

Hello, Test ]> All rights "]]>

The above XML defines INIT, Compile, Test (Test), DOC (Generated Document), Pack (Package) task, which 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 project root directory), due to the junit.jar package, search the eclipse directory, find junit.jar, copy it into the Hello / Lib directory, add to the ClassPath in Ant: and then In the builder panel hooked Ant_build, remove Java Builder: Compile again, you can see the output of Ant on the console: BuildFile: f: /eclipse-projects/hello/build.xml

INIT:

Compile: [mkdir] create Dir: f: / Eclipse-Projects / Hello / Classes [Javac] Compiling 2 Source Files To f: / Eclipse-Projects / Hello / Classes

Test: [mkdir] created dir: f: / eclipse-projects / hello / report [junit] Running Example.Hellotest [JUnit] Tests Run: 1, Failures: 0, Errors: 0, Time Elapsed: 0.02 Sec

Pack: [mkdir] created Dir: f: / eclipse-projects / hello / dist [jar] building jar: f: /eclipse-projects/hello/dist/hello.jar

doc: [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 See: @todobuild SuccessFultotal Time: 11 Secondsant sequentially performs initialization, compile, test, package, generates 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-63772.html

New Post(0)