You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by Jason van Zyl <ja...@maven.org> on 2006/06/29 17:38:31 UTC

OSGi Manifests in Maven JARs

Hi,

I took a quick look at the OSGi plugin that you guys have and I  
quickly tried to hack it up so that the standard Maven Jar plugin  
used some of the logic to add the appropriate manifest entries.

I believe the the plugin is trying to pull in all the dependencies  
and create a bundle from that, but what I would like to try first is  
doing something non-invasive and add manifest entries to standard  
JARs that are created by Maven. I think a simple first step that,  
while not ideal for OSGi, gets you something without much effort.

If you can make me something that takes a Maven project object  and  
produces a Properties object containing all the entries you would  
like inserted in the manifest I can probably get that wired in,  
propose it's inclusion as standard on the Maven list and go from  
there. So I need you a signature like the following:

Properties getManifestEntries( MavenProject project )
     throws MojoExecutionException;

I will also take a look at how we can make the JAR plugin easier to  
extend so that you can create proper OSGi bundles without having to  
completely rewrite your own plugin to make bundles.

Please cc me on any responses to the list as I'm not subscribed right  
now.

Thanks,

Jason van Zyl
jason@maven.org




Re[2]: OSGi Manifests in Maven JARs

Posted by Peter Kriens <Pe...@aQute.biz>.
Jason,
I have changed the plugin code to separate the bundle build phase from
the bundle header generation. I created a method as you requested,
however, I need some help with the MavenProject class. Maybe you can
take a look at the MavenBundlefier class and improve it.

Key issue is that I would like an option in the pom to define the
import and export manifest headers. In the current proposal I use *
for both import and export, generating headers for all imports and
exports. However, the syntax allows a number of more precise
instructions that are useful for some. The interface would be an
import and export instruction string.

Maybe you can take a look and see if you can integrate it. If you make
it optional then I could check out your code and test it more
extensively. If this works, you could make it a default because it
seems quite harmless. Please provide me with some pointer how to best
check out maven and work on it.

I have included the source in a zip. Please feel free to change the
packages. I have done the proper papework for Felix so the grants for
the software should be ok.

Thanks! Kind regards,

        Peter Kriens

-- 
Peter Kriens                              Tel +33467542167
9C, Avenue St. Drézéry                    AOL,Yahoo: pkriens
34160 Beaulieu, France                    ICQ 255570717
Skype pkriens                             Fax +1 8153772599


Re: OSGi Manifests in Maven JARs

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Friday 30 June 2006 18:12, Jason van Zyl wrote:
> So this is just a first simple step to try and help OSGi leverage  
> anything that is built with Maven.

Ahhh, cool!

That would help a lot to get rid of the "bundlization" of used libraries that 
many people are now doing.

So, the plan is essentially, if we could create a method that provides a map 
of entries to be placed into the manifest, then that could go into the 
standard Jar builder in Maven?


Cheers
Niclas

Richard, you posted a reply, without CCing JvZ.

Re: OSGi Manifests in Maven JARs

Posted by Jason van Zyl <ja...@maven.org>.
On 29 Jun 06, at 11:51 PM 29 Jun 06, Niclas Hedhman wrote:

> On Thursday 29 June 2006 23:38, Jason van Zyl wrote:
>
>> I took a quick look at the OSGi plugin that you guys have and I
>> quickly tried to hack it up so that the standard Maven Jar plugin
>> used some of the logic to add the appropriate manifest entries.
>
> Thanks for the interest. _I_ am not entirely sure what you are  
> actually trying
> to achieve and what the request really is.
>

It's not really a request, it's an offer being made after chatting  
with Richard.

> Out of all the code for the plugin, very little is duplicated work,  
> although
> there are a couple of lines.
>

You're basically doing what the JAR plugin is doing. You should be  
able to easily extend the JAR plugin to add bits and pieces to the  
resultant JAR.

> More important issue, IMHO, is the general <configuration> tag for  
> plugins,
> which can't at all be decoupled from the <plugin> declaration. Many  
> OSGi
> projects consists of a lot of bundles, and having a lot of  
> duplication of
> both the plugin declaration as well as common manifest entries  
> makes each
> bundle's pom fairly extensive, even if it doesn't really need to be.
>
> I forked[1] the Maven OSGi plugin to allow me to put these entries as
> <properties> entries in the pom instead, which made the project  
> poms very
> nimble. That change has not made it into the Felix version.
>
> What would be cool is a 'extension' mechanism for the configuration  
> section of
> a plugin. Not sure how it should look like, but where it is  
> possible to
> override configuration elements of the parent pom's plugin  
> declaration with
> additional or new values, and without deeply nested XML elements.
>

Ok, these are all things that can be done in the future. My  
suggestion as a first step is something would place information in  
standard JARs that will be useful for OSGi users. So we're talking  
zero configuration on the part of the typical user and OSGi folks get  
a non-optimal set of entries in the manifest. So in this first step  
let's take commons-logging for example: the commons-logging people  
won't know anything about OSGi but some basic OSGi manifest entries  
will be placed in the JAR in the hopes that the commons-logging JAR  
doesn't have to be repackaged for use with an OSGi environment.

So this is just a first simple step to try and help OSGi leverage  
anything that is built with Maven. Once that is done we can work on  
the configuration bits that people might use to take full advantage  
of OSGi features and there are a couple people here at ApacheCon like  
the Jetty folks who would like to try the extended features to make a  
Jetty bundle. But simple steps first :-)

Jason.

>
> Cheers
> Niclas
>
> [1] Source is available at;
>     https://scm.ops4j.org/repos/ops4j/projects/pax/maven/osgi-bundle/
>

Jason van Zyl
jason@maven.org




Re: OSGi Manifests in Maven JARs

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Thursday 29 June 2006 23:38, Jason van Zyl wrote:

> I took a quick look at the OSGi plugin that you guys have and I
> quickly tried to hack it up so that the standard Maven Jar plugin
> used some of the logic to add the appropriate manifest entries.

Thanks for the interest. _I_ am not entirely sure what you are actually trying 
to achieve and what the request really is.

Out of all the code for the plugin, very little is duplicated work, although 
there are a couple of lines.

More important issue, IMHO, is the general <configuration> tag for plugins, 
which can't at all be decoupled from the <plugin> declaration. Many OSGi 
projects consists of a lot of bundles, and having a lot of duplication of 
both the plugin declaration as well as common manifest entries makes each 
bundle's pom fairly extensive, even if it doesn't really need to be.

I forked[1] the Maven OSGi plugin to allow me to put these entries as 
<properties> entries in the pom instead, which made the project poms very 
nimble. That change has not made it into the Felix version.

What would be cool is a 'extension' mechanism for the configuration section of 
a plugin. Not sure how it should look like, but where it is possible to 
override configuration elements of the parent pom's plugin declaration with 
additional or new values, and without deeply nested XML elements.


Cheers
Niclas

[1] Source is available at;
    https://scm.ops4j.org/repos/ops4j/projects/pax/maven/osgi-bundle/

Re: OSGi Manifests in Maven JARs

Posted by "Richard S. Hall" <he...@ungoverned.org>.
I think this will be more than reasonable for initial integration. To 
convert a library JAR file to a bundle JAR file, we only need to insert 
a few manifest headers. The two most important will be:

    * "Import-Package" which is a list of all packages referenced by
      classes inside the JAR but not contained in it.
    * "Export-Package" which will be a list of all packages contained
      inside of the JAR file.

We just need to polish up how we generate these various manifest headers 
and then we should be ready to go. The end result should be completely 
non-invasive.

-> richard

Jason van Zyl wrote:
> Hi,
>
> I took a quick look at the OSGi plugin that you guys have and I 
> quickly tried to hack it up so that the standard Maven Jar plugin used 
> some of the logic to add the appropriate manifest entries.
>
> I believe the the plugin is trying to pull in all the dependencies and 
> create a bundle from that, but what I would like to try first is doing 
> something non-invasive and add manifest entries to standard JARs that 
> are created by Maven. I think a simple first step that, while not 
> ideal for OSGi, gets you something without much effort.
>
> If you can make me something that takes a Maven project object  and 
> produces a Properties object containing all the entries you would like 
> inserted in the manifest I can probably get that wired in, propose 
> it's inclusion as standard on the Maven list and go from there. So I 
> need you a signature like the following:
>
> Properties getManifestEntries( MavenProject project )
>     throws MojoExecutionException;
>
> I will also take a look at how we can make the JAR plugin easier to 
> extend so that you can create proper OSGi bundles without having to 
> completely rewrite your own plugin to make bundles.
>
> Please cc me on any responses to the list as I'm not subscribed right 
> now.
>
> Thanks,
>
> Jason van Zyl
> jason@maven.org
>
>
>
>