Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367751

Summary: Aether should produce OSGi bundles
Product: z_Archived Reporter: Christian Schneider <chris>
Component: AetherAssignee: Project Inbox <aether.core-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bentmann
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 378188    
Attachments:
Description Flags
Adding maven bundle plugin to poms to create bundles
none
symbolic names and experiments with deps
none
Correct bundle ids and optional imports
none
New patch with better commit description and some optimizations for the aether connectors bentmann: iplog+

Description Christian Schneider CLA 2012-01-03 07:29:19 EST
We are curently starting to build OSGi services around aether in pax and Apache Karaf. To make aether available in OSGi it would help a lot if the aether project would already provide bundles.

I can work on that and provide a patch or pull request. I think for the most parts it is good enough to just add the maven bundle plugin to the pom.
Comment 1 Benjamin Bentmann CLA 2012-01-03 07:33:02 EST
(In reply to comment #0)
> I can work on that and provide a patch or pull request.

Thanks, please submit your work as a patch attached to this bug such that we can properly track the IP.
Comment 2 Christian Schneider CLA 2012-01-03 08:58:31 EST
Created attachment 208934 [details]
Adding maven bundle plugin to poms to create bundles

I am granting all rights for this patch to the eclipse foundation
Comment 3 Benjamin Bentmann CLA 2012-01-03 18:58:15 EST
(In reply to comment #2)
> Adding maven bundle plugin to poms to create bundles

Thanks, I will need some time to review the generated manifest, e.g. not sure whether "org.eclipse.aether.connector-wagon" is a nice bundle id or should better become "org.eclipse.aether.connector.wagon" and whether optional dependencies like Sisu/Guice are properly expressed.

At any rate, I think we need a new patch, the file you attached misses your git user/mail info which is required to properly identify you as author. "git format-patch" should be the command to produce a proper patch file.

When updating the patch, please also review the formatting, some of the indentation appeared off/inconsistent.
Comment 4 Christian Schneider CLA 2012-01-04 11:18:45 EST
Created attachment 209022 [details]
symbolic names and experiments with deps

I now changed the bundle symybolic names for the connectors so that should be all right.

I also experimented a bit with all the depdencies in aether-impl. If I just do mvn dependency:copy-dependencies I get a lot of libs. I think it is about 3 MB at least.

So I experimented a bit what the deps are used for. I was able to remove most dependencies by just removing three files:
deleted:    aether-impl/src/main/java/org/eclipse/aether/impl/AetherModule.java
deleted:    aether-impl/src/main/java/org/eclipse/aether/internal/impl/PlexusLoggerFactory.java
deleted:    aether-impl/src/test/java/org/eclipse/aether/impl/PlexusSupportTest.java

AetherModule seems to setup the dependencies using guice. 
PlexusLoggerFactory seems to setup a for plexus. As there is also a slf4j logger I wonder if this could really be deleted.
The last is a test so it was probably not even necessary to delete it.

I wonder if the guice and plexus related few classes could be moved into a separate project.

In our case in Karaf we would like to setup the deps by hand to keep the footprint small. 

Another option would be to mark these deps as optional. Is that would you meant with optional dependencies?
Comment 5 Benjamin Bentmann CLA 2012-01-04 11:29:42 EST
(In reply to comment #4)
> AetherModule seems to setup the dependencies using guice. 
> PlexusLoggerFactory seems to setup a for plexus. As there is also a slf4j
> logger I wonder if this could really be deleted.

All those classes exist for a reason (ease of integration into apps), so no, deletion is not an option here.

> I wonder if the guice and plexus related few classes could be moved into a
> separate project.

I'm opposed to moving these classes out for the following reasons:
- Modularization overkill
- Complicated use/consumption in client apps

> Another option would be to mark these deps as optional. Is that would you meant
> with optional dependencies?

Yes, I'm not fully up to speed with OSGi manifest but IIRC it has a notion of optional requirements.
Comment 6 Christian Schneider CLA 2012-01-04 11:37:52 EST
I did not really mean to just delete those files. I just removed them to see that the project compiles if I remove dependencies. I think though that at least the dependency to sisu-inject-plexus could be replaced by a dependency to just sisu-guice. That would make the dep tree a lot smaller already. I think only the logger needs more that guice.

I will try to also mark the dep to sisu-guice optional and check what impact it has on the Manifest.
Comment 7 Christian Schneider CLA 2012-01-04 12:15:13 EST
Created attachment 209026 [details]
Correct bundle ids and optional imports

This patch should work for at least aether-impl and its dependencies.

The only problematic bundle might be aether-connector-wagon. I was not sure if I could make the sisu dep optional there.

I also added a README_INSTALL_KARAF.txt that shows what to do to install the bundles in karaf. So at least I get aether-impl resolve correctly in karaf. I will check with some devs from pax-url to see if this works in pax like this.
Comment 8 Benjamin Bentmann CLA 2012-01-04 12:38:56 EST
(In reply to comment #7)
> This patch should work for at least aether-impl and its dependencies.

aether-impl has a direct dependency on javax.inject as such this entry may not be removed from the POM.

> The only problematic bundle might be aether-connector-wagon. I was not sure if
> I could make the sisu dep optional there.

Sisu/Plexus are optional there as well.

> I also added a README_INSTALL_KARAF.txt that shows what to do to install the
> bundles in karaf.

Please remove this readme from the final patch. This kind of documentation doesn't belong in Aether's source repo. A wiki/site page seems a better fit and if I was a Karaf user, I would check the Karaf documentation, not the Aether documentation, how to install bundles.
Comment 9 Christian Schneider CLA 2012-01-05 05:15:49 EST
Created attachment 209059 [details]
New patch with better commit description and some optimizations for the aether connectors

New patch with better commit description and some optimizations for the aether connectors. I am now able to install all projects in karaf with quite minimal dependencies.

Below are the commands you need for a fresh karaf 2.2.5 to install the bundles:
install -s wrap:mvn:org.codehaus.plexus/plexus-component-annotations/1.5.5
install -s mvn:org.eclipse.aether/aether-api/0.9.0-SNAPSHOT
install -s mvn:org.eclipse.aether/aether-spi/0.9.0-SNAPSHOT
install -s mvn:org.eclipse.aether/aether-util/0.9.0-SNAPSHOT
install -s mvn:org.eclipse.aether/aether-impl/0.9.0-SNAPSHOT

install -s mvn:com.ning/async-http-client/1.6.5
install -s mvn:org.eclipse.aether/aether-connector-asynchttpclient/0.9.0-SNAPSHOT
install -s mvn:org.eclipse.aether/aether-connector-file/0.9.0-SNAPSHOT
install -s wrap:mvn:org.codehaus.plexus/plexus-utils/2.1
install -s wrap:mvn:org.apache.maven.wagon/wagon-provider-api/1.0
install -s mvn:org.eclipse.aether/aether-connector-wagon/0.9.0-SNAPSHOT
Comment 10 Benjamin Bentmann CLA 2012-01-07 12:02:05 EST
(In reply to comment #9)
> New patch with better commit description and some optimizations for the aether
> connectors. I am now able to install all projects in karaf with quite minimal
> dependencies.

Thanks, AFAICT, the optional dependencies are now all properly expressed in the manifests, so applied patch in http://git.eclipse.org/c/aether/aether-core.git/commit/?id=5b3b1788ee5c66f7b962c362e717e34f8d2e6de1.
Comment 11 Benjamin Bentmann CLA 2012-01-07 12:57:37 EST
(In reply to comment #9)
> Below are the commands you need for a fresh karaf 2.2.5 to install the bundles:
> install -s wrap:mvn:org.codehaus.plexus/plexus-component-annotations/1.5.5

In a later commit, I fixed missing optional flags in the aether-connector-asynchttpclient module. I would expect that this makes the installation of plexus-component-metadata into Karaf superfluous.
Comment 12 Benjamin Bentmann CLA 2012-09-30 17:53:31 EDT
Done