Skip to content

Commit

Permalink
[development] Adding generic, maven based run and debug.
Browse files Browse the repository at this point in the history
Apply MR comments

Signed-off-by: Gwendal Roulleau <[email protected]>
  • Loading branch information
dalgwen committed Dec 29, 2024
1 parent 1d36eef commit 1d66f99
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
10 changes: 9 additions & 1 deletion .vuepress/docs-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,15 @@ module.exports = [
title: 'Developer Guide',
collapsable: true,
children: [
['developer/', 'Overview & Introduction'],
{ title: 'IDEs',
collapsable: true,
children: [
'developer/eclipse',
'developer/intellij',
'developer/vscode',
'developer/generic',
]
},
'developer/guidelines',
'developer/addons/',
'developer/bindings/',
Expand Down
17 changes: 12 additions & 5 deletions developers/ide/generic.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,26 @@ will be available in your local repository and the demo project will be able to

### Build project

::: Warning Versions
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.
:::

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.

### Preparation

There are two files to take care of:

- `/openhab-distro/launch/app/pom.xml` must contain the artifact you are developing in the dependencies section.
- `/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")

- `/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.
- `/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)

After editing this two files, use this maven command from the `/openhab-distro/launch/app/` directory:

`mvn bnd-resolver:resolve`

This will ask the bnd plugin to 'resolve' the dependencies, i.e. to calculate what to run in the OSGi runtime.
This task will update the `runbundles` section of the `app.bndrun` file.
This will ask the bnd plugin to 'resolve' the dependencies (i.e. to calculate which bundles to run in the OSGi runtime) and update
the `runbundles` section of the `app.bndrun` file accordingly.
Each time you add a dependency or change version, you HAVE to run a resolve task.

::: warning
Expand All @@ -58,12 +62,15 @@ To launch the demo app, using the content of the `app.bndrun` file:

`mvn bnd-run:run`

You can now open the app in your browser via http://localhost:8080/.

To launch in debug mode:

`mvn -D-runjdb=10001 package bnd-run:run`

Wait for the process to pause and show the log `Listening for transport...` then attach your IDE to the remote debugging
session (here, on port 10001). The openHAB demo project startup process will then resume.
session (here, on port 10001). The openHAB demo project startup process will then resume and you will be able to
open it in your browser.

Each modification of your code requires rebuilding your add-on with `mvn clean install` so that it is
deployed in your local repository and accessible for the next execution.
Binary file modified developers/ide/images/generic_ide.pdn
Binary file not shown.
Binary file modified developers/ide/images/generic_ide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions developers/ide/intellij.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: IntelliJ

## Prerequisites

- git, Maven, IntelliJ and Java 17 are installed
- git, Maven (at least 3.8.6), IntelliJ and Java (21) are installed and available in the path.

## Build the repositories

Expand All @@ -25,13 +25,13 @@ Use the command `git clone https://github.com/<yourgitusername>/openhab-<addons|
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.
![Import modules](images/ide_setup_intellij_import_module.png)
1. Repeat step 2 and 3 for all repositories you cloned.
1. Use Maven to clean & install projects
1. Use Maven to clean & install projects. Make sure you use the required Maven version (3.8.6 is recommended).

- `mvn clean install` in the root of the repositories using commandline Maven (or IntelliJ Maven view)
- some of the add-ons might fail to build - if it's not the one you're interested in, that should not bother you
- when the Maven project finished, you should find the freshly built addon JAR in the target directory

You then have two main options to run your development. Use the official distribution, or use Maven.
You then have two main options to run your development: use the official distribution, or use Maven.

## Option 1: Use and debug from the official distribution

Expand Down

0 comments on commit 1d66f99

Please sign in to comment.