`
sunway
  • 浏览: 113102 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

使用Ant 构建Eclipse RCP Product

阅读更多

Keywords:rcp打包,headless build ,ant build rcp product

摘要:

Rcp 让我们可以脱离eclipse环境,作为一个可执行程序独立使用。我们可以使用rcpEclipse Product export wizard来生成rcp,也可以使用ant 脚本来生成rcp应用,使用后者可以给我们带来更大的灵活性和满足我们的更多需求,符合可持续集成的原则,而且生成速度更快,不用打开eclipse,配置人员双击下鼠标就可完成。

在此期间,受到了同事的不少帮助,在此表示感谢。

一、             准备工作

1、安装ant

首先安装apache-ant-1.7.1-bin.zip,在系统环境变量的path=path to ant/bin,这样在cmd下也可以使用ant命令了。

2.下载eclipse3.4.0eclipse-3.4RC4-delta-pack.zip,将eclipse-3.4RC4-delta-pack.zip解开放到 eclipse3.4.0目录下,选择覆盖。如果你的ant脚本打包后的rcp里没有可执行的exe程序,就是因为没有这一步操作。

 

 

二、             修改插件build.xml文件和plugin.xml文件

选择组成我们rcp的插件的plugin.xml文件,或直接双击build.properties,先取消选择上方的“custom build”项,因为我们要通过PDE Tools生成build.xml文件。选中plugin.xml文件,右键选择PDE Tools->Create Ant Build File,PDE自动在当前目录下生成build.xml文件。

1.      修改build.xml文件。

l  修改<pathelement path="../../plugins/…….中的相对路径为<pathelement path="${eclipse.home}/plugins/…….。如果在ant build的过程中出现某个类不能解析的错误,就是因为这里没有改掉相对路径。

l  <javac节点增加encoding="UTF-8",即<javac encoding="UTF-8" destdir=…,这样我们打出的rcp可以正确的显示中文了。如果我们rcp产品里有乱码产生,就是因为没有这样做。

l   

2.      修改plugin.xml文件。

回到plugin.xml文件的Build页,选中上方的“custom build”项,让我们刚修改过的build.xml参与ant build过程。如果我们不需要custom build,就取消选择“custom build”项。如果ant build失败,报找不到某个插件的错误,请先到这个插件的目录下检查plugin.xml文件,看是否选中了“custom build”项,将其取消选择即可解决此问题。

三、             feature工程

在工作空间下建个feature工程,选择File->New->Other->Plug-in Development->Feature Projectnext,输入Project name,next,选中Initialize from the plug-ins list项,勾选rcp需要的所有插件,包括rcp本身。点finish。在feature工程里新建了两个文件:build.propertiesfeature.xml。打开feature.xml文件,选中plug-ins页,在左上角的plug-ins and Fragments里,应该可以看到刚才添加的rcp和它需要的所有插件。如果ant build的过程报找不到某个插件的错误,检查这里。选中Included Features页,在左上角的Included Features里,选右边的Add按钮,增加org.eclipse.rcp插件。

四、             ant脚本工程

这一步是ant build rcp最重要的一步。在当前工作空间下建个script工程,当然也可以是个普通文件目录(如果只在命令行下使用ant命令的话)

我们需要拷贝国际化的语言包插件到我们的rcp中,并且将rcp plugins目录下我们的插件由jar包形式解压缩为目录形式,因为有的插件程序访问不到jar包里的文件。另外还要拷贝一个完整的jre环境到rcp中。

1.在当前工程下建ref目录,目录结构如下:

Ref

   +features

   +jre

   +plugins

Pluginsfeatures是语言包里的两个目录,放了国际化需要的jar包。

Jrejava运行环境,这里用的是jdk1.5

2. 在当前工程下建scripts目录,下面放两个文件:build.propertiesbuild.xml

l  build.properties可以采用如下的模板:

###############################################################################

# Parameters describing how and where to execute the build.

#####################################################

 

#The type of the top level element we are building,  generally "feature"

#topLevelElementType = feature

#The id of the top level element we are building

#topLevelElementId = de.vogella.build.feature

 

############# PRODUCT/PACKAGING CONTROL #############

product=your rcp /your rcp product file name

runPackager=false

 

 

# The prefix that will be used in the generated archive.

archivePrefix=pluginsfeatures的父目录名字

 

############# BASE CONTROL #############

# baselocation must the an working Eclipse installation with the delta pack

 

base=d: #存放上面准备工作中eclipse3.4.0的盘符

baseLocation=${base}/eclipse  #上面准备工作中eclipse3.4.0的硬盘路径

 

############## BUILD NAMING CONTROL ################

# The directory into which the build elements are fetched and where

# the build takes place.

#buildDirectory=D:/workspace-workflow/com.css.sword.workflow.rcp.builder

buildDirectory=D:/builder  #最后生成的rcp存放在此路径

 

#define version various

pdeBuildPluginVersion=3.4.0.v20080604

equinoxLauncherPluginVersion=1.0.100.v20080509-1800

# ID of the build.  Used in naming the build output.

buildId=rcp

left

1
2
分享到:
评论
1 楼 sitoto 2011-11-16  
给个对应的确build.xml 的例子啊,,

相关推荐

Global site tag (gtag.js) - Google Analytics