20. September 2017
by Moritz Kammerer | 732 words | ~4 min read
Developing the Eclipse SmartHome (ESH) bindings with another IDE than Eclipse is difficult because the standard way of developing the bindings requires the tools provided by the Eclipse IDE. One can develop the ESH bindings with IntelliJ, however a crucial question remains open: how to test the developed bindings without having the Eclipse tools at hand? Using IntelliJ to develop the ESH bindings is different to using Eclipse for two main reasons:
Our approach is based on the packaging example of ESH in combination with Eclipse Concierge as OSGi Container. A full MAVEN build with mvn clean package creates a new zip file within the /target directory. This zip file contains a full OSGi container, the Eclipse SmartHome basics, the Yahoo Weather Binding and an addons directory. The OSGi container scans the addons directory for bundles and deploys them automatically. This zip file can be used to create a Docker container. In order to stop the container gracefully a small change in the start script is needed. A description of it can be found here: qaware/smarthome-packaging-sample.
We have updated and added some dependencies to the original repository. One of the updated dependencies is the Jetty webserver, which also includes its client in the latest version of the 9.3.x branch.
All the following examples and commands are based on the qaware/smarthome-packaging-sample repository.
The Dockerfile creates an image which is runnable out of the box. It contains a full Eclipse SmartHome, which runs on an Alpine Linux with the current OpenJDK 8 Runtime Environment. The image has a final size of less than 140 MB.
You can find the Dockerfile within the forked repository.
To build and tag the container as
eclipse/smarthome:latest, you need to run:
./mvnw clean package && docker build . -t eclipse/smarthome:latest
Now it is possible to start the container:
You can subsequently open the PaperUI and the System Console (username & password: admin). The container can also be started in debug mode, which allows connecting an external debugger to the container. To start the container in debug mode use this command:
You can now connect the container with a Java debugger (like IntelliJ) using the address
This part builds upon our previous blog post about the usage of Docker and IntelliJ: How to use Docker within IntelliJ You can use the previously created Docker image for the development of bindings. To do that you need another small Dockerfile which copies the binding into /opt/esh/addons/ of the container:
You can place this Dockerfile into the main directory of the bundle, next to the MAVEN pom.xml, and subsequently use it for a new Docker deployment in IntelliJ as described in How to use Docker within IntelliJ. In IntelliJ you can directly start the Docker deployment with an attached debugger. Alternatively, you can create a volume mount to /opt/esh/addons and, after the successful completion of the build, copy the binding jar into the mount.
We recommend to mount a volume into the Docker container to store the information about the bindings and the other configurations of the ESH: