(翻译水平有限,所以采用中英对照,)
IDE Setup
How to set up a development environment for openHAB
如何安装openHAB的开发环境
Introduction介绍
如果你是一个开发者且不是一个单纯的用户(而是还想搞点开发),你可能想安装EclipseIDE,这样你就可以自己调试和开发openHAB包了。
Setup Instructions安装方法
Here are step-by-step instructions on how to get there:
这里是如何成功的一步步的安装步骤:
1. Create a local clone of the openHAB repository by running "git clonehttps://github.com/openhab/openhab" in a suitable folder.
通过运行"git clone https://github.com/openhab/openhab" 来创建一个openHAB的本地克隆库到一个恰当的目录中。
2. Download and install oracle jdk 1.7
下载并安装Oracle的jdk1.7
3. Download and install the Yoxos Installer.
下载并安装 Yoxos安装器.
4. Download and execute the file openHAB.yoxos (in linux that can be done via command line ./yoxos openHAB.yoxos ). This will install you an Eclipse IDE with all required features to develop for openHAB. Alternatively, you can install all required plugins on top of an existing Eclipse 4.2.2 installation using this update site or download a full distribution from Yoxos, if you register an account there.
下载并运行 openHAB.yoxos (在linux中可以通过命令行 ./yoxos openHAB.yoxos来搞定 )。这样你就安装了一个包含开发openHAB所需的所有功能的Eclipse IDE。或者,你也可以从 update site 或者 Yoxos中下载完整的发行版(如果你在那注册了账号),在现有的Eclipse 4.2.2的基础上安装所有所需插件。
5. Create a new workspace.
创建一个新的工作目录(workspace)
6. Choose File->Import->General->Existing Projects into Workspace, enter your clone repository directory as the root directory and press "Finish".
选择File->Import->General->Existing Projects into Workspace,选择你克隆的目录作为根目录并选择"Finish"。
7. After the import is done, you have to select the target platform by selecting Window->Preferences->Plug-in Development->Target Platform->openHAB from the main menu. Ignore compilation problems at this step.
导入之后,你需要在主菜单选项中选择Window->Preferences->Plug-in Development->Target Platform->openHAB来确定目标平台。
8. Now you need to run code generation for a few parts of openHAB. To do so, go to the project org.openhab.model.codegen and run the prepared launch files. For each .launch file, select "Run As->x Generate abc Model" from the context menu. Please follow the order given by the numbers. On the very first code generation, you are asked in the console to download an ANTLR file, answer with "y" and press enter on the console.
现在你需要运行代码来生成openHAB的几个部分。为此,请转至项目org.openhab.model.codegen中并运行准备的启动文件。对每个启动文件,请从菜单中选择"Run As->x Generate abc Model"。请按照数字编号给定的顺序执行。在首次生成代码时,在控制台中会要求你下载一个ANTLR文件,只需要在里面输入"y"并按下回车。
9. All your project in the workspace should now correctly compile without errors. If you still see error markers, try a "clean" on the concerned projects. If there are still errors, it could be that you use JDK 1.6 instead of JDK 1.7.
在工作区文件夹下的项目现在应该正确无误的编译好了。如果任然看到有错误标记,可以试下“clean”相应的项目。如果还是有错误,可能是因为你用的JDK1.6而不是JDK1.7。
10. To launch openHAB from within your IDE, go to Run->Run Configurations->Eclipse Application->openHAB Runtime (resp. openHAB Designer).
想在IDE中运行openHAB,依次选择 Run->Run Configurations->Eclipse Application->openHAB Runtime (openHAB Designer).
To produce a binary zip yourself from your code, you can simply call mvn clean install
from the repository root and you will find the results in the folder distribution/target (you will of course need a Maven 3.0 installation as a prerequisite). Set MAVEN_OPTS
to -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m
in order to avoid memory problems during the build process.
想自己生将自己的代码生成二进制zip文件,你只需要简单的在资源库的根目录中调用mvn clean install
,然后你就会发现在distribution/target目录中发现结果(当然你需要先装好Maven3.0)。设置MAVEN_OPTS
为-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m
以避免在生成过程中发生内存问题。
To run a single test you have to use following command: mvn -o org.eclipse.tycho:tycho-surefire-plugin:0.18.1:test
which activates the tycho-surefire-specific goal for OSGI unit test using the fragment bundle xxxx.test on xxxx bundle. The maven -o (offline) option accelerates the project dependency resolution by 10-20x since it lets maven search it's local repository. Normally, snapshot-enabled projects are using external repositories to find latest built packages.
要运行单个测试你必须使用如下的命令:它为OSGI单元通过绑定xxxx.test到xxxx包上激活了tycho-surefire-specific目标。maven -o (offline) 选项使得项目依赖解析加速10-20倍,因为该选项可以让maven在本地搜索资源库。 通常,支持快照功能的项目通过使用扩展的资源库来找到最新的软件包。