How to add an external library in a bundle?

Hi everyone,

I’m trying to add an external library (for the moment only the library org.apache.commons.cli ) to the OpenHAB core project. I have already imported the library locally into the module that needs it. My code compiles but when I try to maven the bundle with mvn clean install it cannot find the library and the used functions of the library (so an error occurs).

How can I add a library in a bundle? It is explained here in the openhab documentation but I can’t get it to work.

Can someone explain to me what exactly I need to add in the bundle pom.xml and in the feature.xml?

The library is already installed but not configured with the bundle, could someone help me?

Thanks in advance,

Nicolas Gennart.

Earlier advice How to include Maven dependencies in binding? - #2 by ssalonen

First you need to decide whether other bindings would be likely to use this dependency (feature.xml) or whether it is likely to remain only for this binding (pom.xml with compile scope).

What is the exact error you are having?

1 Like

Hi,

Thanks for your answer,

I will check the other post, I will try to make it work again…

Here there is the error displayed:

And also when I’m trying to put the dependency like above explain in maven repository

<!-- https://mvnrepository.com/artifact/p2.osgi.bundle/org.apache.commons.cli -->

<dependency> <groupId>p2.osgi.bundle</groupId> <artifactId>org.apache.commons.cli</artifactId> <version>1.0.0.v20080604-1500</version> </dependency>

The p2.osgi.bundle, org.apache.commons.cli and 1.0.0.v20080604-1500 are in red and these names are not find by the IDE.

Do you see the problem?

Thank you very much,

Nicolas Gennart.

Would this work instead https://mvnrepository.com/artifact/commons-cli/commons cli

1 Like

Yes it works with this maven repository.

Thank you for you help.

Nicolas Gennart.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.