Setting up development environment with IntelliJ

Tags: #<Tag:0x00007f7465c9f0f0> #<Tag:0x00007f7465c9f000>

One of major advantages of changes made after smarthome/openhab reintegration is plain maven build. The plain difference between openhab 1 and openhab > 2.5.0.M1 is how the whole thing is building internally. Thanks to great contributions from active maintainers and binding developers build is much more stable, despite of Eclipse glitches occurring here and there.
As a user, you might not notice that at all, but as a contributor, you most likely suffered some of the pains caused by build changes.

This simple tutorial is composed from few videos:

The magic pom contents for you:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.openhab</groupId>
    <artifactId>openhab-super-pom</artifactId>
    <version>1.0.1</version>
  </parent>

  <groupId>org.openhab</groupId>
  <artifactId>openhab</artifactId>
  <version>2.5.0-SNAPSHOT</version>

  <packaging>pom</packaging>

  <modules>
    <module>openhab-core</module>
    <module>openhab2-addons</module>
    <module>openhab-webui</module>
    <module>openhab-distro</module>
  </modules>

</project>

Importing project into intellij:

Working with milestone build:

Getting into IDE after 30 minutes of waiting:

5 Likes

Looking forward to these tutorials and videos. I am an intellij user and have not yet taken the plunge in getting openhab development running in intellij yet. Thanks for putting these together.

This looks interesting. Were you able to get the zwave and zigbee bindings to compile from source?

Its ad-hoc recording, many things fall off the cliff. Basic functionality - code editing and (maven) build from IDE is working, however some parts are still bumpy due to xtext dependencies. I hope that I will manage to show in later video how to get it over in less convenient (but reliable) way.

1 Like

Nice!
Are you putting effort into update this page as well?
I will give this a try in the upcoming week.

2 Likes

When I try to open the pom.xml in IntelliJ IDEA 2019.2.1 nothing happens… any suggestion?

P.S.: Command line works, but there is a typo in video 2.

I am using a transformation service now:

(function(i) {
    var date    = new Date(parseInt(i));
    var result  = (date.getDate()    < 10 ? '0' : '') +  date.getDate()       + '.';
        result += (date.getMonth()   <  9 ? '0' : '') + (date.getMonth() + 1) + '.';
        result +=                                        date.getFullYear()   + ' ';
        result += (date.getHours()   < 10 ? '0' : '') +  date.getHours()      + ':';
        result += (date.getMinutes() < 10 ? '0' : '') +  date.getMinutes()    + ':';
        result += (date.getSeconds() < 10 ? '0' : '') +  date.getSeconds();
    return result;
})(input)

There are two dialogs in IntelliJ - one to open project second to import project. Just to be on safe side try with import and then select directory where you have maven pom file. It should be sufficient to launch the import wizard.
I am not aware of any changes in 2019.2 version of IntelliJ thus it should generally work out of the box. If it doesn’t then please check (and/or share) IDE logs for additional information.
The transformation service is not related to topic so I can’t help with this one.