Embedded-Artifacts Instruction - ignored by bndtools?

388 views
Skip to first unread message

Carsten Gräf

unread,
Sep 13, 2016, 2:23:25 AM9/13/16
to bndtools-users
Hi everybody,

I've got this third-party OSGi bundle with this in its manifest file:

  Bundle-ClassPath       ...
  Embed-Dependency   *                                       
  Embed-Transitive        true                                    
  Embedded-Artifacts    ...
  Export-Package          ...

Whatever you might think about this approach, I wonder: should bndtools be able to resolve classes from the exported-packages? 

I got lots of "The import x.y.z cannot be resolved" errors, but the classes are there, contained in jar files (root dir), referenced in 
Bundle-ClassPath and in Embedded-Artifacts, things _seem_ to be ok.

This is the first time I've ever seen the "Embedded-Artifacts"-Instruction and I could not find much about it (other than in the maven bundle
plugin, with which you can create such "I-carry-all-my-transitive-dependencies-with-me"-bundles). 

So my question is: is this supported by bndtools at all? 

Thanks for your help (and bnd/bndtools in general ;))
Carsten


Neil Bartlett

unread,
Sep 13, 2016, 6:45:03 AM9/13/16
to bndtool...@googlegroups.com
Can you clarify the following statement:

On 13 Sep 2016, at 07:23, Carsten Gräf <eva...@gmail.com> wrote:

Hi everybody,

I've got this third-party OSGi bundle with this in its manifest file:

  Bundle-ClassPath       ...
  Embed-Dependency   *                                       
  Embed-Transitive        true                                    
  Embedded-Artifacts    ...
  Export-Package          ...

Whatever you might think about this approach, I wonder: should bndtools be able to resolve classes from the exported-packages? 

I got lots of "The import x.y.z cannot be resolved" errors, but the classes are there, contained in jar files (root dir), referenced in 
Bundle-ClassPath and in Embedded-Artifacts, things _seem_ to be ok.

If the classes are in the root of the bundle then we should be able to see them at build time. Otherwise no we cannot.

The simple reason for this is that Java compilers don’t support nested JARs, nor to they understand the Bundle-ClassPath manifest header. This is a capability offered by OSGi at runtime only.



This is the first time I've ever seen the "Embedded-Artifacts"-Instruction and I could not find much about it (other than in the maven bundle
plugin, with which you can create such "I-carry-all-my-transitive-dependencies-with-me"-bundles). 

So my question is: is this supported by bndtools at all? 

Thanks for your help (and bnd/bndtools in general ;))
Carsten



--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Benson Margulies

unread,
Sep 13, 2016, 8:33:56 AM9/13/16
to bndtool...@googlegroups.com
On Tue, Sep 13, 2016 at 6:44 AM, Neil Bartlett <njbar...@gmail.com> wrote:
Can you clarify the following statement:

On 13 Sep 2016, at 07:23, Carsten Gräf <eva...@gmail.com> wrote:

Hi everybody,

I've got this third-party OSGi bundle with this in its manifest file:

  Bundle-ClassPath       ...
  Embed-Dependency   *                                       
  Embed-Transitive        true                                    
  Embedded-Artifacts    ...
  Export-Package          ...

Whatever you might think about this approach, I wonder: should bndtools be able to resolve classes from the exported-packages? 

I got lots of "The import x.y.z cannot be resolved" errors, but the classes are there, contained in jar files (root dir), referenced in 
Bundle-ClassPath and in Embedded-Artifacts, things _seem_ to be ok.

If the classes are in the root of the bundle then we should be able to see them at build time. Otherwise no we cannot.

The simple reason for this is that Java compilers don’t support nested JARs, nor to they understand the Bundle-ClassPath manifest header. This is a capability offered by OSGi at runtime only.



This is the first time I've ever seen the "Embedded-Artifacts"-Instruction and I could not find much about it (other than in the maven bundle
plugin, with which you can create such "I-carry-all-my-transitive-dependencies-with-me"-bundles). 
To fill in: Embedded-Artifacts isn't an instruction, really. It's more of a comment left behind by the maven-bundle-plugin when it builds a bundle that has jar files in the Bundle-Classpath. The problem, as Neil detailed, is that java compilers don't know about Bundle-Classpath. I suppose that we could have tooling in Maven or bndtools that, on seeing this, could unpack the extra jar files to a temp dir and add them to the compile classpath.

 

So my question is: is this supported by bndtools at all? 

Thanks for your help (and bnd/bndtools in general ;))
Carsten



--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

Tim Ward

unread,
Sep 13, 2016, 12:28:40 PM9/13/16
to bndtool...@googlegroups.com
Another option would be to flatten the embedded jars as they are included - this would make the output bundle fit the normal JAR layout and so be more palatable to all tools without special handling.

Based on the initial email's "Whatever you might think about this approach..." comment I will not dig deeper into why these dependencies are embedded.

Regards,

Tim

Sent from my iPhone
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.

BJ Hargrave

unread,
Sep 13, 2016, 12:31:21 PM9/13/16
to bndtool...@googlegroups.com
The bnd command line tool has a flatten option:

$ bnd flatten help

NAME
  flatten                     - Flatten a bundle by expanding all entries on the
                                Bundle-ClassPath

SYNOPSIS
   flatten <input> <output>

It flattens the classpath and removes the Bundel-Classpath entries and header.

To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
BJ

Benson Margulies

unread,
Sep 13, 2016, 1:35:31 PM9/13/16
to bndtool...@googlegroups.com
On Tue, Sep 13, 2016 at 12:31 PM, BJ Hargrave <b...@bjhargrave.com> wrote:
The bnd command line tool has a flatten option:

$ bnd flatten help

NAME
  flatten                     - Flatten a bundle by expanding all entries on the
                                Bundle-ClassPath

SYNOPSIS
   flatten <input> <output>

It flattens the classpath and removes the Bundel-Classpath entries and header.

Just beware of SPI files, signature files, and all the other detritus that makes it nontrivial to flatten some such items.
 

To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
--
BJ

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

Carsten Gräf

unread,
Sep 14, 2016, 12:50:50 AM9/14/16
to bndtools-users
Hi and thanks to everyone for your input and clarifications.

So, "Embedded-Artifacts" is basically a comment, good to know, and I should not expect it to magically help me with any build time resolving...
The third-party bundle I got has nested jars, so, even if it might working at runtime, I cannot use it to provide its classes at build time. 
I'll contact the bundle's creator to help me with that issue,

thanks again
Carsten 
Reply all
Reply to author
Forward
0 new messages