You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Will Horn <wi...@gmail.com> on 2008/09/24 19:21:27 UTC

maven-bundle-plugin embed-dependency for test scope

Hi,

I see this clear message at the top of
http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html:

NOTE: only compile, runtime and system scoped dependencies are passed to
BND. Provided and test dependencies are not included in the classpath seen
by BND.

But later on the page I see examples like this:

<!-- embed any dependencies with artifactId junit and scope test -->
<Embed-Dependency>junit;scope=test</Embed-Dependency>

>From my experience, the example doesn't work.  But I would like it to!  Is
there any way to bundle test scope dependencies?  If not, why is that
example there?

Thanks,
Will

-- 
View this message in context: http://www.nabble.com/maven-bundle-plugin-embed-dependency-for-test-scope-tp19653799p19653799.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


Re: maven-bundle-plugin embed-dependency for test scope

Posted by Will Horn <wi...@gmail.com>.

Stuart McCulloch wrote:
> 
> yes it's a mistake in the doc, it should be runtime
> 
> ( although if you don't use Embed-Transitive then you can embed direct
>   test scope dependencies, ie. ones declared directly in the current pom,
>   because the Maven API to get direct dependencies doesn't filter out the
>   test scope - whereas the API to get transitive dependencies does... )
> 

This is good to know.  So in fact the junit example I mentioned will work if
junit is a direct dependency AND you have no Embed-Transitive.


Stuart McCulloch wrote:
> 
> as mentioned above, we might support bundling test dependencies in the
> future - but I have to ask why you want to bundle your test dependencies?
> 
> test dependencies are additional artifacts needed to run testcases, they
> should not be required by the actual bundle content - if they are required
> then I would have thought you'd use compile/provided scope...
> 

I'm using maven and your bundle-plugin to manage third party dependencies
for an Eclipse RCP project that is a part of a larger maven-managed project. 
The bundle-plugin is not being used to package my code, but solely for its
"Embed-Dependency" functionality to prepare a bundle wrapping the necessary
third party libraries for the Eclipse development environment.

This works great for the compile and runtime dependencies, and I would like
to create another bundle with the test scope dependencies (to be used at
test-runtime by the Eclipse tests).

I hope that is not outside the intended use!

Thanks,
Will

-- 
View this message in context: http://www.nabble.com/maven-bundle-plugin-embed-dependency-for-test-scope-tp19653799p19672872.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


Re: maven-bundle-plugin embed-dependency for test scope

Posted by Stuart McCulloch <mc...@gmail.com>.
2008/9/25 Will Horn <wi...@gmail.com>

>
> Hi,
>
> I see this clear message at the top of
> http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html:
>
> NOTE: only compile, runtime and system scoped dependencies are passed to
> BND. Provided and test dependencies are not included in the classpath seen
> by BND.
>

yes - that's the current behaviour (related to Maven resolution rules when
processing transitive dependencies), although I am considering changing
it for the next major release of the bundleplugin, as imho it is a bit
limiting

the reason I haven't changed it yet is because this has been the behaviour
since before I joined the project and I didn't want to break projects that
had
relied on this (at least not during a minor release)

however, the next release of the bundleplugin will use the latest version of
Bnd (which is Java 5+ only) and so I'm thinking of making this change at
the same time, along with some other major usability improvements


> But later on the page I see examples like this:
>
> <!-- embed any dependencies with artifactId junit and scope test -->
> <Embed-Dependency>junit;scope=test</Embed-Dependency>
>
> From my experience, the example doesn't work.  But I would like it to!  Is
> there any way to bundle test scope dependencies?  If not, why is that
> example there?
>

yes it's a mistake in the doc, it should be runtime

( although if you don't use Embed-Transitive then you can embed direct
  test scope dependencies, ie. ones declared directly in the current pom,
  because the Maven API to get direct dependencies doesn't filter out the
  test scope - whereas the API to get transitive dependencies does... )

as mentioned above, we might support bundling test dependencies in the
future - but I have to ask why you want to bundle your test dependencies?

test dependencies are additional artifacts needed to run testcases, they
should not be required by the actual bundle content - if they are required
then I would have thought you'd use compile/provided scope...

Thanks,
> Will
>
> --
> View this message in context:
> http://www.nabble.com/maven-bundle-plugin-embed-dependency-for-test-scope-tp19653799p19653799.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

Re: maven-bundle-plugin embed-dependency for test scope

Posted by Stuart McCulloch <mc...@gmail.com>.
2009/4/23 Steve Schwartz <sc...@alum.mit.edu>

>
> Is it possible for "provided" dependencies to be passed as well?
>

the 2.0.0 bundleplugin can now embed provided dependencies
(basically it can see anything that the Maven resolver can see)


> I am creating an OSGi bundle, based on an existing jar from a separate
> Maven
> project.  The bundle will wrap the jar, instantiating selected classes as
> Spring beans.  The jar is traditionally deployed in a web container, with
> some of its dependencies provided in a separate directory.  I want to have
> all of its dependencies (compile | provided | runtime) embedded in the
> bundle.
>
> As a workaround, I've copied the jar's scope-provided dependencies into the
> bundle's pom.xml.  It denormalizes things a little.  Is there a way to make
> BND see "provided" transitive dependencies?
>

transitive provided dependencies are a bit tricky because the Maven resolver
doesn't consider provided dependencies as transitive - we'd have to use our
own resolution process, which might not pick the same versions in the case
of a dependency conflict... you might also end up pulling in much more than
you bargained for (especially if you wanted optional dependencies too)

this would basically create a "mega-bundle" which would work in OSGi but
wouldn't be very modular - far better to process each major dependency as
a separate bundle then compose them together in the final application

FYI, I have some tools that can process the dependency graph and create
Maven poms to turn them into bundles:

   http://www.ops4j.org/projects/pax/construct/

you can use 'pax-wrap' to turn each dependency into a separate project:

   pax-create-project -g examples -a hibernate -v 3.1
   cd hibernate
   pax-wrap-jar -g org.hibernate -a hibernate -v 3.1 -- -DwrapTransitive

It's not perfect, as you may need to tweak the generated poms when
there's a cycle in the graph (which happens with hibernate) or there's
an artifact that you have to download from Sun, like certain specs,
but you might find it useful.

Craig Walls has a good intro to these tools:

  http://www.jroller.com/habuma/entry/pax_construct_from_zero_to

HTH

--Steve
>
> Will Horn wrote:
> >
> > Hi,
> >
> > I see this clear message at the top of
> > http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html:
> >
> > NOTE: only compile, runtime and system scoped dependencies are passed to
> > BND. Provided and test dependencies are not included in the classpath
> seen
> > by BND.
> >
> > [It actually discusses test scoped dependencies, not provided.]
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/maven-bundle-plugin-embed-dependency-for-test-scope-tp19653799p23175780.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

Re: maven-bundle-plugin embed-dependency for test scope

Posted by Steve Schwartz <sc...@alum.mit.edu>.
Is it possible for "provided" dependencies to be passed as well?

I am creating an OSGi bundle, based on an existing jar from a separate Maven
project.  The bundle will wrap the jar, instantiating selected classes as
Spring beans.  The jar is traditionally deployed in a web container, with
some of its dependencies provided in a separate directory.  I want to have
all of its dependencies (compile | provided | runtime) embedded in the
bundle.  

As a workaround, I've copied the jar's scope-provided dependencies into the
bundle's pom.xml.  It denormalizes things a little.  Is there a way to make
BND see "provided" transitive dependencies?

--Steve



Will Horn wrote:
> 
> Hi,
> 
> I see this clear message at the top of
> http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html:
> 
> NOTE: only compile, runtime and system scoped dependencies are passed to
> BND. Provided and test dependencies are not included in the classpath seen
> by BND.
> 
> [It actually discusses test scoped dependencies, not provided.]
> 
> 

-- 
View this message in context: http://www.nabble.com/maven-bundle-plugin-embed-dependency-for-test-scope-tp19653799p23175780.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