Download Eclipse JAR Javadoc deployment package build tool Apache Ant

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
5
Eclipse
JAR
Javadoc
deployment package
build tool
Ant
Apache
Ant
http://ant.apache.org/
Java
Ant
JAR
Ant
Eclipse
Ant
Java
Ant
Ant
Eclipse
Ant
Ant
Ant
Ant
Ant
Eclipse
main()
Ant
Ch05_01
No worries.
Ch05_01
5-1
125
126
5-1
package org.eclipsebook.ch05;
public class Ch05_01 {
public static void main(String[] args) {
System.out.println("No worries.");
}
}
Ant
Ant
build.xml
New
build.xml
File
File name
Finish
Eclipse
XML
Ant
Ant
Ant
XML
XML
Eclipse
build.xml
XML
Ant at work!
Ant
build.xml
Ant
Ant
5-1
127
<?xml version = "1.0" encoding="UTF-8" ?>
<project name = "Ch05_01" default = "Main Build">
<target name = "Main Build">
<echo message = "Ant at work!" />
</target>
</project>
XML
Main Build
default target
<target>
Ant
Java
method
Ant
5-2
XML
Ant
Ant
JDT
Outline
build.xml
outline
build.xml
Ch05_01 build.xml
Run Ant
5-3
Main Build
128
Run
Ant
Console
Build le: D:\eclipse211\eclipse\workspace\Ch05_01\build.xml
Main Build:
[echo] Ant at work!
BUILD SUCCESSFUL
Total time: 430 milliseconds
Eclipse
Ant
JAR
Ant at work!
Eclipse
Ant
JAR
Eclipse
Ant
JAR
Eclipse
Ant
129
Ant
Eclipse
Ant
Ant
http://ant.apache.org/manual/index.html
Eclipse
Java
Ant
JAR
.class
Java
Ch05_02
src
bin
New Java Project
Source
Folder
Add Folder
Create New
New Folder
Folder name
src
OK
Eclipse
Yes
Ch05_02/bin
Finish
src
Ch05_02
bin
org.eclipsebook.ch05
main()
This code was built using Ant.
5-2
5-2
package org.eclipsebook.ch05;
public class Ch05_02 {
public static void main(String[] args) {
System.out.println("This code was built using Ant.");
}
}
Package Explorer
build.xml
New
File name
Ant
XML
declaration
build.xml
File
Finish
build.xml
<project>
Main Build
<?xml version="1.0" encoding = "UTF-8"?>
<project name="Ch05_01" default="Main Build" basedir=".">
.
.
.
</project>
130
property
JAR
JAR
jardir
bin
jar le
build.compiler
src
lib
Ant
JDT
adapter
<?xml version="1.0" encoding = "UTF-8"?>
<project name="Ch05_01" default="Main Build" basedir=".">
<property name="bin" location="bin"/>
<property name="src" location="src"/>
<property name="jardir" location="${bin}/lib"/>
<property name="jar le" location="${jardir}/Ch05_02.jar"/>
<property name="build.compiler"
value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
.
.
.
</project>
Main Build
Ant
JAR
Compile
depends
JAR
Ch05_02.jar
org.eclipse.jdt.core.JDTCompilerAdapter
Initialize
bin
JAR
Jar
attribute
Ant
Ant
<?xml version="1.0" encoding = "UTF-8"?>
<project name="Ch05_01" default="Main Build" basedir=".">
<property name="bin" location="bin"/>
<property name="src" location="src"/>
<property name="jardir" location="${bin}/lib"/>
<property name="jar le" location="${jardir}/Ch05_02.jar"/>
<property name="build.compiler"
value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<target name="Main Build" depends="Initialize, Compile, Jar">
<echo message="Ant at work!"/>
</target>
.
.
.
</project>
131
Initialize
${bin}
${jardir}
<target name="Initialize">
<delete dir="${bin}"/>
<delete dir="${jardir}"/>
<mkdir dir="${bin}"/>
<mkdir dir="${jardir}"/>
</target>
Compile
${src}
Ch05_02.java
.class
${bin}
<target name="Compile" depends="Initialize">
<javac srcdir="${src}"
destdir="${bin}">
</javac>
</target>
Jar
Ch05_02.class
${jar le}
JAR
Initialize
Compile
<target name="Jar" depends="Initialize, Compile">
<jar dest le="${jar le}" basedir="${bin}"/>
</target>
build.xml
5-3
5-3
Ant
<?xml version="1.0" encoding = "UTF-8"?>
<project name="Ch05_01" default="Main Build" basedir=".">
<property name="bin" location="bin"/>
<property name="src" location="src"/>
<property name="jardir" location="${bin}/lib"/>
<property name="jar le" location="${jardir}/ch05_01.jar"/>
<property name="build.compiler"
value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<target name="Main Build" depends="Initialize, Compile, Jar">
<echo message="Ant at work!"/>
</target>
<target name="Initialize">
<delete dir="${bin}"/>
132
5-3
Ant
<delete dir="${jardir}"/>
<mkdir dir="${bin}"/>
<mkdir dir="${jardir}"/>
</target>
<target name="Compile" depends="Initialize">
<javac srcdir="${src}"
destdir="${bin}">
</javac>
</target>
<target name="Jar" depends="Initialize, Compile">
<jar dest le="${jar le}" basedir="${bin}"/>
</target>
</project>
Eclipse
XML
Ant
manifest
11~12
manifest
plugin.xml
manifest
Create Ant Build File
XML
Outline
build.xml
5-4
Package Explorer
5-5
Ant
Run
build.xml
Ch05_02 build.xml
Ant
Main Build
Run
5-6
Console
Console
Build le: D:\eclipse211\eclipse\workspace\Ch05_02\build.xml
Initialize:
[delete] Deleting directory D:\eclipse211\eclipse\workspace\Ch05_02\bin
[mkdir] Created dir: D:\eclipse211\eclipse\workspace\Ch05_02\bin
[mkdir] Created dir: D:\eclipse211\eclipse\workspace\Ch05_02\bin\lib
133
134
Compile:
[javac] Compiling 1 source le to D:\eclipse211\eclipse\workspace\
Ch05_02\bin
[javac] D:\eclipse211\eclipse\workspace\Ch05_02\src\org\eclipsebook\
ch05\Ch05_02.java
[javac] Compiled 20 lines in 210 ms (95-2 lines/s)
[javac] 1 .class le generated
Jar:
[jar] Building jar: D:\eclipse211\eclipse\workspace\Ch05_02\bin\
lib\ch05_01.jar
Main Build:
[echo] Ant at work!
BUILD SUCCESSFUL
Total time: 1 second
Ch05_02.jar
Ant
JAR
Eclipse
bin/lib
135
Eclipse
Ant
Eclipse
Ant
Preferences
Ant
Ant
Window
5-7
Eclipse
Ant
build.xml
XML
.xml
Eclipse
Runtime
Ant
Eclipse
Ant
Ant
1.5-4
5-8
Eclipse 2.1.1
Ant 1.5-2
1.6
Apache
Ant
http://ant.apache.org
JAR
Runtime
ant.jar
5-8
optional.jar
ANT_HOME
Ant
Tasks
Types
Ant
Ant
Properties
Properties
<taskdef>
Eclipse
<typedef>
Ant
Add
136
Ant
Ant
Preferences
Editor
Ant
XML
overview ruler
Ant
5-9
<
Ant
XML
<p
<path>
<patternset>
Ant
<property>
Ant
Ctrl+Space
137
Eclipse
Sets a property by name, or a set of
<property>
properties (from file or resource) in the project.
Ant
Ant
Main
Ant
Run Ant
build.xml
5-10
base directory
Arguments
Ant
Ant
Tools
External Tools
New
Run
External
Program
Ant
Location
Browse File System
Windows
ant.bat
Working Directory
Ant bin
138
Eclipse
Other
Ant
Ant
Wi n d o w
S h o w Vi e w
Ant
Add Build file
5-11
Run
Ant
Eclipse Ant
Ant
Eclipse
Ant
JDT
Java
XML
139
<project>
default
deefault
Ant
closing
XML
tag
XML
Ant
XML
JDT
5-12
<mkdir>
XML
Ant
Ant
XML
default
<project>
deefault
Ant
5-13
Eclipse
Ant
Ant
Console
Eclipse
Java
Eclipse
Ant
Eclipse
Ant
File
Eclipse
New
Eclispe
Ant
wizard
Ant
140
Related documents