4.0 KiB
layout | title |
---|---|
developersguide | Eclipse IDE |
TODO: We are currently reworking how to setup a perfect development enviroment. A new step by step guide will appear here soon.
For now follow these steps:
Eclipse IDE Setup
-
Install the latest "Eclipse IDE for Java Developers", the installer can be downloaded from the Eclipse web site
-
Launch Eclipse and install Bndtools from the Eclipse Marketplace: Help -> Eclipse Marketplace -> Find "bndtools" -> Install:
(Accept License and the Security warning about the software is not signed)
Restart Eclipse to activate Bndtools.
-
Using
git
from the command line, checkout the openHAB demo application:git clone --depth=1 https://github.com/maggu2810/openhab-demo
-
Import the demo application from Eclipse: File -> Import -> Maven -> Existing Maven Projects -> select the root directory of the demo application project -> Finish.
Leave Eclipse open and wait for the downloads and build to finish (about 5-10 minutes).
-
Using git from the command line, checkout the
openhab2-addons
repository:git clone --depth=1 https://github.com/openhab/openhab2-addons
-
Add the binding that you want to develop (in this guide we use
astro
as an example) to the Eclipse workspace: File -> Import -> Maven -> Existing maven projects -> select the root directory of the binding -> Finish.Leave Eclipse open and wait for the downloads and build to finish.
WARNING: if the build continues indefinitely, this a bug in the setup that is already being addressed. Meanwhile, to stop the loop deselect from Eclipse -> Project -> Build Automatically. Remember to do Project -> Build Project after changes in the binding project
NOTE: You do not need to add all projects to the workspace, just the binding project you want to work on.
-
In Eclipse Package Explorer: look for
app.bndrun
in theorg.openhab.demo.app
project. Double click to openapp.bndrun
(takes a few seconds) -
Under Browse Repos search for your binding (
astro
) and add it to the "Run Requirements" list using drag&drop from the "Browse Repos" list: -
Click "Resolve": a window with the list of resolved bundles will be shown. Click Finish and save the file.
Now the IDE is ready to start openHAB with a minimum set of the openHAB core bindings, PaperUI and the selected binding
-
Start openHAB from the IDE clicking "Run OSGi" or "Debug OSGi". You can check openHAB is running going with your browser to: http://localhost:8080/paperui/
-
Check the chosen binding is active in PaperUI -> Configuration -> Bindings
Develop a NEW binding with the IDE
To start developing a new binding follow these steps:
-
Close Eclipse
-
From the command line in
openhab2-addons/bundles
directory run:$ ./create_openhab_binding_skeleton.sh MyNewBinding <Author> <GitHubUsername>
to create a skeleton of a new binding
mynewbinding
. Accept withY
the skeleton configuration. -
Edit file
openhab2-addons/bom/openhab-addons/pom.xml
and add your new binding to the list (adapt the artifactid to your binding name!):<dependency> <groupId>org.openhab.addons.bundles</groupId> <artifactId>org.openhab.binding.mynewbinding</artifactId> <version>${project.version}</version> </dependency>
-
From the
openhab2-addons
directory run:mvn -DskipChecks -DskipTests clean install
to rebuild the list of bindings in the BOM (Bill Of Material) and make your new binding visible from the demo.app project -
Now open Eclipse and follow from previous step 6. to import and run/debug your new binding in the Eclipse IDE
Now you can start developing your new binding.
In case the new binding has dependencies to other bundles/libraries see Adding Dependencies for more information.