Eclipse Ant Build Project

Source: Internet
Author: User
Tags log4j

Main content:

1 Java build tools ant

2 Ant's Projects,targets,tasks,properties

3 Simple ant Build file

5.3.1
XML and HTML
Xml:extensible Markup Language Extensible Markup Language
1 HTML shows how to display data on a Web page, and he defines a standard set of labels.
2 HTML tags have a start tag, you can have no end tag such as: "P" can also "P" and XML must match the start and end tags
3 The label of the XML must be nested correctly and the HTML will not have to be as follows: "B" "I" this isn't valid in XML "/b" "/I"
4 XML tags are case sensitive, HTML is not

Element: A start tag and an end tag define an element.
Attribute: The name-value pair in the start tag is a property
Annotations in XML: "! --Do something--"
The writing of empty elements: "java classname=" Hello.class ""/java "or" Java classname= "Hello.class"/"
5.3.2 Ant's Default build profile is Build.xml
Run ant script in Eclipse: Right-click on Build.xml to select Run ant to display results in the console
Ant is integrated into eclipse and if you want to get a new version of Ant, its download address is: http://ant.apache.org
A "Project"
Property describes whether you must
Default target Y to run
Name Project name N
Basedir Base Directory N
Description Project Description N
Property

"Project Name=" Hello "default=" Compile "basedir=". description= "Hello,world Build File"
‘.’ Represents the directory where Build.xml is located.
Tags that can be nested "description" target "property"

B Targets
Property describes whether you must
Name Target name Y
Depends dependencies list N
If specifies that the property is set to execute N
Unless executes N when the specified property is not set
Description Target Description N

Target Name= "compile" depends= "init" description = "Compile all sources"

C Tasks

"BuildNumber" reads the built counter from the file. Each build counter plus a write back file

Property describes whether you must
File Read Property default Build.number N

"BuildNumber file=" Buildnum.txt "/"

Copy Task properties
Property describes whether you must
File source filename Y unless you use the Fileset
ToFile target filename Y unless you are using Todir
Todir target directory Y, if more than 1 files
Overwrite overwrite newer target file N, default False
Includeemptydirs Copy Empty directory N, default True
FailOnError file not found stop build N, default True
Verbose list copy file N, default False

"Copy file=" log4j.properties "todir=" Bin "/"
Copy copies a file property copy a set of files "Fileset" element nesting

Delete Task properties
Property describes whether you must
File Y to delete, unless it is dir or fileset
Dir to delete the directory Y, unless file Fileset
Verbose Delete file list N, default false
FailOnError has error stopping at N, default true
Includeemptydirs deleted directory When fileset specifies N, default false

"Delete file=" Ant.log "/"
"Delete dir=" temp "/"
Delete Deletes a file using the files attribute, a set of files with the Fileset element nesting or directory

Echo Task properties:
"Echo" to the terminal, file writing information
Property describes whether you must
Message Info Y, unless text as element content
File Output Files N
Append whether to append to file N, default False
"Echo messag=" Hello "/"
"Echo" This is a message form ant "/echo"

Jar Task Properties:
Jar compresses a set of files into a jar file
Property describes whether you must
DestFile jar filename Y
Basedir the directory to be packaged N
Includes contains file N
Excludes excluded files N

Jar destfile= Dist/persistence.jar "basedir=" Bin "includes=" org/ecli/persis/**,org/ecli/astr/** "excludes=" * Text*.class "/"
Jar destfile= "Dist/persistence.jar"
include name= "**/*.class"/"
Exclude Name=" **/* test* "/"
/jar
Java task properties:
Java can be nested element "Classpath" is used to override Classpath properties
Properties    description   must
ClassName the class name   y to run, unless you specify the jar  y to be executed by the jar
jar , unless you specify the classpath   N
Classpath used by the Clsssname
fork  Whether to use newer JVM N, default false
FailOnError error occurs stop N, default false
output  output file   n
append  append or overwrite default file n
Java classname= "HelloWorld"/"
Java classname=" Add "classpath=" ${basedir}/bin "
Arg value=" 100 "/"
Arg Value= "200"/"
/java"
Arg "specify command-line arguments

Javac Task properties:
Javac compile Java files can be nested elements "classpath" "Jar"
Properties    description   must
srcdir   source directory   Y, unless SRC uses the
destdir   output directory n
includes  contains compiled file n, default contains all Java files
excludes  ignored files n
classpath  uses the classpath n
debug   contains debug information N, default false
optimize  uses optimization n, default false
verbose    provide verbose output n
failonerror  If error occurs stop N, default true

Javac srcdir= "src" destdir= "bin"/"
Javac srcdir=" ${basedir} "destdir=" Bin "
includes=" org/eclipseguide/ persistence/** "
excludes=" **/*test* "
Classpath"
pathelement path= "${java.class.path}"/"
Pathelement location=
"D:/log4j/jakarta-log4j-1.2.8/dist/lib/log4j-1.2.8.jar"/"
/classpath"
"/javac"
Javadoc Task properties:
Javadoc produces Javadoc documents from Java source files, nested elements are "Fileset" "Packageset" "Classpath"
Properties   Description     Whether you must
SourcePath source path y unless you specify sorcefiles,sorcepathref
Sourcepathref source path reference y unless you specify Sorcepath,sorcefiles
SourceFiles source file, comma-delimited y unless specified sorcepath,sorcepathref
destdir  target y unless specified Doclet
Classpath class path N
Public   Show only public classes, Member N
protected only display protected, public class, member N, default True
package  only show package, protected, public class, member N
private  Show all classes, member N
version  contains version information n
use  contains use information n
author  contains author information n
FailOnError error occurs stop N, default true

"Javadoc destdir=" Doctest "
sourcefiles=
"Src/org/eclipseguide/persistence/objectmanager.java"/"
"Javadoc destdir=" Doc "
Author= "true"
Version= "true"
Use= "true"
Package= "true"
"Fileset dir=" "${src}/org/eclipseguide/astronomy/"
"Include name=" **/*.java "/"
"Exclude Name=" **/*test* "/"
"/fileset"
"Classpath"
"The Pathelement path=" ${java.class.path} "/"
"Pathelement location=
"D:/log4j/jakarta-log4j-1.2.8/dist/lib/log4j-1.2.8.jar"/"
"/classpath"
"/javadoc"

"MkDir" Create a Directory
Property describes whether you must
Dir to build the directory Y
"MkDir dir=" Dist/doc "/"
"Tstamp" time stamp
Dstamp YYYYMMDD
Tstamp HHMM
Today MMM DD yyyy
C Property
Attributes can be written in a file, specified and read with the property file= "Build.properties"
# build.properties
junit_home=d:/junit/junit3.8.1
log4j_home=d:/log4j/jakarta-log4j-1.2.8
You can use this:
Property file= "Build.properties"/"

D Fileset
Wildcard characters in "Fileset"
'? ' any one character
' * ' 0 or more characters
' * * ' 0 or more directories
Property describes whether you must
Dir directory Y
Includes contains file N
Excludes exclude file N
"Fileset dir=" src/org/eclipseguide/astronomy "
Includes= "**/*.java"
excludes= "**/*test*"/"
"Fileset dir=" "src/org/eclipseguide/astronomy/"
"Include name=" **/*.java "/"
"Exclude Name=" **/*test* "/"
"/fileset"

E Classpath
Property describes whether you must
Path Path N
Location standalone file or directory N
"Classpath path=" ("Bin")
"Classpath"
"The Pathelement path=" ${java.class.path} "/"
"The Pathelement location=" ${junit_path} "/"
"The Pathelement location=" ${log4j_path} "/"
"/classpath"
F refID
Ant element can set an ID, you can use this ID to reference this element
Set Classpath
"Classpath id=" "Common_path"
"The Pathelement path=" ${java.class.path} "/"
"The Pathelement location=" ${junit_path} "/"
"The Pathelement location=" ${log4j_path} "/"
"/classpath"
Reference:
"Javac srcdir=" src "destdir=" bin "
"Classpath refid=" Common_path "/"
"/javac"

Related Article

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.