Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Maven Integration (M2E) » [tycho] hybrid dependencies
[tycho] hybrid dependencies [message #18633] Mon, 20 October 2008 17:09 Go to next message
Will Horn is currently offline Will Horn
Messages: 265
Registered: July 2009
Senior Member
Often, Eclipse plug-ins depend on third party (or in house) libraries
that are managed/understood by maven, but they are not OSGi bundles.

The typical Eclipse practice is to wrap the jar in a bundle manually,
but this has disadvantages. For example, I'm working on a project where
we have a core java library that is used both by pure Java apps and
Eclipse RCP ones. Currently, we jar it up and wrap it in a plug-in, but
this adds excessive complexity to the development environment (changing
the core library source is not visible to the RCP app until the jar is
rebuilt and re-wrapped).

Has Tycho considered a use case where a plug-in project has both OSGi
dependencies and regular POM dependencies? Could Tycho/m2e somehow
transparently do the wrapping step?

Thanks,
Will
Re: [tycho] hybrid dependencies [message #18699 is a reply to message #18633] Tue, 21 October 2008 17:42 Go to previous messageGo to next message
Eclipse User
Originally posted by: igor.ifedorenko.com

Will Horn wrote:
> Often, Eclipse plug-ins depend on third party (or in house) libraries
> that are managed/understood by maven, but they are not OSGi bundles.
>
> The typical Eclipse practice is to wrap the jar in a bundle manually,
> but this has disadvantages. For example, I'm working on a project where
> we have a core java library that is used both by pure Java apps and
> Eclipse RCP ones. Currently, we jar it up and wrap it in a plug-in, but
> this adds excessive complexity to the development environment (changing
> the core library source is not visible to the RCP app until the jar is
> rebuilt and re-wrapped).
>
> Has Tycho considered a use case where a plug-in project has both OSGi
> dependencies and regular POM dependencies? Could Tycho/m2e somehow
> transparently do the wrapping step?
>

If your team controls the build of the core java library, I would
recommend generating OSGi metadata as part of the build. Then, you can
tell tycho to use this library as part of build target platform and it
will resolve it from maven repository (see the message with subject "Re:
[m2eclipse-user] Tycho: Eclipse plugin dependency resolution from
local repository" I just forwarded from m2e user list). We're using
maven-osgi-packaging-plugin:generate-bundle mojo in m2e build to
generate OSGi metadata. You might be able to use felix/bnd mojos too,
but I have not had much success when I tried it earlier this year (this
was one of the reasons I started to work on tycho).

I looked at the problem of transparently adding plain jars to the build
target platform some time ago too. I came to conclusion it was not
possible without extra metadata that will tell tycho how to map maven
dependencies into osgi and what packages to export. But I'll be happy to
change my mind if we can come up with an approach that works completely
transparently.

--
Regards,
Igor
Re: [tycho] hybrid dependencies [message #18722 is a reply to message #18699] Tue, 21 October 2008 20:37 Go to previous messageGo to next message
Will Horn is currently offline Will Horn
Messages: 265
Registered: July 2009
Senior Member
Igor Fedorenko wrote:
> If your team controls the build of the core java library, I would
> recommend generating OSGi metadata as part of the build. Then, you can
> tell tycho to use this library as part of build target platform and it
> will resolve it from maven repository (see the message with subject "Re:
> [m2eclipse-user] Tycho: Eclipse plugin dependency resolution from
> local repository" I just forwarded from m2e user list). We're using
> emaven-osgi-packaging-plugin:gnerate-bundle mojo in m2e build to
> generate OSGi metadata. You might be able to use felix/bnd mojos too,
> but I have not had much success when I tried it earlier this year (this
> was one of the reasons I started to work on tycho).

I have successfully used the felix maven-bundle-plugin to wrap jars in a
bundle. This works for static third party jars that can be dropped into
the target platform. However, with an in house core java library, I
would like to be able to modify the source in Eclipse and have it
understood by PDE immediately (without an extra step of generating
metadata and re-deploying to the target). Does Tycho have any mojo to
just generate the PDE files (build.properties, MANIFEST.MF, .project,
..classpath) for Eclipse without packaging and installing the bundle?

> I looked at the problem of transparently adding plain jars to the build
> target platform some time ago too. I came to conclusion it was not
> possible without extra metadata that will tell tycho how to map maven
> dependencies into osgi and what packages to export. But I'll be happy to
> change my mind if we can come up with an approach that works completely
> transparently.

My project structure boils down to this:

core - java project with many third party (non OSGi) dependencies
managed by Maven

app1 - java project depending on core, managed by Maven

app2 - RCP application, depends on core (and thus indirectly on the
third party libraries)

(This is, in fact, a simplification - there are actually more than one
"core" libraries, and more than one pure java apps using the core libraries)

As you can see, with core and app1, there are no issues. Maven takes
care of everything. With app2 in the mix, I now need OSGi bundles to
make core and all of the third party libraries available to Eclipse
plug-ins.

It seems theoretically possible to walk the dependency tree and make
bundles for all non OSGi projects. The generated bundles could export
all packages and each maven dependency could be translated into a
Require-Bundle. In addition, there would need to be some bundle naming
conventions. That being said, without any mechanism to manually
customize the MANIFEST, you can quickly run into classloading issues
that could make the tool unusable.

I am more than happy to continue the discussion and help in any way I
can. Getting Eclipse and Maven working together for both development
and packaging is a big pain point, so thanks for your great work!

-Will
Re: [tycho] hybrid dependencies [message #18769 is a reply to message #18722] Thu, 23 October 2008 03:57 Go to previous message
Eclipse User
Originally posted by: igor.ifedorenko.com

Will Horn wrote:
> Igor Fedorenko wrote:
>> If your team controls the build of the core java library, I would
>> recommend generating OSGi metadata as part of the build. Then, you can
>> tell tycho to use this library as part of build target platform and it
>> will resolve it from maven repository (see the message with subject
>> "Re: [m2eclipse-user] Tycho: Eclipse plugin dependency resolution
>> from local repository" I just forwarded from m2e user list). We're
>> using emaven-osgi-packaging-plugin:gnerate-bundle mojo in m2e build to
>> generate OSGi metadata. You might be able to use felix/bnd mojos too,
>> but I have not had much success when I tried it earlier this year
>> (this was one of the reasons I started to work on tycho).
>
> I have successfully used the felix maven-bundle-plugin to wrap jars in a
> bundle. This works for static third party jars that can be dropped into
> the target platform. However, with an in house core java library, I
> would like to be able to modify the source in Eclipse and have it
> understood by PDE immediately (without an extra step of generating
> metadata and re-deploying to the target). Does Tycho have any mojo to
> just generate the PDE files (build.properties, MANIFEST.MF, .project,
> .classpath) for Eclipse without packaging and installing the bundle?

There is generate-bundle mojo in
org.codehaus.tycho:maven-osgi-packaging-plugin that generates
MENIFEST.MF and build.properties files without packaging. It should not
be too difficult to write m2e project configurator that would nicely
integrate this into eclipse... I can show you examples and give you some
pointers, if you're interested to implement this yourself. Or submit an
enhancement request in m2e jira [2] and I will have a look, although I
can't tell when.


>
>> I looked at the problem of transparently adding plain jars to the
>> build target platform some time ago too. I came to conclusion it was
>> not possible without extra metadata that will tell tycho how to map
>> maven dependencies into osgi and what packages to export. But I'll be
>> happy to change my mind if we can come up with an approach that works
>> completely transparently.
>
> My project structure boils down to this:
>
> core - java project with many third party (non OSGi) dependencies
> managed by Maven
>
> app1 - java project depending on core, managed by Maven
>
> app2 - RCP application, depends on core (and thus indirectly on the
> third party libraries)
>
> (This is, in fact, a simplification - there are actually more than one
> "core" libraries, and more than one pure java apps using the core
> libraries)
>
> As you can see, with core and app1, there are no issues. Maven takes
> care of everything. With app2 in the mix, I now need OSGi bundles to
> make core and all of the third party libraries available to Eclipse
> plug-ins.
>
> It seems theoretically possible to walk the dependency tree and make
> bundles for all non OSGi projects. The generated bundles could export
> all packages and each maven dependency could be translated into a
> Require-Bundle. In addition, there would need to be some bundle naming
> conventions. That being said, without any mechanism to manually
> customize the MANIFEST, you can quickly run into classloading issues
> that could make the tool unusable.

I agree that mapping maven dependencies to OSGi is not trivial and in
many cases will require explicit configuration to properly represent
developers intent. (see [1] for a brief analysis of the problem I did
earlier this year). I also think that exporting all packages will be a
problem in some cases, particularly for applications that use
Import-Package and DynamicImport-Package.

So it seems like workable solution should have three things

1. have reasonable defaults that would generate proper OSGi metadata for
"conventional" artifacts
2. allow configuration of OSGi metadata generation on the consumer side
3. provide mechanism to push generation configuration to developers
responsible for the artifact

We've been talking about implementing something like this, but no
specific plans yet.


>
> I am more than happy to continue the discussion and help in any way I
> can. Getting Eclipse and Maven working together for both development
> and packaging is a big pain point, so thanks for your great work!
>
> -Will

[1]
http://docs.codehaus.org/display/M2ECLIPSE/Mapping+Maven+dep endencies+to+OSGi
[2] http://jira.codehaus.org/browse/MNGECLIPSE
Previous Topic:stable dev build 0.9.7.200810211352 is published
Next Topic:Tycho build 0.3.0-DEV-1785
Goto Forum:
  


Current Time: Fri Oct 24 08:44:40 GMT 2014

Powered by FUDForum. Page generated in 0.02077 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software