Using bndtools for Eclipse plugin development

692 views
Skip to first unread message

Martin Ellis

unread,
Nov 3, 2010, 2:36:47 PM11/3/10
to bndtool...@googlegroups.com
Hi,

I'm wondering whether bndtools would be a more appropriate build
system for Eclipse plugins for us compared to Tycho. Problem is: I'm
not sure how to go about using it for Eclipse plugins...

As far as I can tell, bndtools is itself built with bndtools, so I've
been trying to use that as an example. I've checked out bndtools from
its GitHub repository, and used "Import Existing project" in Eclipse
to import the checkout into my workspace. I've also discovered the
'build' and 'p2' Ant targets, which seem to build everything.

So far, so good. But I can't figure out how to run Eclipse with the
bndtools in my workspace. Obviously, I could run a full build and
install the result into an Eclipse, but that's not a practical way to
do plugin development.

Are there any instruction on this? Specifically, I can't work out:
* Should I try to run using OSGI Run, or using the usual "Eclipse Application"?
* If the former, which .bnd file should I try to Run?
* If the latter, how do I get Eclipse to recognise each project as a bundle?

I'm also puzzled by the cnf project.
* Is there supposed to be one per workspace?
* Does it have to be called cnf?
* Can I have my own project in the same workspace as bndtools itself?

I found "Launching Eclipse Applications" on the bndtools wiki, but it
didn't really answer my questions.

Thanks
Martin

Neil Bartlett

unread,
Nov 3, 2010, 5:31:43 PM11/3/10
to bndtool...@googlegroups.com, mar...@ellis.name
Hi Martin,

Many thanks for your email and for trying bndtools!

Yes bndtools can be used for Eclipse plug-ins and RCP applications,
with one big caveat. Currently there is no support for editing
plugin.xml, i.e. extensions and extension points. You have to use a
plain XML editor and keep referring back to documentation, which is
very painful compared to PDE's rich editing support. I hope I can
improve this in the future, perhaps by forking PDE's editor and making
it work in the context of a bndtools project. But then again the
extension registry is becoming less important in Eclipse, for example
Eclipse 4.0 has decreased its reliance on extensions significantly, so
I may not bother.

To run an OSGi framework from bndtools you use the "OSGi Run" launch
type, usually by selecting a .bndrun file. Because running Eclipse
requires various platform-specific bundles, there are separate .bndrun
files for each platform: look for the bndtools.<platform>.bndrun
files. You'll notice however that these each includes
bndtools.shared.bndrun, which lists all of the cross-platform bundles
and other common settings.

The "Eclipse Application" launch type comes from PDE. Please ignore it
when using bndtools.

The cnf project is a configuration project for the bnd workspace. It
contains things like shared settings for bnd, and the local repository
of bundles that are available for building and running. The reason for
putting this stuff in a project is so that it can be shared across a
team using version control. Unfortunately it cannot currently be
renamed, it must be called cnf. If you want that to change, please
raise a bug report against bnd ;-)

Finally, yes you certainly can create other projects in the same
workspace as bndtools.

I hope this helps.

Regards,
Neil

Christopher Brind

unread,
Nov 3, 2010, 5:50:54 PM11/3/10
to bndtool...@googlegroups.com, mar...@ellis.name
Hi Neil,

I always thought that Eclipse would default to the Plug-in Manifest Editor regardless of whether it was a PDE project or not.  I just tested that theory by creating a plugin.xml file in an Android project and as I expected when I double clicked the file up popped Plug-in Manifest Editor.  

Is there some other reason why you would have to use a regular XML editor?

Cheers,
Chris

Neil Bartlett

unread,
Nov 3, 2010, 5:58:22 PM11/3/10
to bndtool...@googlegroups.com
Hi Chris,

You're right that the PDE manifest editor pops up when you open a
plugin.xml, even outside a PDE project. However, try using it for a
minute and you'll discover it's not really worth bothering with. None
of the support for extensions works, because the editor can't see any
of the available extension points or their schemas.

Still, at least it doesn't throw NPEs any more, which is what it used
to do in this scenario...

Regards.

Christopher Brind

unread,
Nov 3, 2010, 6:23:13 PM11/3/10
to bndtool...@googlegroups.com
Ah, well that's useless then. :)

Martin Ellis

unread,
Nov 3, 2010, 9:00:54 PM11/3/10
to bndtool...@googlegroups.com
On 3 November 2010 21:31, Neil Bartlett <njbar...@gmail.com> wrote:
> You have to use a
> plain XML editor and keep referring back to documentation, which is
> very painful compared to PDE's rich editing support.

OK. I think we could cope with that.

> To run an OSGi framework from bndtools you use the "OSGi Run" launch
> type, usually by selecting a .bndrun file. Because running Eclipse
> requires various platform-specific bundles, there are separate .bndrun
> files for each platform: look for the bndtools.<platform>.bndrun
> files.

I couldn't get this to work. Right now, I'm using 64-bit cocoa-based
Eclipse 3.6.1 (I've checked in the 'About Eclipse SDK' dialog), but
when I try to use the "OSGI Run" context menu item on
bndtools.cocoa.macosx.x86_64.bndrun, I get a "Problem Occurred"
dialog:

'Lauching bndtools.cocoa.macosx.x86_64.bndrun' has encountered a problem.
Could not find framework org.eclipse.osgi, version 0.

I've tried this with an empty workspace, selecting the default option
when it prompts about the configuration project (which I think
actually refers to updating it). The workspace .log gives no more
info:
!ENTRY bndtools.core 4 0 2010-11-04 00:37:04.916
!MESSAGE Could not find framework org.eclipse.osgi, version 0.

Not sure if it makes a difference, but my working copy is outside my
Eclipse workspace. If I import with the "Copy projects into
workspace" checkbox set, I see the NPE exception below, as Eclipse
tries to build my workspace.

Any suggestions?

Thanks,
Martin


!SUBENTRY 1 bndtools.core 4 0 2010-11-04 00:57:34.008
!MESSAGE Error building project.
!STACK 0
java.lang.NullPointerException
at bndtools.builder.BndIncrementalBuilder.rebuildBndProject(BndIncrementalBuilder.java:234)
at bndtools.builder.BndIncrementalBuilder.build(BndIncrementalBuilder.java:77)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:203)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:255)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:258)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:311)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:343)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:242)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Neil Bartlett

unread,
Nov 3, 2010, 9:36:32 PM11/3/10
to bndtool...@googlegroups.com
The first problem means that Equinox could not be found in the
cnf/repo directory. Did you checkout the full set of projects,
including the cnf?

Currently all projects (including cnf) must be in the workspace.

Neil

Martin Ellis

unread,
Nov 4, 2010, 6:17:42 PM11/4/10
to bndtool...@googlegroups.com
On 4 November 2010 01:36, Neil Bartlett <njbar...@gmail.com> wrote:
> The first problem means that Equinox could not be found in the
> cnf/repo directory. Did you checkout the full set of projects,
> including the cnf?

I did: git clone git://github.com/njbartlett/bndtools.git
Then when I went to "Import Existing Project" I selected the top-level
directory, and made sure all the projects were imported (i.e. checked
in the dialog).

> Currently all projects (including cnf) must be in the workspace.

I tried again tonight. Took me a while to figure out that "in the
workspace" means actually in that directory, rather than just be open
as a project. I had to copy the checkout into the workspace and
import it from there.

Now I'm back to "Could not find framework org.eclipse.osgi, version 0".

Lets say I've checked out to $HOME/bndtools, how should I import into Eclipse?
And should I been aiming to have workspace/bndtools/cnf? Or workspace/cnf?

Also, is it better to try the released version, or to build master and
install that?

Martin

Martin Ellis

unread,
Nov 4, 2010, 7:53:57 PM11/4/10
to bndtool...@googlegroups.com
On 4 November 2010 22:17, Martin Ellis <mar...@ellis.name> wrote:
> I tried again tonight.  Took me a while to figure out that "in the
> workspace" means actually in that directory, rather than just be open
> as a project.  I had to copy the checkout into the workspace and
> import it from there.

Aha! Success. Here's how I got it working:

* In $HOME: git clone git://github.com/njbartlett/bndtools.git
* Create a cnf symlink in the workspace to the cnf directory in the checkout
* Build master: ant build p2
* Install master by pointing Eclipse at bndtools/cnf/p2target
* Import all the projects
* I accepted the update to the cnf repo - not sure if I needed to
* Run the bndrun file to start a new Eclipse.

Sure enough, if I change a message string in the BND file editor, the
newly started Eclipse will ask if I want to reset the perspective to
pick up changes. Nice!

I guess that means I still need a separate workspace for each 'cnf'
project, although I can't imagine wanting more than a few. Still, I'm
pleased to have it running at all for now.

Cheers
Martin

Reply all
Reply to author
Forward
0 new messages