You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Peter Donald <pe...@realityforge.org> on 2010/03/16 01:38:41 UTC

Building OSGi bundles with Buildr and Bnd

Hi,

I am investigating Buildr to build OSGi bundles using Bnd. Has anyone
done this before or know of any example build files that I could have
a look at?

If no one has done it I guess the best approach is to create a plugin?
In practical terms OSGi bundles are just jars with extra metadata in a
manifest. Bnd is a java tool that jars up resources and adds
appropriate metadata based on some directives in a supplied manifest
file.

My current plan is to support something like

package(:bundle).tap do |p|
  p.directive("Export-Package", "#{id}.*;version=#{version}")
  ...
end

Which I believe means I need to define a method such as follows on the
project via an extension.

def package_as_bundle(file_name)
    ... insert magic here ...
end

Does this sound reasonable?

-- 
Cheers,

Peter Donald

Re: Building OSGi bundles with Buildr and Bnd

Posted by Peter Donald <pe...@realityforge.org>.
> Unfortunately, your attachment disappeared. You can use a gist or open a
> github repository and point us to it.

Ok - it must have been swallowed by the mailing list manager. I added
the extension and a few examples into github [1]

[1] http://github.com/rockninja/buildr-bnd/

-- 
Cheers,

Peter Donald

Re: Building OSGi bundles with Buildr and Bnd

Posted by Antoine Toulme <an...@lunar-ocean.com>.
Extensions may live on github and can be listed on the wiki.

Unfortunately, your attachment disappeared. You can use a gist or open a
github repository and point us to it.

Antoine

On Fri, Mar 19, 2010 at 16:33, Peter Donald <pe...@realityforge.org> wrote:

> On Tue, Mar 16, 2010 at 11:46 AM, Antoine Toulme
> <an...@lunar-ocean.com> wrote:
> > We don't do bnd but I implemented a plugin to do OSGi. We enforce
> > dependencies from the manifest to the Buildfile rather than the contrary.
> > It's named buildr4osgi.
>
> That looks neat. I am just new to OSGi so I am just getting my feet
> wet and I like the ease with which bnd creates the jars. So I plan to
> stick with that for now.
>
> On Tue, Mar 16, 2010 at 11:55 AM, Rhett Sutphin
> <rh...@detailedbalance.net> wrote:
> > I use bnd with buildr in this project:
> >
> > https://ncisvn.nci.nih.gov/svn/psc/trunk/
> >
> > Take a look at the buildfile and tasks/bnd.rake
> >
> > I do not use a custom package type, though if I were doing it again now I
> would.
>
> That was a great example thanks. I finally got back to look at this
> and ended up customizing your extension so it worked the same way as
> my brain does ;) I basically made a :bundle package type and had bnd
> create the jar rather than replacing one created by jar. An example of
> using the extension is
>
>  desc 'Bundle of jms utility classes'
>  define 'link', :layout => CentralLayout.new('link') do
>    bnd['Export-Package'] =
> "#{group}.#{leaf_project_name}.*;version=#{version}"
>
>    package :bundle
>    compile.with JMS
>  end
>
> I have attached a version of the extension so that you can see what I
> have done. I plan on continuing to refactor the way properties are
> handled so that it easier to share sets of properties between
> projects. Any thoughts?
>
> Also is it a good idea to submit this extension to the project? Or is
> there another place where tasks like this should live?
>
> --
> Cheers,
>
> Peter Donald
>

Re: Building OSGi bundles with Buildr and Bnd

Posted by Peter Donald <pe...@realityforge.org>.
On Tue, Mar 16, 2010 at 11:46 AM, Antoine Toulme
<an...@lunar-ocean.com> wrote:
> We don't do bnd but I implemented a plugin to do OSGi. We enforce
> dependencies from the manifest to the Buildfile rather than the contrary.
> It's named buildr4osgi.

That looks neat. I am just new to OSGi so I am just getting my feet
wet and I like the ease with which bnd creates the jars. So I plan to
stick with that for now.

On Tue, Mar 16, 2010 at 11:55 AM, Rhett Sutphin
<rh...@detailedbalance.net> wrote:
> I use bnd with buildr in this project:
>
> https://ncisvn.nci.nih.gov/svn/psc/trunk/
>
> Take a look at the buildfile and tasks/bnd.rake
>
> I do not use a custom package type, though if I were doing it again now I would.

That was a great example thanks. I finally got back to look at this
and ended up customizing your extension so it worked the same way as
my brain does ;) I basically made a :bundle package type and had bnd
create the jar rather than replacing one created by jar. An example of
using the extension is

 desc 'Bundle of jms utility classes'
  define 'link', :layout => CentralLayout.new('link') do
    bnd['Export-Package'] = "#{group}.#{leaf_project_name}.*;version=#{version}"

    package :bundle
    compile.with JMS
  end

I have attached a version of the extension so that you can see what I
have done. I plan on continuing to refactor the way properties are
handled so that it easier to share sets of properties between
projects. Any thoughts?

Also is it a good idea to submit this extension to the project? Or is
there another place where tasks like this should live?

-- 
Cheers,

Peter Donald

Re: Building OSGi bundles with Buildr and Bnd

Posted by Rhett Sutphin <rh...@detailedbalance.net>.
Hi Peter,

On Mar 15, 2010, at 7:38 PM, Peter Donald wrote:

> Hi,
> 
> I am investigating Buildr to build OSGi bundles using Bnd. Has anyone
> done this before or know of any example build files that I could have
> a look at?

I use bnd with buildr in this project:

https://ncisvn.nci.nih.gov/svn/psc/trunk/

Take a look at the buildfile and tasks/bnd.rake

I do not use a custom package type, though if I were doing it again now I would.

Rhett

> 
> If no one has done it I guess the best approach is to create a plugin?
> In practical terms OSGi bundles are just jars with extra metadata in a
> manifest. Bnd is a java tool that jars up resources and adds
> appropriate metadata based on some directives in a supplied manifest
> file.
> 
> My current plan is to support something like
> 
> package(:bundle).tap do |p|
>  p.directive("Export-Package", "#{id}.*;version=#{version}")
>  ...
> end
> 
> Which I believe means I need to define a method such as follows on the
> project via an extension.
> 
> def package_as_bundle(file_name)
>    ... insert magic here ...
> end
> 
> Does this sound reasonable?
> 
> -- 
> Cheers,
> 
> Peter Donald


Re: Building OSGi bundles with Buildr and Bnd

Posted by Antoine Toulme <an...@lunar-ocean.com>.
We don't do bnd but I implemented a plugin to do OSGi. We enforce
dependencies from the manifest to the Buildfile rather than the contrary.
It's named buildr4osgi.

Yes, a plugin is needed to make it happen.

Thanks,

Antoine

On Mon, Mar 15, 2010 at 17:38, Peter Donald <pe...@realityforge.org> wrote:

> Hi,
>
> I am investigating Buildr to build OSGi bundles using Bnd. Has anyone
> done this before or know of any example build files that I could have
> a look at?
>
> If no one has done it I guess the best approach is to create a plugin?
> In practical terms OSGi bundles are just jars with extra metadata in a
> manifest. Bnd is a java tool that jars up resources and adds
> appropriate metadata based on some directives in a supplied manifest
> file.
>
> My current plan is to support something like
>
> package(:bundle).tap do |p|
>  p.directive("Export-Package", "#{id}.*;version=#{version}")
>  ...
> end
>
> Which I believe means I need to define a method such as follows on the
> project via an extension.
>
> def package_as_bundle(file_name)
>    ... insert magic here ...
> end
>
> Does this sound reasonable?
>
> --
> Cheers,
>
> Peter Donald
>