- 浏览: 339534 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
fengjingxianjing:
凤舞凰扬的话 -
qiubite520:
求登陆这块的完整代码,378657535@qq.com,谢谢
用RCP实现MSN风格的登录窗口 -
renyanwei:
可是现在怎么看还是1.4呢
InfoQ中文站正式升级为1.5版 -
malk:
ray_linn 写道作者可以和罗时飞一拼了,无论从语无伦次, ...
书评:《敏捷软件开发》中文版第二版 -
sleekengine:
一路看下来的感想:1)看来还是有能够翻译的不错的好手2)翻译也 ...
书评:《敏捷软件开发》中文版第二版
通常我们打包Product的时候,一般都是通过Product的export操作来进行的,但这样的做法,则限制了Continous Integration的自动化执行,那么,应该如何编写自动化构建脚本呢?
一、首先,让我们看一下Eclipse官方的解决方案:
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.pde.doc.user/guide/tasks/pde_product_build.htm
从 文中我们可以看出,PDE已经为从product文件构建RCP应用做好了一切准备,我们所需要做的,就是搭建目录结构以及构建脚本。但是如果完全按照官 方方案去做的话,只会使得构建更加复杂,更加不可自动化,那么,让我们跟随一个简单的例子来看一下如何完成自动构建吧(在下使用的是 Eclipse3.2,pde的版本号为3.2.0.v20060603,使用其他版本的朋友请自行修改):
1。 使用Hello RCP模版构建一个RCP工程。命名为hellorcp,创建到G:\eclipse\workspace\hellorcp
在这一步,有一个很关键的问题需要注意,我们先来看一下上文中build directory的结构:
要想成功build工程的话,那么工程就必须要放到<builddirectory>/plugins/的目录结构下,不然pde是找不到工程的plugin id的!我努力了很长时间才无奈的认可了这个事实。
如果我们不想把工程放到一个很复杂的目录结构下,或者对于既有的工程不想做这样的改动,那么就只好用到ant来拷贝了。我的做法是,在工程目录下,创建名为dist\plugins\hellorcp的目录,待一切就绪后,使用ant来把整个工程拷贝到这个目录下。
2。准备脚本
在 工程下,新建buildConfiguration目录,并把<eclipse_install_dir>\plugins\ org.eclipse.pde.build_3.2.0.v20060603\templates\headless-build下的 build.properties文件拷贝到此目录下,并修改如下设置项:
1).product—— 官方的说法是:the location of your product configuration file in the form "/ <plugin or="" feature="" id="">/path/to/.product",而我们的buildConfiguration目录和 product文件同处于一个目录下,所以只需要写上product文件的名字即可,如hellorcp.product。
2).baseLocation——官方的说法是:the location of an eclipse install containing all the pre-built features and plug-ins that your product requires in features/ and plugins/ subdirectories. The RCP delta pack (it is available from the eclipse download page) is mandatory as it includes the org.eclipse.platform.launchers feature which contains the launchers and root files necessary for a product. 我们要做的就是把RCP delta pack安装到Eclipse目录下,然后把base location指向Eclipse根目录即可,这里需要绝对路径。
3).buildDirectory——官方的说法是:the directory the build will take place in. Set this to the full path of the build directory created previously. 这里因为最后的目录指向是ant拷贝完成以后的路径,所以应当是G:\eclipse\workspace\hellorcp\dist
4).configs—— list the configurations for which you want your product to be built. You can uncomment the configuration(s) provided (be careful of the line continuations).
5).archivePrefix—— the name of the directory of your product once installed on disk. 如hellorcp
以上为官方给出的配置项,而我们如果使用了1.5或1.6中的新功能的话,还需要到文件的最底部,找到javacSource和javacTarget两个选项,进行对应的修改。
3。ant脚本
在工程目录下新建一个ant脚本,把下面的代码粘贴进去,运行,就可以到dist/I.TestBuild下面找构建后的产品了。</plugin> </eclipse_install_dir></builddirectory>
构建后的产品是以zip形式存在的,我们还可以根据实际的需要,对build.properties进行更多的修改。
上面的脚本还有一些缺陷,比如绝对位置的使用,但这是无法避免的了.......
二、接下来是使用Maven的构建:
使用Maven的准备工作包括下载,配置环境变量,安装Maven plugin for Eclipse,并在Preferences中,Java/Build Path/Classpath Variables/下面配置M2_REPO变量,使其指向userhome\.m2\repository
关于Maven的入门知识在此略过,请自行阅读Maven官方站点的相关资料。
在创建工程时,请将src目录指向src/main/java,output目录指向target/classes
工 程创建完毕后,右击工程名,在弹出菜单中选中“Maven2“,然后选择”Enable“,则会生成对应的pom文件,我们可以自己设置对应的 groupid,artifactId,以及相应的dependencies,在这里,我们只需要为Eclipse插件依赖以外的第三方包设置 dependency就可以了。如果该包在官网上无法访问到,则可以通过运行
mvn install:install-file -Dfile=path-to-your-artifact-jar \
-DgroupId=your.groupId \
-DartifactId=your-artifactId \
-Dversion=version \
-Dpackaging=jar \
-DgeneratePom=true
来把第三方包安装到local repository里面去。
然 而,在plugin project运行时,除了Eclipse插件依赖以外的第三方包是需要位于plugin目录下的,否则在运行时无法找到对应路径,我们也可以看到,在 plugin.xml视图的runtime页面中,根本无法把plugin目录以外的jar文件加入到classpath中来。所以,我们还需要另外的 ant脚本来完成拷贝工作。脚本如下所示:(此处参考了江南白衣,有一点不同的是,此处把ant的classpath指向了local repository,这样发布的时候,就无需发布maven-artifact-ant.jar了)
接下来的目录结构及脚本的准备工作和前面一样,除了两处需要修改:
1)buildConfiguration\build.properties, 这里的buildDirectory可以注释掉。
2)第3步中的ant脚本,因为我们这里需要用maven来构建,所以只需要执行prepare任务就可以了。
再有就是pom.xml文件中,要加入构建的任务:
最后运行第3步中的ant脚本,然后到dist\plugins\hellorcp目录下,运行mvn install就可以了。构建后的文件可以在local repository中找到。
常见错误:
使用ant build的时候,出现plugin:xxx找不到的错误,请检查buidConfiguration\build.properties中buildDirectory的配置项
使用Maven build的时候,出现编译错误,请检查pom.xml中是否少了
<packaging></packaging> 这一项
一、首先,让我们看一下Eclipse官方的解决方案:
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.pde.doc.user/guide/tasks/pde_product_build.htm
从 文中我们可以看出,PDE已经为从product文件构建RCP应用做好了一切准备,我们所需要做的,就是搭建目录结构以及构建脚本。但是如果完全按照官 方方案去做的话,只会使得构建更加复杂,更加不可自动化,那么,让我们跟随一个简单的例子来看一下如何完成自动构建吧(在下使用的是 Eclipse3.2,pde的版本号为3.2.0.v20060603,使用其他版本的朋友请自行修改):
1。 使用Hello RCP模版构建一个RCP工程。命名为hellorcp,创建到G:\eclipse\workspace\hellorcp
在这一步,有一个很关键的问题需要注意,我们先来看一下上文中build directory的结构:
- buildDirectory/
- plugins/
- pluginToBuildA
- pluginToBuildB
- myProduct.product
- ...
- features/
- featureToBuild
要想成功build工程的话,那么工程就必须要放到<builddirectory>/plugins/的目录结构下,不然pde是找不到工程的plugin id的!我努力了很长时间才无奈的认可了这个事实。
如果我们不想把工程放到一个很复杂的目录结构下,或者对于既有的工程不想做这样的改动,那么就只好用到ant来拷贝了。我的做法是,在工程目录下,创建名为dist\plugins\hellorcp的目录,待一切就绪后,使用ant来把整个工程拷贝到这个目录下。
2。准备脚本
在 工程下,新建buildConfiguration目录,并把<eclipse_install_dir>\plugins\ org.eclipse.pde.build_3.2.0.v20060603\templates\headless-build下的 build.properties文件拷贝到此目录下,并修改如下设置项:
1).product—— 官方的说法是:the location of your product configuration file in the form "/ <plugin or="" feature="" id="">/path/to/.product",而我们的buildConfiguration目录和 product文件同处于一个目录下,所以只需要写上product文件的名字即可,如hellorcp.product。
2).baseLocation——官方的说法是:the location of an eclipse install containing all the pre-built features and plug-ins that your product requires in features/ and plugins/ subdirectories. The RCP delta pack (it is available from the eclipse download page) is mandatory as it includes the org.eclipse.platform.launchers feature which contains the launchers and root files necessary for a product. 我们要做的就是把RCP delta pack安装到Eclipse目录下,然后把base location指向Eclipse根目录即可,这里需要绝对路径。
3).buildDirectory——官方的说法是:the directory the build will take place in. Set this to the full path of the build directory created previously. 这里因为最后的目录指向是ant拷贝完成以后的路径,所以应当是G:\eclipse\workspace\hellorcp\dist
4).configs—— list the configurations for which you want your product to be built. You can uncomment the configuration(s) provided (be careful of the line continuations).
5).archivePrefix—— the name of the directory of your product once installed on disk. 如hellorcp
以上为官方给出的配置项,而我们如果使用了1.5或1.6中的新功能的话,还需要到文件的最底部,找到javacSource和javacTarget两个选项,进行对应的修改。
3。ant脚本
在工程目录下新建一个ant脚本,把下面的代码粘贴进去,运行,就可以到dist/I.TestBuild下面找构建后的产品了。</plugin> </eclipse_install_dir></builddirectory>
- xml version="1.0"?>
- <project name="project" default="rcpAutomatedBuild">
- <property name="eclipse.install" value="G:\eclipse">
- <!---->property>
- <property name="project.dir" value="G:\eclipse\workspace\hellorcp">
- <!---->property>
- <property name="dist.dir" value="${project.dir}\dist\plugins\hellorcp" />
- <target name="prepare">
- <mkdir dir="${dist.dir}" />
- <copy todir="${dist.dir}">
- <fileset dir="${project.dir}">
- <!---->fileset>
- <!---->copy>
- <!---->target>
- <target name="rcpAutomatedBuild" depends="prepare">
- <java classname="org.eclipse.core.launcher.Main" fork="true" failonerror="true">
- <arg value="-application" />
- <arg value="org.eclipse.ant.core.antRunner" />
- <arg value="-buildfile" />
- <arg value="${eclipse.install}\plugins\org.eclipse.pde.build_3.2.0.v20060603\scripts\productBuild\productBuild.xml" />
- <arg value="-Dbuilder=${dist.dir}\buildConfiguration" />
- <classpath>
- <pathelement location="${eclipse.install}\startup.jar" />
- <!---->classpath>
- <!---->java>
- <!---->target>
- <!---->project>
构建后的产品是以zip形式存在的,我们还可以根据实际的需要,对build.properties进行更多的修改。
上面的脚本还有一些缺陷,比如绝对位置的使用,但这是无法避免的了.......
二、接下来是使用Maven的构建:
使用Maven的准备工作包括下载,配置环境变量,安装Maven plugin for Eclipse,并在Preferences中,Java/Build Path/Classpath Variables/下面配置M2_REPO变量,使其指向userhome\.m2\repository
关于Maven的入门知识在此略过,请自行阅读Maven官方站点的相关资料。
在创建工程时,请将src目录指向src/main/java,output目录指向target/classes
工 程创建完毕后,右击工程名,在弹出菜单中选中“Maven2“,然后选择”Enable“,则会生成对应的pom文件,我们可以自己设置对应的 groupid,artifactId,以及相应的dependencies,在这里,我们只需要为Eclipse插件依赖以外的第三方包设置 dependency就可以了。如果该包在官网上无法访问到,则可以通过运行
mvn install:install-file -Dfile=path-to-your-artifact-jar \
-DgroupId=your.groupId \
-DartifactId=your-artifactId \
-Dversion=version \
-Dpackaging=jar \
-DgeneratePom=true
来把第三方包安装到local repository里面去。
然 而,在plugin project运行时,除了Eclipse插件依赖以外的第三方包是需要位于plugin目录下的,否则在运行时无法找到对应路径,我们也可以看到,在 plugin.xml视图的runtime页面中,根本无法把plugin目录以外的jar文件加入到classpath中来。所以,我们还需要另外的 ant脚本来完成拷贝工作。脚本如下所示:(此处参考了江南白衣,有一点不同的是,此处把ant的classpath指向了local repository,这样发布的时候,就无需发布maven-artifact-ant.jar了)
- xml version="1.0" encoding="UTF-8"?>
- <project name="build-base" default="copy" xmlns:artifact="urn:maven-artifact-ant">
- <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">
- <classpath>
- <pathelement location="${user.home}/.m2/repository/org/apache/maven/maven-artifact-ant/2.0.4/maven-artifact-ant-2.0.4.jar" />
- <!---->classpath>
- <!---->typedef>
- <artifact:pom id="maven.project" file="pom.xml" />
- <artifact:dependencies filesetId="dependency.fileset" useScope="runtime">
- <pom refid="maven.project"/>
- <!---->artifact:dependencies>
- <target name="copy">
- <copy todir="lib">
- <fileset refid="dependency.fileset" />
- <mapper type="flatten" />
- <!---->copy>
- <!---->target>
- <!---->project>
接下来的目录结构及脚本的准备工作和前面一样,除了两处需要修改:
1)buildConfiguration\build.properties, 这里的buildDirectory可以注释掉。
2)第3步中的ant脚本,因为我们这里需要用maven来构建,所以只需要执行prepare任务就可以了。
再有就是pom.xml文件中,要加入构建的任务:
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo<!---->groupId>
- <artifactId>pde-maven-plugin<!---->artifactId>
- <extensions>true<!---->extensions>
- <configuration>
- <eclipseInstall>G:\eclipse<!---->eclipseInstall>
- <pdeProductFilename>hellorcp.product<!---->pdeProductFilename>
- <pdeBuildVersion>3.2.0.v20060603<!---->pdeBuildVersion>
- <!---->configuration>
- <!---->plugin>
- <!---->plugins>
- <!---->build>
最后运行第3步中的ant脚本,然后到dist\plugins\hellorcp目录下,运行mvn install就可以了。构建后的文件可以在local repository中找到。
常见错误:
使用ant build的时候,出现plugin:xxx找不到的错误,请检查buidConfiguration\build.properties中buildDirectory的配置项
使用Maven build的时候,出现编译错误,请检查pom.xml中是否少了
- <packaging>zip</packaging>
<packaging></packaging> 这一项
评论
4 楼
hnlzwaq
2007-07-04
[java] BUILD FAILED
[java] D:\Program Files\eclipse_rcp\plugins\org.eclipse.pde.build_3.3.0.v20
070612\scripts\productBuild\productBuild.xml:24: The following error occurred wh
ile executing this line:
[java] D:\Program Files\eclipse_rcp\plugins\org.eclipse.pde.build_3.3.0.v20
070612\scripts\productBuild\productBuild.xml:51: Unable to find plug-in: org.ecl
ipse.equinox.launcher.*.*.*. Please check the error log for more details.
按照作者所述,出现上面的错误
这个的配置也没错啊 ,但是老是出错,请求指点一下!
[java] D:\Program Files\eclipse_rcp\plugins\org.eclipse.pde.build_3.3.0.v20
070612\scripts\productBuild\productBuild.xml:24: The following error occurred wh
ile executing this line:
[java] D:\Program Files\eclipse_rcp\plugins\org.eclipse.pde.build_3.3.0.v20
070612\scripts\productBuild\productBuild.xml:51: Unable to find plug-in: org.ecl
ipse.equinox.launcher.*.*.*. Please check the error log for more details.
按照作者所述,出现上面的错误
引用
使用ant build的时候,出现plugin:xxx找不到的错误,请检查buidConfiguration\build.properties中buildDirectory的配置项
这个的配置也没错啊 ,但是老是出错,请求指点一下!
3 楼
dearwolf
2007-03-06
确实非常的烦人,我也是用了好几天才搞清楚的,最开始的时候,还经历了把一个普通的maven project一步步改造成plugin project的过程,修改.classpath和.project文件等等,不是一般的头大...
2 楼
partech
2007-03-06
共同学习,曾经考察过,觉得很烦人,回头再试一下.
1 楼
lyx_2709
2007-03-06
学习了
发表评论
-
使用Sleak分析RCP应用潜在内存泄露
2008-02-14 16:14 18241. following the website(http:/ ... -
一个RCP的IM应用,请教关于网络故障及恢复的处理方法
2007-04-02 16:15 2775目前是一个IM系统,需要在网络连接断开的时候,关掉主程序,回到 ... -
关于Dispose SWT资源的思考与疑问
2007-03-19 14:10 2256我们知道,在SWT中,有两条关于Dispose的法则: 1。 ... -
在Eclipse RCP中实现I18N的思考与疑问
2007-02-14 17:11 3726在RCP产品中实现国际化,一般是两种方式。 方式一: ... -
Eclipse RCP开发书籍资料简介
2007-01-22 11:31 7910为了给大家提供方便,我在这篇帖子里对常用的RCP参考资料作了一 ... -
RCP中异步线程的处理
2007-01-17 17:13 6015在RCP中要在非UI线程中执行UI线程的操作,最简单的方式就是 ... -
UI的底层机制
2006-09-18 14:54 1751EventHandler要抽象出一个接口来,然后根据不同的需要 ... -
有关CellEditor
2006-09-18 15:08 3456为了批量发布设备,需要在一个窗口中为设备命名,设定其类型等,要 ... -
SWT基础概念之一
2006-09-18 15:09 1487Design decisions: Most platfo ... -
Dialog相关
2006-09-18 15:09 1704ModalessDialog: public class M ... -
使用JFace Viewer注意事项
2006-09-21 14:44 1789如果使用了Eclipse3.2提供的自绘制功能来在table或 ... -
用RCP实现MSN风格的登录窗口
2006-09-25 19:02 6455需要以下的对象: LoginDialog,用于展示状态, Lo ... -
设置Perspective
2006-10-08 10:04 2417在IWorkbenchPreferenceConstants中 ... -
用RCP做出漂亮的对话框
2006-10-16 18:11 5281首先是一个效果图: 为了不违反保密协议,偶在这里把log ... -
指定JFace.Dialog初始化的位置
2006-11-08 15:23 3479目的1:打开一个新的对 ... -
使SWT的Table根据TableItem显示Tooltip
2006-12-11 19:13 3670默认情况下,SWT的Table只 ... -
动态改变RCP应用程序的标题
2006-12-13 18:47 2580我们知道,Title是在ApplicationWorkbenc ... -
ViewerFilter与自定义选中Column的颜色
2006-12-26 16:10 2812ViewerFilter主要用于根据 ...
相关推荐
高级篇(第6-12章)系统讲解了Eclipse RCP应用开发的基础知识、Eclipse RCP软件产品各个组成部分的构建方法,以及Eclipse RCP扩展的使用和扩展点的开发,掌握这些技术知识的读者将能构建一个结构完整的Eclipse RCP...
Maven 2 Eclipse Plugin
java视频教程之SVN Maven搭建自动化构建教程 Eclipse中使用Maven视频教程云盘下载链接
介绍maven 安装,maven Eclipse环境集成。maven是apache出的能够方便工程构建的可代替ant的软件。
maven-eclipse-plugin-2.5.1为eclipse中的maven插件,别下错了哦...
maven2之m2eclipse使用手册.doc Maven2使用.ppt maven2完全使用手册.docx Maven_介绍培训.pptx Maven学习指南.pdf Maven实战.doc Maven实战.pdf Maven构建并管理Flex项目入门.pdf Maven简单实用教程.docx OTNVD_...
本文介绍了使用maven构建eclipse项目,挺不错的大家参考参考!
使用Maven构建多模块项目
最新的maven集成eclipse书籍,使用maven和eclipse开发必看。
Maven在eclipse中的项目启动命令
maven eclipse 免费
使用Eclipse使用Maven构建web项目视频教程,不包含框架内容
m2e 适合 eclipse3.X jdk1.6 (maven2eclipse)
maven及eclipse插件下载和使用.zip maven及eclipse插件下载和使用.zip maven及eclipse插件下载和使用.zip
maven-eclipse-plugin-2.3.jar
maven-eclipse-plugin-2.8.jar
maven-eclipse-plugin-2.2.jar
maven_eclipse_GEF-zest-3.7.1_m2e-extras_m2e.zip maven的eclipse插件