I’m new on Java and ItelliJ. I have downloaded IntelliJ because I use phpStorm from the same company and known the interface. I work on Windows 10. My OpenHab is on a Debian machine.
I have also try eclipse.
My goal is to change a small passage of a binding.
At first, I have downloaded the master ZIP File from git: https://github.com/volfan6415/openHAB-EMBY
IntelliJ: I go to File - Open and use pom.xml. At first I will only try if I can create the .jar file before I change the code. When I go to Build - Build Project I get this error:
Error:java: error: release version 5 not supported
I have installed the zulu 8 jdk
In eclipse the same. I open the project, go to File - Export and JAR file. Here I use all files in org.openhab.binding.emby, and chose this options:
The error is
JAR export finished with warnings. See details for additional information.
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/EmbyBindingConstants.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/EmbyHandlerFactory.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/discovery/EmbyClientDiscoveryService.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/discovery/EmbyDiscoveryService.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/handler/EmbyDeviceHandler.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/handler/EmbyBridgeHandler.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/model/embyPlayState.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/model/EmbyPlayStateModel.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/model/EmbyPlayingPostJsonModel.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/model/nowPlayingItem.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/protocol/EmbyConnection.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/protocol/EmbyClientSocket.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/protocol/EmbyDeviceEncoder.java
Exported with compile errors: org.openhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/protocol/EmbyHTTPUtils.java
I think I forgot to load anything. Does someone can help me to export the jar file?
As this is a maven project you cannot just click
Build > Build Project in IntelliJ. You need to tell it to use maven to build.
You can do this in two ways:
- The maven tool window (easiest for a one-off build)
- A run configuration (easiest for repeated use)
Maven Tool Window
- Click on the “Maven” button on the right side of your window or go to
View > Tool Windows > Maven
- In the “Maven” window double click
[your project] > Lifecycle > install
- Look for JAR in
[your project dir]/target
- Click the run configuration drop-down on the top toolbar (between the “hammer” and “play” buttons)
- Select “Edit Configurations…”
- Click the plus button in the top left of the new window
- Select “maven”
- Give your run configuration a name.
- Pick your working directory
clean install in the “command line” field.
- Press “OK”
- Select your new run configuration from the drop-down on the top toolbar.
- Press the run (“play”) button to the right of the drop-down.
- Look for JAR in
[your project dir]/target
@rossgb: Thank you for your great tutorial. I have set this, but IntelliJ search a parent POM
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for org.openhab.addons.bundles:org.openhab.binding.emby:2.5.0-SNAPSHOT: Could not find artifact org.openhab.addons.bundles:org.openhab.addons.reactor.bundles:pom:2.5.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 5, column 11
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR] The project org.openhab.addons.bundles:org.openhab.binding.emby:2.5.0-SNAPSHOT (D:\Profil\Downloads\openHAB-EMBY-master\openHAB-EMBY-master\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM for org.openhab.addons.bundles:org.openhab.binding.emby:2.5.0-SNAPSHOT: Could not find artifact org.openhab.addons.bundles:org.openhab.addons.reactor.bundles:pom:2.5.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 5, column 11 -> [Help 2]
Someone with a better grasp on the build system may be able to help you with a more elegant solution when you are not working with a full fork of openhab-addons.
This should at least get you building:
- Clone / Download the openhab-addons repo: https://github.com/openhab/openhab-addons
- Put your openHAB-EMBY project in
- Add this inside the
<modules> section in
- Add this inside the
<dependencies> section of
<openhab-addons>/bundles/org.openhab.binding.emby/pom.xml change this:
Thank you @rossgb and please excuse the initial questions. I must Change a few think but it works
If you have time, you can also explain to me how I work with a full fork. Who knows if I won’t try my own bindings later. But this is not urgent
By a “full fork” I just meant that you can create a new binding project by forking the entire openhab-addons repo and write your binding in-place (as I told you to re-create in my previous post). This makes building easier as maven can find parent POMs by just looking at parent directories.
In this openHAB-EMBY project only the binding itself is checked into the git repo. This means maven needs to go looking elsewhere for parent POMs.
I’m sure there are some arguments you can pass to maven to tell it to look somewhere else in the filesystem or in a maven repository but I’ve not tried that before so I just told you the way I know works.
Sorry I have an additional question. Givs an option in IntelliJ do cleanup the folder?
After I generate the jar file, I have many files like .importorder, .prefs or two times the thing-types.xml (one in target, classes, ESH-INF, thing
and one in src, main, ressources, ESH-INF, thing
Or givs some folder where I can delete after generate?
The maven “clean” phase will get rid of that for you.
e.g. in the maven tool window:
[your project] > Lifecycle > clean
Just make sure you do not have any files from the “target” directory open or maven may not be able to clean everything.