Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[development] Adding generic, maven based run and debug. #2435

Merged
merged 3 commits into from
Dec 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[development] Adding generic, maven based run and debug.
Apply MR comments

Signed-off-by: Gwendal Roulleau <[email protected]>
dalgwen committed Dec 29, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 2278f3b618e1fbc494f0bc8f4e7bd04e340d4b1f
9 changes: 9 additions & 0 deletions .vuepress/docs-sidebar.js
Original file line number Diff line number Diff line change
@@ -213,6 +213,15 @@ module.exports = [
collapsable: true,
children: [
['developer/', 'Overview & Introduction'],
{ title: 'IDEs',
collapsable: true,
children: [
'developer/ide/eclipse',
'developer/ide/intellij',
'developer/ide/vscode',
'developer/ide/generic',
]
},
'developer/guidelines',
'developer/addons/',
'developer/bindings/',
17 changes: 12 additions & 5 deletions developers/ide/generic.md
Original file line number Diff line number Diff line change
@@ -23,22 +23,26 @@ will be available in your local repository and the demo project will be able to

### Build project

::: warning
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed it before. Done


::: warning
@@ -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/](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
@@ -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

@@ -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