You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Stuart McCulloch <st...@jayway.net> on 2008/07/24 12:08:04 UTC

Re: Help with Felix Maven Plugin (Embed-Dependency attribute)

2008/6/20 techi_amol <te...@yahoo.com>:

>
> Hi all,
>
> What i want to do is generate a bundle where the dependencies needed by my
> classes will be provided by embedding jar files in the bundle archive, and
> add those jar file to the Bundle-ClassPath attribute. I have generated this
> bundle using java's jar command. The bundle works perfectly. Now i am
> trying
> to do similar generation using this maven plug in.
>
> Here the relevant section of my pom.xml
>
> <configuration>
> <instructions>
> <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
> <Bundle-Name>MLBOsgiRemoteDeployment Plug-in</Bundle-Name>
> <Bundle-SymbolicName>MLBOsgiRemoteDeployment</Bundle-SymbolicName>
> <Bundle-Version>${pom.version}</Bundle-Version>
> <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
>
> <Bundle-Activator>mlb.osgi.remote.deploy.activator.MLBOsgiRemoteDeploymentBundleActivator</Bundle-Activator>
>
> <Import-Package>mlb.osgi.deploy.service;version="1.0.0",org.osgi.framework;version="1.3.0",org.osgi.util.tracker;version="1.3.3"</Import-Package>
> <Private-Package>mlb.osgi.remote.deploy.*</Private-Package>
> </instructions>
> <configuration>
>
> On using this i get the error "Unresolved references to [<package name>] by
> class(es) on the Bundle-Classpath [<list of jar file in the bundle
> classpath>] and the bundle archive is not generated.
>
> If i remove the <Import-Package>, the bundle archive is generated with
> right
> right Bundle-ClassPath attribute. However, the plug in adds an
> Import-Package attribute to the generated Manifest and that value contains
> a
> ton of package, that i don't want. How do i control the Import package
> value? If there is now way, can i at least instruct the maven plug in to
> make resolution=optional for all the Import packages.
>

FYI, the additional imports are probably because the dependencies
you're embedding have their own dependencies on other packages
that are not currently contained in your bundle

because you haven't set Embed-Transitive to true, the bundleplugin
will only be embedding direct dependencies - this may, or may not
be what you want (enabling Embed-Transitive will usually give you
everything you need - but can lead to an explosion in bundle size
when some projects, like hibernate, have huge dependency lists)

the thing to remember is that the bundleplugin is simply using the
Maven dependency API - so it's a good idea to read up on this if
you're wondering why certain artifacts appear and others don't:

   http://www.sonatype.com/book/reference/pom-relationships.html#d0e7840

other times you will get additional imports because a dependency
uses a "javax.*" package from the JDK - these are also imported
because by default OSGi only provides java.* packages for 'free'
- any other packages (like javax.*) should usually be imported

if you know you don't need certain packages (because the code
that uses them is actually never called at runtime) then you can
mark them as optional, for example:

   <Import-Package>*;resolution:=optional</Import-Package>

will mark all generated imports as optional - you can find more
details on the Import-Package instruction and wildcards here:

   http://aqute.biz/Code/Bnd

   http://cwiki.apache.org/FELIX/apache-felix-maven-bundle-plugin-bnd.html

note that the default is *, which means add all detected imports

HTH

I am attaching the generated Manifest (
> http://www.nabble.com/file/p18018547/MANIFEST-generated.txt
> MANIFEST-generated.txt ) and the manifest that i actually need (
> http://www.nabble.com/file/p18018547/MANIFEST-needed.txtMANIFEST-needed.txt
>
> ) for your reference.
>
>
>
> cheers
> amol.
> --
> View this message in context:
> http://www.nabble.com/Help-with-Felix-Maven-Plugin-%28Embed-Dependency-attribute%29-tp18018547p18018547.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Cheers, Stuart