Embedding another .jar in a binding .jar

I am trying to embed a library .jar inside by binding .jar and fail to do so. I put my library inside lib/ subfolder of the binding project and set up project’s build path in eclipse. The binding project builds successfully, but the resulting .jar does not contain my library. Consequently, i cannot run it due to unresolved dependencies.
What am i missing? I tried to study rfxcomm binding, which also has another library (jd2xx) bundled inside, i found no explicit mentionings of the library .jar anywhere but .classpath ; but i have the same setting in my .classpath.

1 Like

You don‘t want to embed jars in other jars. This is some sort of a „last resort“ if nothing else works. What is the root problem? Can you show your complete code?

The “root problem” is i need to use the library i wrote:
https://github.com/Sonic-Amiga/opensdg?files=1 This library is not available on any Maven repository and it is unlikely to be accepted there due to its narrow specialization and specific applications. It is more likely to be distributed as part of openhabian in future. Additionally it is in development and testing stage at the moment, so it’s not even ready yet for uploading to a public repo.
I don’t have my binding code on any public repo yet since it doesn’t do anything useful yet, but ok, i’ll share it for you today in the evening

Everybody can publish on bintray and only needs to fulfill some basic requirements (version control - already in github, a source code bundle, a free license) to be included in jcenter. So this seems a low hurdle if the other wants it.

We can also add them to our own repo, if it is not possible. But we‘ll not accept new /lib in a source code repo, so this is not an option.

I meant your source, not the library.

Well, OK. Then for the time being i will import the code into a binding project.
Actually, over time it can become an OpenHab component by itself, similar to modbus support. This would happen if there is some more hardware using the same cloud with the same protocol.
BTW, since we are talking about bundling and distribution… What is the preferred policy regarding native code? Simply embedding an .so into JAR works quite badly on Linux if the .so depends on something else (protobuf-c and libsodium in my case). The .so either has external dependencies, which are not tracked, or i have to build the whole dependency chain myself in order to get .a files with -fPIC option, to be statically linked into the final .so

The library seem GPL v3. That means it might be a problem to include it in openHAB as that is not compatible with the eclipse license.

It’s my repo and my code, i can relicense it, no problem. I just chose something i am more familiar with.
The only thing i want to keep is “non-commercial client use only” limitation, since the library implements reverse engineered protocol to talk to a commercial cloud.

By this time the problem with embedded .jar has solved itself. :slight_smile: I simply started my computer and opened the project in Eclipse, and it mysteriously worked.

@hilbrand Hi! Slightly back to the topic. What licenses are compatible with EPL ?