2008/9/17 Jim Babka <[EMAIL PROTECTED]>

> What I mean is that there were no dependencies at all being pulled in to
> the bundle - either explicit or transitive. I have purposely made the
> "eclipse-deps" dependency "provided" scope because I really do not want them
> to show up in the bundle. I also do not want any transitive dependencies
> included, either. All I wanted to be included were the 5 explicit
> dependencies that were listed without any scope. However, none of them was
> being included - the only stuff in the bundle were the classes that were
> directly part of this module.
>
> In any case, I tried making the changes that you suggested to the
> Embed-Dependency tag and adding the Embed-Transitive tag. Sure enough, now I
> got all kinds of stuff, including the transitive dependencies that I did not
> want. Then I had a thought - I removed the transitive specification but kept
> your suggested version of the Embed-Dependencies tag. Success! Now the
> bundle has the dependencies I want, so there is apparently a bug that gets
> worked around by using the "type=" specification!
>
interesting - could you provide a standalone test project that recreates the
bug
and builds without needing access to special repos, etc?  ie. your original
pom
didn't build so I created my own mini-project that used a pom dependency,
but
unfortunately I wasn't able to recreate the missing dependency issue...

without a testcase we'd probably need detailed build logs (ie. mvn -X
install)

feel free to raise this over at JIRA:
http://issues.apache.org/jira/browse/FELIX

> However, there is a bizarre thing going on still: the bundle has the JARs I
> want in its root directory, but they are also unpacked inside it. So, I have
> a JAR with two copies of everything I want - one inside another set of JARs,
> and one directly in the bundle's JAR. How can I stop that from happening? I
> would be OK with it having just the JARs inside the bundle (because WPS will
> unpack inner JARs at bundle deploy time), but however it works, I definitely
> don't want two copies of everything.
>
having two copies of classes, both unpacked and embedded as jars, is a sign
that your Embed-Dependency and Export-Package instructions are overlapping

Export-Package tells BND to pull in classes found in the named packages from
the build classpath and add them to the bundle, Embed-Dependency tells BND
to embed (or inline if enabled) whole artifacts in the bundle.

so say I have:

  Export-Package: org.objectweb.asm.*

and I have the asm artifact as a compile scope dependency, then I would see
the org.objectweb.asm classes unpacked in the bundle, ie. pulled in by BND.

say I now decide to embed asm as a jar, for example with:

  Embed-Dependency: *;scope=compile|runtime

I would now see the asm artifact embedded inside bundle - but I would also
see the unpacked classes from before, because I'm still asking BND to pull
them in (you will probably also see split package warnings during the
build).

ok - so how do I embed asm as a jar, but mark its packages as exported
without pulling in the unpacked classes...

well, there is another export instruction added for exactly this reason:

  -exportcontents: org.objectweb.asm.*

  ( <_exportcontents> in the pom.xml )

this instruction is merged with Export-Package, after BND has decided on
the content of the bundle - that is, it works just like Export-Package
except
that it won't alter the content of the bundle.

so by removing org.objectweb.asm.* from Export-Package and using the
-exportcontents instruction instead along with Embed-Dependency, I can
now embed the asm artifact in my bundle and export its packages:

  Embed-Dependency: *;scope=compile|runtime
  -exportcontents: org.objectweb.asm.*

final note: standard Java tools like javac cannot use jars embedded within
jars, so you might still need to compile against the original artifacts -
but
OSGi will be able to see the embedded jar(s)

HTH

> Thanks for your help so far - I'm a lot farther along than I was yesterday.
>
>
> Jim Babka
> S/W Engineer, Industry SOA Accelerators
> (512)838-8180
> [EMAIL PROTECTED]
> [image: Inactive hide details for "Stuart McCulloch" <[EMAIL 
> PROTECTED]>]"Stuart
> McCulloch" <[EMAIL PROTECTED]>
>
>
>
>     *"Stuart McCulloch" <[EMAIL PROTECTED]>*
>
>             09/16/2008 11:48 PM
>             Please respond to
>             [email protected]
>
>
> To
>
> [email protected]
> cc
>
>
> Subject
>
> Re: Embed-Dependency doesn't work
>
> 2008/9/17 Jim Babka <[EMAIL PROTECTED]>
>
> > Sorry if this is a repeat, but I didn't know where to send a post (there
> > is all kinds of documentation on how to manage your subscription, but
> > there's nothing that says, "send postings to this address").
> >
> > I am new to Felix, and am trying to use the maven-bundle-plugin to build
> > an OSGi bundle that includes dependent JARs. The web page says that I
> > should use the Embed-Dependency instruction to cause this to happen, but
> > it is not doing anything (and in fact, the instruction is just ending up
> > copied verbatim into the manifest file for the bundle).
> >
> > Here is the POM file that I'm using. The build succeeds, but again, none
> > of my dependencies are being copied into the resulting JAR. Can anyone
> > offer any clues as to what I can do to make this work?
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance";
> >         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > http://maven.apache.org/maven-v4_0_0.xsd";>
> >    <modelVersion>4.0.0</modelVersion>
> >    <parent>
> >        <groupId>com.ibm.websphere.fabric</groupId>
> >        <artifactId>fabric-engine-parent</artifactId>
> >        <version>9.0</version>
> >    </parent>
> >
> >    <groupId>com.ibm.websphere.fabric</groupId>
> >    <artifactId>com.ibm.ws.fabric.extension</artifactId>
> >    <packaging>bundle</packaging>
> >    <version>9.0</version>
> >    <name>Fabric extensions to be used by 3rd party code</name>
> >    <description>
> >      This bundle provides the Fabric extensions to WPS that are used by
> > 3rd party and/or customer code.
> >    </description>
> >    <dependencies>
> >      <dependency>
> >        <groupId>com.ibm.websphere.fabric</groupId>
> >        <artifactId>fabric-engine-api</artifactId>
> >        <version>9.0</version>
> >      </dependency>
> >      <dependency>
> >        <groupId>com.ibm.websphere.fabric</groupId>
> >        <artifactId>fabric-types</artifactId>
> >        <version>9.0</version>
> >      </dependency>
> >      <dependency>
> >        <groupId>com.ibm.websphere.fabric</groupId>
> >        <artifactId>fabric-da-model</artifactId>
> >        <version>9.0</version>
> >      </dependency>
> >      <dependency>
> >        <groupId>com.ibm.websphere.fabric</groupId>
> >        <artifactId>fabric-da-sca</artifactId>
> >        <version>9.0</version>
> >      </dependency>
> >      <dependency>
> >        <groupId>com.ibm.websphere.fabric</groupId>
> >        <artifactId>com.ibm.ws.fabric.da.scdl</artifactId>
> >        <version>9.0</version>
> >      </dependency>
> >        <dependency>
> >            <groupId>eclipse</groupId>
> >            <artifactId>eclipse-deps</artifactId>
> >            <type>pom</type>
> >            <version>1.3</version>
> >            <scope>provided</scope>
> >        </dependency>
>
>
> when you say the dependencies aren't being embedded, do you mean the ones
> directly listed in this pom or the ones pulled in from the "eclipse-deps"
> artifact?
>
> if you mean the ones from "eclipse-deps" then this is probably because of
> two
> reasons - 1) you haven't enabled <Embed-Transitive>true<Embed-Transitive>
> which is required to embed dependencies of dependencies - and 2) the scope
> of the pom dependency is "provided", which means that Maven will ignore its
> dependencies when calculating the transitive graph, see:
>
>  http://www.sonatype.com/book/reference/pom-relationships.html#d0e10431
>
> to include the "eclipse-deps" dependencies in the transitive graph you
> should
> just remove the <scope> from that entry, so it defaults to the compile
> scope.
>
>
> >        <dependency>
> >            <groupId>junit</groupId>
> >            <artifactId>junit</artifactId>
> >            <scope>test</scope>
> >        </dependency>
> >    </dependencies>
> >    <build>
> >      <plugins>
> >        <plugin>
> >          <groupId>org.apache.felix</groupId>
> >          <artifactId>maven-bundle-plugin</artifactId>
> >          <version>1.4.3</version>
> >          <extensions>true</extensions>
> >          <configuration>
> >            <instructions>
> >              <Export-Package>com.ibm.websphere.fabric.*</Export-Package>
> >              <Private-Package>com.ibm.ws.fabric.*</Private-Package>
> >              <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
> >
> >
> >
> <Bundle-Activator>com.ibm.ws.fabric.extensions.osgi.Activator</Bundle-Activator>
> >  <Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
>
>
> so this should be:
>
>
>
> <Embed-Dependency>*;scope=compile|runtime;type=!pom,inline=true</Embed-Dependency>
>  <Embed-Transitive>true</Embed-Transitive>
>
> note that I've also added a filter to exclude any 'pom' dependencies from
> being
> embedded, as otherwise the bundleplugin will try to inline them (ie. unzip
> them)
> and you'll see errors because an artifact with packaging 'pom' is just a
> text file
>
> HTH - let me know if it doesn't
>
>           </instructions>
> >          </configuration>
> >        </plugin>
> >      </plugins>
> >    </build>
> > </project>
> >
> > Jim Babka
> > S/W Engineer, Industry SOA Accelerators
> > (512)838-8180, T/L 678-8180
> > Starting November 17, my new number will be (512)286-5195, T/L 363-5195
> > [EMAIL PROTECTED]
>
>
>
>
> --
> Cheers, Stuart
>
>


-- 
Cheers, Stuart

Reply via email to