bnd icon indicating copy to clipboard operation
bnd copied to clipboard

Bndtools / Maven with sources JAR

Open thahnen opened this issue 1 year ago • 3 comments

TL;DR: I didn't find any concrete information on how to include the sources of JAR archives in the sources.jar that are configured using the -includeresource statement (e.g. -includeresource: lib/guava.jar=guava-*.jar;lib=true does not pack the sources of the guava library into the sources JAR archive).

I found a bit of conflicting information regarding packaging the sources when using Maven. There is THIS thread that seems to not have an answer provided and I found THIS snippet. But if I understood correctly the latter is used to follow the OSGi guidelines and have the sources packed into the normal JAR archive instead of the sources.jar.

So is there any possibility? I'm currently using two different bnd files in the Maven build that are used via the bnd-process goal. The first one uses -includeresource statements like the one mentioned above (but a bit more complicated), and the other one has none. It is a bit confusing, I was also trying to use -sources: true but it didn't do anything.

So my question is: Is there something possible? Does the -includeresource have an option for that or do I have to invoke something else? Is it possible with Maven or does it require some manual magic perhaps?

thahnen avatar May 02 '24 14:05 thahnen

you can include them explicitly?

-includeresource: 
    lib/guava.jar=guava-*.jar;lib=true, \
    OSGI-OPT/[email protected]

pkriens avatar May 03 '24 07:05 pkriens

I'm using Maven with the biz.aQute.bnd:bnd-maven-plugin version 6.4.0 and have tried different approaches but with no success.

In my Maven dependencies I have the following ones defined:

<dependencies>
  <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <classifier>sources</classifier>
    </dependency>
</dependencies>

I've tried the following commands:

-includeresource: lib/guava.jar=guava-*.jar;lib:=true,\
  OSGI-OPT/[email protected]
-includeresource: lib/guava.jar=guava-*.jar;lib:=true,\
  OSGI-OPT/src=@guava-*-sources.jar
-includeresource: lib/guava.jar=guava-*.jar;lib:=true,\
  OSGI-OPT/[email protected];lib:=true,
-includeresource: lib/guava.jar=guava-*.jar;lib:=true,\
  OSGI-OPT/guava-sources.jar=guava-*-sources.jar;lib:=true,

Am I missing something?

thahnen avatar May 03 '24 10:05 thahnen

The syntax you used indicated the guava-*.jar was on the file system. In workspace bnd, you can use ${repo;com.google.guava:guava} instead of the file name to get it from a repository. I am not sure how this works in maven because their repository model is very different, maybe one of the maven users can chime in. @timothyjward ?

pkriens avatar May 07 '24 10:05 pkriens

Any feedback?

pkriens avatar Jun 07 '24 09:06 pkriens

please reopen if you want to take this further.

pkriens avatar Jun 21 '24 15:06 pkriens