You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[development] Adding generic, maven based run and debug. (#2435)
* [development] Adding generic, maven based run and debug.
Also see openhab/openhab-distro#1707
Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
* [development] Adding generic, maven based run and debug.
Apply MR comments
Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
* [development] Adding generic, maven based run and debug.
Apply MR comments
Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
---------
Signed-off-by: Gwendal Roulleau <gwendal.roulleau@gmail.com>
It can be particularly useful, regardless of the IDE, to be able to launch a development instance of openHAB.
11
+
This is the purpose of the `org.openhab.demo.app` project, which can be found in the `openhab-distro` repository.
12
+
13
+
To do this, you need to clone the [openhab distro repository](https://www.github.com/openhab/openhab-distro)
14
+
15
+
To launch the demo project, Eclipse [has its bnd plugin](./eclipse.html#working-with-add-ons).
16
+
However, it can sometimes be particularly slow. Maven is therefore a completely viable alternative (and the only option
17
+
available for other IDEs).
18
+
Using the demo project through Maven will allow you to run an openHAB instance that uses the artifacts present in your
19
+
local Maven repository (and downloads them beforehand if they are not already present).
20
+
21
+
This means that if you develop an add-on (or even a `openhab-core` module), once you have built and installed it, it
22
+
will be available in your local repository and the demo project will be able to use your development.
23
+
24
+
### Build project
25
+
26
+
::: warning
27
+
Make sure you meet the prerequisites like the Java and Maven version. As of openHAB 5.x Java 21.x is required and at least mvn 3.8.6.
28
+
:::
29
+
30
+
Use Maven to build the projects you want to develop for. It is important to use the `mvn install` option to copy the artifact in your local repository.
31
+
32
+
### Preparation
33
+
34
+
There are two files to take care of:
35
+
36
+
-`/openhab-distro/launch/app/pom.xml` must contain the artifact you are developing in the dependencies section (search for "uncomment this and add the name of your binding that you want to work on")
37
+
38
+
-`/openhab-distro/launch/app/app.bndrun` will list the modules needed by the OSGi runtime. You also have to add your add-on in the `runrequires` section (e.g. `bnd.identity;id='org.openhab.binding.YOURBINDINGNAME'` and don't forget to add the `\` to the previous line if you adding it to the end of the list)
39
+
40
+
After editing this two files, use this maven command from the `/openhab-distro/launch/app/` directory:
41
+
42
+
`mvn bnd-resolver:resolve`
43
+
44
+
This will ask the bnd plugin to 'resolve' the dependencies (i.e. to calculate which bundles to run in the OSGi runtime) and update
45
+
the `runbundles` section of the `app.bndrun` file accordingly.
46
+
Each time you add a dependency or change the version, you HAVE to run a resolve task.
47
+
48
+
::: warning
49
+
The `pom.xml` file is versioned. The version fields present in the file must match the modules
50
+
you are developing. For example, if you are developing a module for `openhab-core` and it is deployed as version
51
+
5.0.0-SNAPSHOT in your local repository, you must use this same 5.0.0-SNAPSHOT version in the version field of the
52
+
`org.openhab.demo.app` artifact. Similarly, for add-on development, ensure that the version field of your add-on in the
53
+
pom.xml file matches the version you are currently developing. If you use incorrect versions, you will not understand
54
+
why your changes are not being taken into account
55
+
:::
56
+
57
+
### Launching and debugging
58
+
59
+
Go to the directory `/openhab-distro/launch/app`
60
+
61
+
To launch the demo app, using the content of the `app.bndrun` file:
62
+
63
+
`mvn bnd-run:run`
64
+
65
+
You can now open the app in your browser via [http://localhost:8080/](http://localhost:8080/).
66
+
67
+
To launch in debug mode:
68
+
69
+
`mvn -D-runjdb=10001 package bnd-run:run`
70
+
71
+
Wait for the process to pause and show the log `Listening for transport...` then attach your IDE to the remote debugging
72
+
session (here, on port 10001). The openHAB demo project startup process will then resume and you will be able to
73
+
open it in your browser.
74
+
75
+
Each modification of your code requires rebuilding your add-on with `mvn clean install` so that it is
76
+
deployed in your local repository and accessible for the next execution.
Copy file name to clipboardExpand all lines: developers/ide/intellij.md
+44-14Lines changed: 44 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -7,30 +7,44 @@ title: IntelliJ
7
7
8
8
## Prerequisites
9
9
10
-
- git, Maven, IntelliJ and Java 17 are installed
10
+
- git, Maven (at least 3.8.6), IntelliJ and Java (21) are installed and available in the path.
11
11
12
-
## Install openHAB distribution
12
+
## Build the repositories
13
13
14
-
1. Install the official [openHAB distribution](https://www.openhab.org/download/)
15
-
1. Start the distribution **in debug mode** (use `./start_debug.sh` instead of `./start.sh` in step 4)
14
+
1. Fork and clone the repositories into a parent directory (Reference `<PARENT_DIR>` from now on for this article). Take only the one(s) you will work on:
16
15
17
-
This article refers to the directory where you installed the distribution as `<DISTRO_DIR>`.
Use the command `git clone https://github.com/<yourgitusername>/openhab-<addons|core|webui>` (replace git user name accordingly).
20
21
21
-
1. Fork and clone the [openhab addons repository](https://www.github.com/openhab/openhab-addons) into a new directory (Reference `<ADDON_DIR>` from now on for this article) with `git clone https://github.com/<yourgitusername>/openhab-addons` (replace git user name accordingly)
22
+
1. Open IntelliJ, select the file/open, and choose the `<PARENT_DIR>`
23
+
1. Open The Module settings (inside `Project Settings`, or use F4). Click on the + button and select `Import module`.
24
+
1. Choose one of the repository directory you just cloned. select the Maven external model as import format.
25
+
IntelliJ will start importing and indexing. It will take while, wait until finished. The Module window should now be filled with a bunch of projects.
0 commit comments