Ants with Ant, have to say (1)

zhaozj2021-02-16  60

Apache Ant: Apache Ant Is A Java-Based Build Tool. In Theory, IT IS Kind of Like Make, But Without make's Wrinkles

The above is the official definition, it is white, it is compilation tool, free, and efficient.

I specifically define it for writing EJB: Build.xml

Everyone knows that when Ant is a project, you must write an XML. In order to save money, do not buy JBuilder, develop tools: IDEA, NetBean and Eclipse, I am not very familiar with Eclipse, for JB and IDEA More, however, in the general compiler, we can't form two JAR files, if you plan to use EJB, and you are ready to use distributed deployment, you will have to create a new generation from your EJB's client. The JAR file does not contain yourejbnamebean. Also deploying EJB on JBoss, you must include two XML files in your meta-inflicity: ejb-jar.xml and jboss.xml, in jbuilder, you can freely increase the XML files in Jar, don't work in IDEA And Ant can be arbitrarily increased.

In order to achieve the above two purposes, I preplute the build.xml file as follows:

BUILD.XML of Jakarta-Ant-1.6alpha in Ant

Copyright (c) 2002 The Neusoft Software Foundation. All Rights Reserved.

============================================================================================================================================================================================================= ==========

->

The document structure is:

Definition of global variable

...

Task Group (Tasks)

a Java Assistant task

...

A other task

...

Project represents a project,

Default: Target (task group) running to the name "dist"

Basedir: Benchmark path.

->

Define properties (Property Tasks)

It is best to use the path, the name is defined here into a global variable.

Example: Definition

You can use it in the future:

Now: b == "Hello / B"

============================================================================================================================================================================================================= =========

->

"DOCS directory" - app ->

Define a set of paths after you can reuse this set of paths, for example:

->

INIT Preparation Directory (File Tasks)

The main directory structure is usually not changed, build them together

->

============================================================================================================================================================================================================= ==== Build the code (Compile Tasks, File Tasks)

============================================================================================================================================================================================================= ====

->

============================================================================================================================================================================================================= ===========

Copy-related deployment XML file to meta-inf

->

Tofile = "$ {build.classes.metainf} /ejb-jar.xml" />

Tofile = "$ {build.classes.metainf} /jboss.xml" />

============================================================================================================================================================================================================= ======= Packing document (Archive Tasks)

Create The Project Jars: xxx1.jar and xxx2.jar

============================================================================================================================================================================================================= ==========

->

COM / collegesoft / training / ejb / helloejb / hellobean.class "/>

============================================================================================================================================================================================================= ===========

Creates the API Documentation

============================================================================================================================================================================================================= ============ ->

Depends = "jars"

Description = "-> Creates the API Documentation>

SourcePath = "$ {src.main}"

DEFAULTEXCLUDES = "YES"

destdir = "$ {build.docs.api}"

Author = "True"

Version = "True"

Use = "true"

Windowtitle = "DOCS API">

Hello Ant Docs API ]>

$ {app.copyright} ]>

============================================================================================================================================================================================================= ====

Create The Distribution That Can Run (Archive Tasks)

Mainly from the Copy's COPY from each directory

============================================================================================================================================================================================================= === ->

============================================================================================================================================================================================================= ====

Cleans Everything (File Tasks)

For example, you can delete files in build, leave it to you.

============================================================================================================================================================================================================= ====

->

Many people start watching this document at first, it will not be able to touch it, it is very simple, first explain it.

OK, let's find the label of the Name = "dist" Target:

The other information is described in this label, which shows that the Javadocs tag must be completed before doing this action, then we continue to find target name = "javadoc" tag, according to this class, finally discovered The first execution is init this Target, so when writing Builder.xml, he wrote, because actual Ant is executed, starting from him.

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

New Post(0)