虽然Eclipse RCP使用他的Product向导可以方便的导出软件,但对于统一的java build来说,使用ant或maven来完成这样的工作很为方便。现在把我使用的方法写在这里,以备忘。
1.开始前的准备(我使用的是Eclipse 3.3.2,也就是Eclipse europa)
当然是开发好的RCP工程,我这里使用com.rcpquickstart.helloworld;
下载eclipse-RCP-3.3.2-win32.zip和eclipse-RCP-3.3.2-delta-pack.zip,先解压eclipse-RCP-3.3.2-win32,再解压eclipse-RCP-3.3.2-delta-pack,并进行覆盖;如路径:D:/Apps-build/eclipse
ant环境,暂时使用的是apache-ant-1.7.1,路径:D:/DevTools/apache-ant-1.7.1
Java环境,使用的jdk1.6.0_19,路径:D:/DevTools/jdk1.6.0_12
2.在rcp工程(com.rcpquickstart.helloworld)上创建一个一个.product文件,这就不累述了,如helloworld.product
3.创建一个Project,导航栏右键-->New-->Project-->Plug-in Project-->Feature Project,工程名为com.rcpquickstart.helloworld.feature,在选择插件时将需要的插件都选上,当然com.rcpquickstart.helloworld是必须的。工程里里面两个文件,一个build.properties和feature.xml,feature.xml如下:
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="com.newautovideo.impclient.feature"
label="Impclient Feature"
version="1.0.0">
<description url="http://www.example.com/description">
[Enter Feature Description here.]
</description>
<copyright url="http://www.example.com/copyright">
[Enter Copyright Description here.]
</copyright>
<license url="http://www.example.com/license">
[Enter License Description here.]
</license>
<plugin
id="com.newautovideo.impclient"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.core.runtime"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.core.runtime.compatibility.auth"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.gef"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ui.intro"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ui.views"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="com.newautovideo.impclient.feature"
label="Impclient Feature"
version="1.0.0">
<description url="http://www.example.com/description">
[Enter Feature Description here.]
</description>
<copyright url="http://www.example.com/copyright">
[Enter Copyright Description here.]
</copyright>
<license url="http://www.example.com/license">
[Enter License Description here.]
</license>
<plugin
id="com.newautovideo.impclient"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.core.runtime"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.core.runtime.compatibility.auth"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.gef"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ui.intro"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ui.views"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>
build.properties里的内容就一行:bin.includes = feature.xml
4.创建一个一般工程,名为com.rcpquickstart.helloworld.build,里面创建两个文件,build.properties和build.xml,这两个文件是最关键的文件,最终编译就靠这两个文件,也就是ant脚本。首先说build.properties,这个文件的原本是在一个官方例子中,如下:
view plaincopy to clipboardprint?
###############################################################################
# Copyright (c) 2003, 2006 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
#####################
# Parameters describing how and where to execute the build.
# Typical users need only update the following properties:
# baseLocation - where things you are building against are installed
# bootclasspath - The base jars to compile against (typicaly rt.jar)
# configs - the list of {os, ws, arch} configurations to build.
#
# Of course any of the settings here can be overridden by spec'ing
# them on the command line (e.g., -DbaseLocation=d:/eclipse
############# PLUG-IN VERSIONS ######################
#
# Look in the plugins directory of your Eclipse
# installation to determine the version numbers
# the correct version numbers. These version numbers
# are used to create the correct paths when launching
# PDE Build.
#
#####################################################
# Version of org.ecilpse.pdebuild
pdeBuildPluginVersion=3.3.2.v20071019
# Version of org.eclipse.equinox.launcher
equinoxLauncherPluginVersion=1.0.1.R33x_v20080118
############# BASE LOCATION #########################
#
# Specify the directory of the base under which your
# your build target is located. This directory should
# contain the RCP Runtime Binary that you want to
# compile against.
#
#####################################################
###编译的根目录
base=D:/apps-build
############# ECLIPSE LOCATION ######################
#
# Specify the directory of the Eclipse installation
# that will be used to execute PDE Build.
#
#####################################################
###Eclipse的根目录
eclipseLocation=D:/DevTools/eclipse-jee-europa-winter-win32/eclipse
############# PRODUCT/PACKAGING CONTROL #############
###刚才创建的.product在工程中的位置
product=/com.rcpquickstart.helloworld/helloworld.product
runPackager=true
#Set the name of the archive that will result from the product build.
#archiveNamePrefix=
# The prefix that will be used in the generated archive.
###目标文件夹的名称
archivePrefix=helloworld
# The location underwhich all of the build output will be collected.
collectingFolder=${archivePrefix}
# The list of {os, ws, arch} configurations to build. This
# value is a '&' separated list of ',' separate triples. For example,
# configs=win32,win32,x86 & linux,motif,x86
# By default the value is *,*,*
#configs = *, *, *
###根据系统来选择
configs=win32, win32, x86
# & /
# win32,win32,x86_64 & /
# win32,win32,wpf & /
# linux, gtk, ppc & /
# linux, gtk, x86 & /
# linux, gtk, x86_64 & /
# linux, motif, x86 & /
# solaris, motif, sparc & /
# solaris, gtk, sparc & /
# aix, motif, ppc & /
# hpux, motif, ia64_32 & /
# macosx, carbon, ppc & /
# macosx, carbon, x86 & /
# macosx, cocoa, ppc & /
# macosx, cocoa, x86 & /
# macosx, cocoa, x86_64
# By default PDE creates one archive (result) per entry listed in the configs property.
# Setting this value to true will cause PDE to only create one output containing all
# artifacts for all the platforms listed in the configs property.
# To control the output format for the group, add a "group, group, group - <format>" entry to the
# archivesFormat.
#groupConfigurations=true
#The format of the archive. By default a zip is created using antZip.
#The list can only contain the configuration for which the desired format is different than zip.
#archivesFormat=win32, win32, x86 - antZip& /
# linux, gtk, ppc - antZip &/
# linux, gtk, x86 - antZip& /
# linux, gtk, x86_64 - antZip& /
# linux, motif, x86 - antZip& /
# solaris, motif, sparc - antZip& /
# solaris, gtk, sparc - antZip& /
# aix, motif, ppc - antZip& /
# hpux, motif, PA_RISC - antZip& /
# macosx, carbon, ppc - antZip
#Allow cycles involving at most one bundle that needs to be compiled with the rest being binary bundles.
allowBinaryCycles = true
#Sort bundles depenedencies across all features instead of just within a given feature.
flattenDependencies = true
#Parallel compilation, requires flattenedDependencies=true
#parallelCompilation=true
#parallelThreadCount=
#parallelThreadsPerProcessor=
#Set to true if you want the output to be ready for an update jar (no site.xml generated)
#outputUpdateJars = false
#Set to true for Jnlp generation
#codebase should be a URL that will be used as the root of all relative URLs in the output.
#generateJnlp=false
#jnlp.codebase=<codebase url>
#jnlp.j2se=<j2se version>
#jnlp.locale=<a locale>
#jnlp.generateOfflineAllowed=true or false generate <offlineAllowed/> attribute in the generated features
#jnlp.configs=${configs} #uncomment to filter the content of the generated jnlp files based on the configuration being built
#Set to true if you want to sign jars
#signJars=false
#sign.alias=<alias>
#sign.keystore=<keystore location>
#sign.storepass=<keystore password>
#sign.keypass=<key password>
#Arguments to send to the zip executable
zipargs=
#Arguments to send to the tar executable
tarargs=
#Control the creation of a file containing the version included in each configuration - on by default
#generateVersionsLists=false
############## BUILD NAMING CONTROL ################
# The directory into which the build elements are fetched and where
# the build takes place.
###打包的目标文件夹
buildDirectory=d:/apps-build/build
# Type of build. Used in naming the build output. Typically this value is
# one of I, N, M, S, ...
###形成的zip文件前缀
buildType=I
# ID of the build. Used in naming the build output.
###打包后的zip文件名,这里可以加上一些版本的信息
buildId=HelloWorld
# Label for the build. Used in naming the build output
buildLabel=${buildType}.${buildId}
# Timestamp for the build. Used in naming the build output
timestamp=007
#The value to be used for the qualifier of a plugin or feature when you want to override the value computed by pde.
#The value will only be applied to plugin or features indicating build.properties, qualifier = context
#forceContextQualifier=<the value for the qualifier>
#Enable / disable the generation of a suffix for the features that use .qualifier.
#The generated suffix is computed according to the content of the feature
#generateFeatureVersionSuffix=true
############# BASE CONTROL #############
# Settings for the base Eclipse components and Java class libraries
# against which you are building.
# Base location for anything the build needs to compile against. For example,
# in most RCP app or a plug-in, the baseLocation should be the location of a previously
# installed Eclipse against which the application or plug-in code will be compiled and the RCP delta pack.
###就是eclipse-RCP-3.3.2-delta-pack和eclipse-RCP-3.3.2-win32的解压位置
baseLocation=${base}/eclipse
#Folder containing repositories whose content is needed to compile against
#repoBaseLocation=${base}/repos
#Folder where the content of the repositories from ${repoBaseLocation} will be made available as a form suitable to be compiled against
#transformedRepoLocation=${base}/transformedRepos
#Os/Ws/Arch/nl of the eclipse specified by baseLocation
baseos=win32
basews=win32
basearch=x86
#this property indicates whether you want the set of plug-ins and features to be considered during the build to be limited to the ones reachable from the features / plugins being built
filteredDependencyCheck=false
#this property indicates whether the resolution should be done in development mode (i.e. ignore multiple bundles with singletons)
resolution.devMode=false
#pluginPath is a list of locations in which to find plugins and features. This list is separated by the platform file separator (; or :)
#a location is one of:
#- the location of the jar or folder that is the plugin or feature : /path/to/foo.jar or /path/to/foo
#- a directory that contains a /plugins or /features subdirectory
#- the location of a feature.xml, or for 2.1 style plugins, the plugin.xml or fragment.xml
#pluginPath=
skipBase=true
eclipseURL=<url for eclipse download site>
eclipseBuildId=<Id of Eclipse build to get>
eclipseBaseURL=${eclipseURL}/eclipse-platform-${eclipseBuildId}-win32.zip
############# MAP FILE CONTROL ################
# This section defines CVS tags to use when fetching the map files from the repository.
# If you want to fetch the map file from repository / location, change the getMapFiles target in the customTargets.xml
skipMaps=true
mapsRepo=:pserver:anonymous@example.com/path/to/repo
mapsRoot=path/to/maps
mapsCheckoutTag=HEAD
#tagMaps=true
mapsTagTag=v${buildId}
############ REPOSITORY CONTROL ###############
# This section defines properties parameterizing the repositories where plugins, fragments
# bundles and features are being obtained from.
# The tags to use when fetching elements to build.
# By default thebuilder will use whatever is in the maps.
# This value takes the form of a comma separated list of repository identifier (like used in the map files) and the
# overriding value
# For example fetchTag=CVS=HEAD, SVN=v20050101
# fetchTag=HEAD
skipFetch=true
############# JAVA COMPILER OPTIONS ##############
# The location of the Java jars to compile against. Typically the rt.jar for your JDK/JRE
#bootclasspath=${java.home}/lib/rt.jar
# specific JRE locations to compile against. These values are used to compile bundles specifying a
# Bundle-RequiredExecutionEnvironment. Uncomment and set values for environments that you support
#CDC-1.0/Foundation-1.0= /path/to/rt.jar
#CDC-1.1/Foundation-1.1=
#OSGi/Minimum-1.0=
#OSGi/Minimum-1.1=
#JRE-1.1=
#J2SE-1.2=
#J2SE-1.3=
#J2SE-1.4=
#J2SE-1.5=
#JavaSE-1.6=
#PersonalJava-1.1=
#PersonalJava-1.2=
#CDC-1.0/PersonalBasis-1.0=
#CDC-1.0/PersonalJava-1.0=
#CDC-1.1/PersonalBasis-1.1=
#CDC-1.1/PersonalJava-1.1=
# Specify the output format of the compiler log when eclipse jdt is used
logExtension=.log
# Whether or not to include debug info in the output jars
javacDebugInfo=false
# Whether or not to fail the build if there are compiler errors
javacFailOnError=true
# Enable or disable verbose mode of the compiler
javacVerbose=true
# Extra arguments for the compiler. These are specific to the java compiler being used.
#compilerArg=
# Default value for the version of the source code. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacSource in build.properties
####这里可以指定你的jdk版本
#javacSource=1.3
# Default value for the version of the byte code targeted. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacTarget in build.properties.
#javacTarget=1.1
###############################################################################
# Copyright (c) 2003, 2006 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
#####################
# Parameters describing how and where to execute the build.
# Typical users need only update the following properties:
# baseLocation - where things you are building against are installed
# bootclasspath - The base jars to compile against (typicaly rt.jar)
# configs - the list of {os, ws, arch} configurations to build.
#
# Of course any of the settings here can be overridden by spec'ing
# them on the command line (e.g., -DbaseLocation=d:/eclipse
############# PLUG-IN VERSIONS ######################
#
# Look in the plugins directory of your Eclipse
# installation to determine the version numbers
# the correct version numbers. These version numbers
# are used to create the correct paths when launching
# PDE Build.
#
#####################################################
# Version of org.ecilpse.pdebuild
pdeBuildPluginVersion=3.3.2.v20071019
# Version of org.eclipse.equinox.launcher
equinoxLauncherPluginVersion=1.0.1.R33x_v20080118
############# BASE LOCATION #########################
#
# Specify the directory of the base under which your
# your build target is located. This directory should
# contain the RCP Runtime Binary that you want to
# compile against.
#
#####################################################
###编译的根目录
base=D:/apps-build
############# ECLIPSE LOCATION ######################
#
# Specify the directory of the Eclipse installation
# that will be used to execute PDE Build.
#
#####################################################
###Eclipse的根目录
eclipseLocation=D:/DevTools/eclipse-jee-europa-winter-win32/eclipse
############# PRODUCT/PACKAGING CONTROL #############
###刚才创建的.product在工程中的位置
product=/com.rcpquickstart.helloworld/helloworld.product
runPackager=true
#Set the name of the archive that will result from the product build.
#archiveNamePrefix=
# The prefix that will be used in the generated archive.
###目标文件夹的名称
archivePrefix=helloworld
# The location underwhich all of the build output will be collected.
collectingFolder=${archivePrefix}
# The list of {os, ws, arch} configurations to build. This
# value is a '&' separated list of ',' separate triples. For example,
# configs=win32,win32,x86 & linux,motif,x86
# By default the value is *,*,*
#configs = *, *, *
###根据系统来选择
configs=win32, win32, x86
# & /
# win32,win32,x86_64 & /
# win32,win32,wpf & /
# linux, gtk, ppc & /
# linux, gtk, x86 & /
# linux, gtk, x86_64 & /
# linux, motif, x86 & /
# solaris, motif, sparc & /
# solaris, gtk, sparc & /
# aix, motif, ppc & /
# hpux, motif, ia64_32 & /
# macosx, carbon, ppc & /
# macosx, carbon, x86 & /
# macosx, cocoa, ppc & /
# macosx, cocoa, x86 & /
# macosx, cocoa, x86_64
# By default PDE creates one archive (result) per entry listed in the configs property.
# Setting this value to true will cause PDE to only create one output containing all
# artifacts for all the platforms listed in the configs property.
# To control the output format for the group, add a "group, group, group - <format>" entry to the
# archivesFormat.
#groupConfigurations=true
#The format of the archive. By default a zip is created using antZip.
#The list can only contain the configuration for which the desired format is different than zip.
#archivesFormat=win32, win32, x86 - antZip& /
# linux, gtk, ppc - antZip &/
# linux, gtk, x86 - antZip& /
# linux, gtk, x86_64 - antZip& /
# linux, motif, x86 - antZip& /
# solaris, motif, sparc - antZip& /
# solaris, gtk, sparc - antZip& /
# aix, motif, ppc - antZip& /
# hpux, motif, PA_RISC - antZip& /
# macosx, carbon, ppc - antZip
#Allow cycles involving at most one bundle that needs to be compiled with the rest being binary bundles.
allowBinaryCycles = true
#Sort bundles depenedencies across all features instead of just within a given feature.
flattenDependencies = true
#Parallel compilation, requires flattenedDependencies=true
#parallelCompilation=true
#parallelThreadCount=
#parallelThreadsPerProcessor=
#Set to true if you want the output to be ready for an update jar (no site.xml generated)
#outputUpdateJars = false
#Set to true for Jnlp generation
#codebase should be a URL that will be used as the root of all relative URLs in the output.
#generateJnlp=false
#jnlp.codebase=<codebase url>
#jnlp.j2se=<j2se version>
#jnlp.locale=<a locale>
#jnlp.generateOfflineAllowed=true or false generate <offlineAllowed/> attribute in the generated features
#jnlp.configs=${configs} #uncomment to filter the content of the generated jnlp files based on the configuration being built
#Set to true if you want to sign jars
#signJars=false
#sign.alias=<alias>
#sign.keystore=<keystore location>
#sign.storepass=<keystore password>
#sign.keypass=<key password>
#Arguments to send to the zip executable
zipargs=
#Arguments to send to the tar executable
tarargs=
#Control the creation of a file containing the version included in each configuration - on by default
#generateVersionsLists=false
############## BUILD NAMING CONTROL ################
# The directory into which the build elements are fetched and where
# the build takes place.
###打包的目标文件夹
buildDirectory=d:/apps-build/build
# Type of build. Used in naming the build output. Typically this value is
# one of I, N, M, S, ...
###形成的zip文件前缀
buildType=I
# ID of the build. Used in naming the build output.
###打包后的zip文件名,这里可以加上一些版本的信息
buildId=HelloWorld
# Label for the build. Used in naming the build output
buildLabel=${buildType}.${buildId}
# Timestamp for the build. Used in naming the build output
timestamp=007
#The value to be used for the qualifier of a plugin or feature when you want to override the value computed by pde.
#The value will only be applied to plugin or features indicating build.properties, qualifier = context
#forceContextQualifier=<the value for the qualifier>
#Enable / disable the generation of a suffix for the features that use .qualifier.
#The generated suffix is computed according to the content of the feature
#generateFeatureVersionSuffix=true
############# BASE CONTROL #############
# Settings for the base Eclipse components and Java class libraries
# against which you are building.
# Base location for anything the build needs to compile against. For example,
# in most RCP app or a plug-in, the baseLocation should be the location of a previously
# installed Eclipse against which the application or plug-in code will be compiled and the RCP delta pack.
###就是eclipse-RCP-3.3.2-delta-pack和eclipse-RCP-3.3.2-win32的解压位置
baseLocation=${base}/eclipse
#Folder containing repositories whose content is needed to compile against
#repoBaseLocation=${base}/repos
#Folder where the content of the repositories from ${repoBaseLocation} will be made available as a form suitable to be compiled against
#transformedRepoLocation=${base}/transformedRepos
#Os/Ws/Arch/nl of the eclipse specified by baseLocation
baseos=win32
basews=win32
basearch=x86
#this property indicates whether you want the set of plug-ins and features to be considered during the build to be limited to the ones reachable from the features / plugins being built
filteredDependencyCheck=false
#this property indicates whether the resolution should be done in development mode (i.e. ignore multiple bundles with singletons)
resolution.devMode=false
#pluginPath is a list of locations in which to find plugins and features. This list is separated by the platform file separator (; or :)
#a location is one of:
#- the location of the jar or folder that is the plugin or feature : /path/to/foo.jar or /path/to/foo
#- a directory that contains a /plugins or /features subdirectory
#- the location of a feature.xml, or for 2.1 style plugins, the plugin.xml or fragment.xml
#pluginPath=
skipBase=true
eclipseURL=<url for eclipse download site>
eclipseBuildId=<Id of Eclipse build to get>
eclipseBaseURL=${eclipseURL}/eclipse-platform-${eclipseBuildId}-win32.zip
############# MAP FILE CONTROL ################
# This section defines CVS tags to use when fetching the map files from the repository.
# If you want to fetch the map file from repository / location, change the getMapFiles target in the customTargets.xml
skipMaps=true
mapsRepo=:pserver:anonymous@example.com/path/to/repo
mapsRoot=path/to/maps
mapsCheckoutTag=HEAD
#tagMaps=true
mapsTagTag=v${buildId}
############ REPOSITORY CONTROL ###############
# This section defines properties parameterizing the repositories where plugins, fragments
# bundles and features are being obtained from.
# The tags to use when fetching elements to build.
# By default thebuilder will use whatever is in the maps.
# This value takes the form of a comma separated list of repository identifier (like used in the map files) and the
# overriding value
# For example fetchTag=CVS=HEAD, SVN=v20050101
# fetchTag=HEAD
skipFetch=true
############# JAVA COMPILER OPTIONS ##############
# The location of the Java jars to compile against. Typically the rt.jar for your JDK/JRE
#bootclasspath=${java.home}/lib/rt.jar
# specific JRE locations to compile against. These values are used to compile bundles specifying a
# Bundle-RequiredExecutionEnvironment. Uncomment and set values for environments that you support
#CDC-1.0/Foundation-1.0= /path/to/rt.jar
#CDC-1.1/Foundation-1.1=
#OSGi/Minimum-1.0=
#OSGi/Minimum-1.1=
#JRE-1.1=
#J2SE-1.2=
#J2SE-1.3=
#J2SE-1.4=
#J2SE-1.5=
#JavaSE-1.6=
#PersonalJava-1.1=
#PersonalJava-1.2=
#CDC-1.0/PersonalBasis-1.0=
#CDC-1.0/PersonalJava-1.0=
#CDC-1.1/PersonalBasis-1.1=
#CDC-1.1/PersonalJava-1.1=
# Specify the output format of the compiler log when eclipse jdt is used
logExtension=.log
# Whether or not to include debug info in the output jars
javacDebugInfo=false
# Whether or not to fail the build if there are compiler errors
javacFailOnError=true
# Enable or disable verbose mode of the compiler
javacVerbose=true
# Extra arguments for the compiler. These are specific to the java compiler being used.
#compilerArg=
# Default value for the version of the source code. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacSource in build.properties
####这里可以指定你的jdk版本
#javacSource=1.3
# Default value for the version of the byte code targeted. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacTarget in build.properties.
#javacTarget=1.1
接下来是build.xml
view plaincopy to clipboardprint?
<!--
This program and the accompanying materials are made available
under the terms of the Eclipse Public License v1.0 which
accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
This build script creates a build directory containing the plugins
and features to be built, and then kicks off the PDE build process.
You could just as easily do this from a shell script or cron job.
Also, the script can be run inside the Eclipse IDE by choosing
Run As -> Ant Build from the context menu. It could obviously be
run outside of the IDE if you have ANT installed on your path.
If you have any questions about this build, feel free to contact me
at patrick@rcpquickstart.com.
-->
<project name="com.rcpquickstart.helloworld.build" default="build">
<property file="build.properties" />
<!--
PDE Build expects that the build directory contains a "plugins"
directory and a "features" directory. These directories should contain
the various plug-ins and features to be built.
It's possible to use the CVS checkout process that is built into
PDE Build. This is done with map files and is beyond the scope of
this tutorial.
This tutorial simply copies the projects directly from your workspace
into the appropriate build directory folders.
-->
<target name="init">
<mkdir dir="${buildDirectory}" />
<mkdir dir="${buildDirectory}/plugins" />
<mkdir dir="${buildDirectory}/features" />
<copy todir="${buildDirectory}/plugins">
<fileset dir="../">
<include name="com.rcpquickstart.helloworld/**" />
</fileset>
</copy>
<copy todir="${buildDirectory}/features">
<fileset dir="../">
<include name="com.rcpquickstart.helloworld.feature/**" />
</fileset>
</copy>
</target>
<!--
This target actually executes the PDE Build process by launching the
Eclipse antRunner application.
NOTE: If you are using Eclipse 3.2, switch out the pathelement below
with the one that is commented out.
-->
<target name="pde-build">
<java classname="org.eclipse.equinox.launcher.Main" fork="true" failοnerrοr="true">
<!-- replace with following for Eclipse 3.2 -->
<!--<java classname="org.eclipse.core.launcher.Main" fork="true" failοnerrοr="true">-->
<arg value="-application" />
<arg value="org.eclipse.ant.core.antRunner" />
<arg value="-buildfile" />
<arg value="${eclipseLocation}/plugins/org.eclipse.pde.build_${pdeBuildPluginVersion}/scripts/productBuild/productBuild.xml" />
<arg value="-Dtimestamp=${timestamp}" />
<classpath>
<pathelement location="${eclipseLocation}/plugins/org.eclipse.equinox.launcher_${equinoxLauncherPluginVersion}.jar" />
<!-- replace with following for Eclipse 3.2 -->
<!-- <pathelement location="${eclipseLocation}/startup.jar" />-->
</classpath>
</java>
</target>
<target name="clean">
<delete dir="${buildDirectory}" />
</target>
<target name="build" depends="clean, init, pde-build" />
</project>
<!--
This program and the accompanying materials are made available
under the terms of the Eclipse Public License v1.0 which
accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
This build script creates a build directory containing the plugins
and features to be built, and then kicks off the PDE build process.
You could just as easily do this from a shell script or cron job.
Also, the script can be run inside the Eclipse IDE by choosing
Run As -> Ant Build from the context menu. It could obviously be
run outside of the IDE if you have ANT installed on your path.
If you have any questions about this build, feel free to contact me
at patrick@rcpquickstart.com.
-->
<project name="com.rcpquickstart.helloworld.build" default="build">
<property file="build.properties" />
<!--
PDE Build expects that the build directory contains a "plugins"
directory and a "features" directory. These directories should contain
the various plug-ins and features to be built.
It's possible to use the CVS checkout process that is built into
PDE Build. This is done with map files and is beyond the scope of
this tutorial.
This tutorial simply copies the projects directly from your workspace
into the appropriate build directory folders.
-->
<target name="init">
<mkdir dir="${buildDirectory}" />
<mkdir dir="${buildDirectory}/plugins" />
<mkdir dir="${buildDirectory}/features" />
<copy todir="${buildDirectory}/plugins">
<fileset dir="../">
<include name="com.rcpquickstart.helloworld/**" />
</fileset>
</copy>
<copy todir="${buildDirectory}/features">
<fileset dir="../">
<include name="com.rcpquickstart.helloworld.feature/**" />
</fileset>
</copy>
</target>
<!--
This target actually executes the PDE Build process by launching the
Eclipse antRunner application.
NOTE: If you are using Eclipse 3.2, switch out the pathelement below
with the one that is commented out.
-->
<target name="pde-build">
<java classname="org.eclipse.equinox.launcher.Main" fork="true" failοnerrοr="true">
<!-- replace with following for Eclipse 3.2 -->
<!--<java classname="org.eclipse.core.launcher.Main" fork="true" failοnerrοr="true">-->
<arg value="-application" />
<arg value="org.eclipse.ant.core.antRunner" />
<arg value="-buildfile" />
<arg value="${eclipseLocation}/plugins/org.eclipse.pde.build_${pdeBuildPluginVersion}/scripts/productBuild/productBuild.xml" />
<arg value="-Dtimestamp=${timestamp}" />
<classpath>
<pathelement location="${eclipseLocation}/plugins/org.eclipse.equinox.launcher_${equinoxLauncherPluginVersion}.jar" />
<!-- replace with following for Eclipse 3.2 -->
<!-- <pathelement location="${eclipseLocation}/startup.jar" />-->
</classpath>
</java>
</target>
<target name="clean">
<delete dir="${buildDirectory}" />
</target>
<target name="build" depends="clean, init, pde-build" />
</project>
完成了上面的步骤,基本上就快大功告成了,在com.rcpquickstart.helloworld.build工程的build.xml单击右键Run as-->Ant Build可以进行调试,如果没有错误就可以在目标目录下生成到处打包的文件了。
5.编写运行脚本,以windows的bat为例。
在windows中进入com.rcpquickstart.helloworld.build的目录,创建一个bat文件,内容如下:
set JAVA_HOME=D:/DevTools/jdk1.6.0_19
set ANT_HOME=D:/DevTools/apache-ant-1.7.1
%ANT_HOME%/bin/ant.bat -file build.xml
以后每次打包就可以只运行这个bat文件了。
这种打包的方式是采用eclipse的pde工具来完成的,当然如果ant写得好除了在上述build.properties中可以在cvs或是svn上获取代码后打包外,还可以调用如inno setup的软件完成安装程序的制作,大大地减少了打包的工作量,而且还可靠稳定。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/meteors1113/archive/2010/04/23/5522538.aspx