If you are a developer yourself, you might want to setup a development environment, so that you can debug and develop openHAB 2 yourself.
Note that the project build is completely mavenized - so running "mvn install" on the repository root will nicely build the product. For development and debugging, we recommend using an Eclipse IDE though. It should be possible to use other IDEs (e.g. NetBeans or IntelliJ), but you will have to work out how to resolve OSGi dependencies etc. yourself. So unless you have a strong reason to go for another IDE, we recommend using Eclipse.
Make sure that you have the following things installed on your computer:
- Git
- Maven 3.x
- Oracle JavaSE 7 or 8
- Yoxos Installer
Note: Here you can find a screencast of the IDE setup on YouTube.
Here are step-by-step instructions:
- Create your own fork of the openHAB2 repository at Github
- Create a local clone of your repository on the local filesystem by running
git clone https://github.com/<your_github_user>/openhab2.git
- Download and execute the file openHAB2.yoxos (in linux that can be done via command line ./yoxos openhab2.yoxos ). This will install you an Eclipse IDE with all required features to develop for openHAB 2. Alternatively, you can install all required plugins on top of an existing Eclipse 4.4 installation using this update site or download a full distribution from Yoxos, if you register an account there.
- Create a new workspace and choose
File->Import->General->Existing Projects into Workspace
, enter your repository root folder and press "Finish". Ignore any compilation errors at this point. - Switch the perspective to "Plug-in Development"
- Select the target platform by selecting
Window->Preferences->Plug-in Development->Target Platform->"openHAB 2"
(OS X:Eclipse->...
instead ofWindow->...
) from the main menu and press Ok. All project should now compile without errors. - To launch openHAB from within your IDE, go to Run->Run Configurations->Eclipse Application->openHAB_Runtime
To produce a binary zip of the runtime yourself, you can simply call mvn clean package
from the repository root and you will find the result in the folder distribution/target.
To run a single test you have to use following command: mvn -o org.eclipse.tycho:tycho-surefire-plugin:0.20.0: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 its local repository. Normally, snapshot-enabled projects are using external repositories to find latest built packages.
Note that the Paper UI is not yet contained in the official repository and is thus missing in your workspace at this point. You can manually add it by downloading the binary and then import it into your workspace by selecting File->Import->Plug-in Development->Plug-ins and Fragments' from the menu, choosing
Import from->Directory` your download folder and adding the Paper UI bundle on the next page.
Note: Here you can find a brief screencast that shows the steps.