2008/5/7 Matthias Küspert <[EMAIL PROTECTED]>:

> Hi folks,
> I have created a project with pax-create-project and in that project I
> created two bundles: bundle1 and bundle2.
>
> If I now use pax-import-bundle to create a dependency to bundle1 in the
> bundle2 POM, it creates a dependency entry for bundle1 with
> <scope>provided</scope>.
>
> But running 'mvn package' in the root directory now tells me that the
> artifact bundle1 cannot be found.
>

we've typically found using "mvn package" leads to problems with
multi-module builds
with Maven, so usually recommend developers use "mvn install" - that way you
know
the latest artifacts and build poms are installed in your local repository.

with your example, if you run "mvn install" in the root directory, the build
will actually pass.

this is because of a long running Maven issue wrt. multi-module builds and
packaging
types that have a different file extension compared to their packaging name
(ie. jar vs
bundle). For some reason Maven starts looking for bundle artifacts with
.bundle instead
of .jar - we've worked around this in the bundleplugin by forcing it back to
.jar on install.

Everything is fine when using an additional <type>bundle</type> in the
> dependency entry for bundle1.
>

ok, so it looks like Maven is treating installed artifacts in the local
repository (which still
have packaging type "bundle" and extension .jar) differently to the same
artifacts in the
project reactor - otherwise both "mvn package" and "mvn install" would fail.


> So, two questions to the guru(s):
>
>  1. why scope provided - shouldn't it be the default compile when the
> referenced bundle is part of the current project?
>

in Maven "provided" scope is used for dependencies that you expect to be
provided
by the container at deployment time - in OSGi this typically includes any
other bundles
including those developed in the current project (because you could swap
them with
other compatible bundles later on). The "compile" and "runtime" scopes are
typically
used for dependencies you expect to embed inside the bundle - this is very
similar to
how WAR files are packaged in Maven.

it also means you only get that bundle on your compilation classpath, not
its transitive
dependencies - this is important because otherwise you could drag in other
non-bundle
artifacts that mean your build passes, but when you deploy the bundle to
OSGi it fails.


>  2. why is the <type>bundle</type> not automatically created?
>

probably because we all use "mvn install" and so never noticed this - it's
straightforward
to add the type: the importBundle method of ImportBundleMojo.java in
maven-pax-plugin
just needs to set the dependency type to match the packaging type of the
given project.

feel free to raise this on JIRA:

   http://issues.ops4j.org/jira/browse/PAXCONSTRUCT

and if you want to commit the change yourself then go ahead and I'll review
it later on
(you automatically get commit rights when you sign up on JIRA - no need for
patches :)

in the meantime, using "mvn install" should work fine

HTH

TIA
>
> Cheers,
> Matthias
>
> _______________________________________________
> general mailing list
> [email protected]
> http://lists.ops4j.org/mailman/listinfo/general
>
>


-- 
Cheers, Stuart
_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to