[ 
https://issues.apache.org/jira/browse/FELIX-954?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12675757#action_12675757
 ] 

Stuart McCulloch commented on FELIX-954:
----------------------------------------

This is a non-trivial feature that will probably require co-operation from the 
Bnd Tool, so it's unlikely to be in the next release (expected end of Feb).

We also have to be careful not to mark packages as optional when they are 
imported by both optional and non-optional dependencies, or when packages from 
optional dependencies are embedded inside the bundle (as embedded packages 
should then be considered as non-optional).

FYI, there are a number of existing options you can use to make your life 
easier when handling optional dependencies:

1)  when embedding dependencies you can exclude optional dependencies by using:

     <configuration>
       <instructions>
         <Embed-Dependency>*;optional=false</Embed-Dependency>
         <!-- etc. -->
       </instructions>
     </configuration>

2) with the 1.5.0-SNAPSHOT bundleplugin you can exclude optional dependencies 
from the classpath passed to the Bnd Tool:

     <configuration>
       <excludeDependencies>*;optional=true</excludeDependencies>
     </configuration>

both of which may reduce the number of imports when processing large graphs 
full of optional dependencies.

You can also take advantage of the wildcard support provided by the Bnd Tool, 
for example to mark all imports as optional:

     <configuration>
       <instructions>
         <Import-Package>*;resolution:=optional</Import-Package>
         <!-- etc. -->
       </instructions>
     </configuration>

and if you know that the packages from optional dependencies have a common 
prefix you can be a bit more specific:

     <configuration>
       <instructions>
         <Import-Package>
           javax.*;resolution:=optional,
           com.sun.*;resolution:=optional,
           *
         </Import-Package>
         <!-- etc. -->
       </instructions>
     </configuration>

Also when people talk about bundles with hundreds of imports that sounds like 
either they're trying to create a "mega-bundle" which contains (and exports) a 
large number of packages, or they have extremely tight coupling between their 
main bundle and their optional dependencies. Either way creating smaller 
bundles along with possibly some refactoring to reduce coupling should 
drastically reduce your number of imports.

> Import-Package should include packages from optional Maven dependencies with 
> resolution=optional
> ------------------------------------------------------------------------------------------------
>
>                 Key: FELIX-954
>                 URL: https://issues.apache.org/jira/browse/FELIX-954
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven Bundle Plugin
>    Affects Versions: maven-bundle-plugin-1.4.3
>            Reporter: Pavol Juhos
>
> It would be great if maven-bundle-plugin used resolution=optional for 
> packages that are coming from _optional_ Maven dependencies.
> The current behavior causes problems e.g. when embedding libraries with lots 
> of optional dependencies. As described by Detelin Yordanov: "[I]t seems that 
> BND finds the
> references to [the optional packages] and assumes them to be mandatory adding 
> a bunch of imports in the manifest." This can easily result in hundreds of 
> import-package declarations importing packages that are actually not required 
> by the application. In these cases it is not practical to handle this 
> manually in the plug-in / BND configuration.
> This issue was already discussed on felix-users list in Jan 2009 -- see 
> thread "Maven bundle plugin: Is it possible to mark optional Maven 
> dependencies to be imported with resolition=optional"
> http://mail-archives.apache.org/mod_mbox/felix-users/200901.mbox/%[email protected]%3e

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to