Make Retrofit ready for usage in OSGi

Retrofit is a really great library for addressing  REST APIs. It is often used for Android apps, because it is really lightweight and easy to use.

I’d also love to use this library for my Eclipse 4 RCP applications, so let’s make use of retrofit also here.

So download the retrofit artefacts and make use of it. But wait..! For Eclipse applications we need OSGi bundles rather than usual Java artefacts. When looking at the MANIFEST.MF file of the retrofit jar archive there isn’t any OSGi bundle meta data.

Fortunately there are many tools out there to convert plain Java artefacts into OSGi bundles, e.g., p2-maven-plugin(Maven) or bnd-platform(Gradle).

Since I am involved in the Buildship development (Gradle tooling for Eclipse) and we now also offer Gradle trainings besides our Maven trainings, I chose the bnd-platform plugin for Gradle.

The build.gradle file then looks like this:

buildscript {
	repositories {
	dependencies {
		classpath 'org.standardout:bnd-platform:1.2.0'

apply plugin: 'org.standardout.bnd-platform'

repositories {

platform {
	bundle 'com.squareup.retrofit:retrofit:2.0.0-beta2'

	bundle 'com.squareup.retrofit:converter-gson:2.0.0-beta2'

When Gradle has been setup properly, the desired bundles can be converted with the bundles task from the org.standardout.bnd-platform plugin:

/retrofit-osgi-convert$ ./gradlew bundles

By running the bundles task retrofit, a json converter, in this case GSON, and the transitive dependencies are available as converted OSGi bundles in the /retrofit-osgi-convert/build/plugins folder.

See Gradle tutorial for further information.

When adding these converted bundles to the target platform of a Eclipse RCP application it should usually work out of the box.

But …! After adding the retrofit and gson converter bundles as dependencies to my plugin’s MANIFEST.MF file I still get compile errors. :-(

So what went wrong? Basically 2 things! The first problem is obvious, because when looking into the generated MANIFEST.MF meta data of retrofit there is an import for the android.os package. This import was added automatically during the conversion. The readme of the bnd-platform plugin explains how to configure the imports.

The second thing is that the retrofit and its converter bundles have split packages, which is fine for plain Java projects, but not for OSGi bundles. So the split package problem has also to be resolved. See

Fortunately this can also be configured in the build.gradle file:

platform {

	// Convert the retrofit artifact to OSGi, make android.os optional and handle the split package problems in OSGi
		bnd {
			optionalImport 'android.os'
			instruction 'Export-Package', 'retrofit;com.squareup.retrofit=split;mandatory:=com.squareup.retrofit, retrofit.http'

	// Convert the retrofit gson converter artifact to OSGi and handle the split package problems in OSGi
	bundle('com.squareup.retrofit:converter-gson:2.0.0-beta2') {
			instruction 'Require-Bundle', 'com.squareup.retrofit'
			instruction 'Export-Package', 'retrofit;com.squareup.retrofit.converter-gson=split;mandatory:=com.squareup.retrofit.converter-gson'

	// You can add other converters similar to the gson converter above...

The actual build.gradle file can be found on Github.

After resolving these problems, no compile errors are left. :-) But when running the application an java.lang.IllegalAccessError: tried to access class retrofit.Utils from class retrofit.GsonResponseBodyConverter error occured.

The cause for this are the modifiers used in the retrofit.Utils class, which itself is package private and also its closeQuietly method is package private. So even with these split package rules being applied this package private access rules prohibit the usage of the closeQuietly method from the converters bundles (gson, jackson etc.).

Now comes the part, why I love open source that much. I checked out the retrofit sources made some changes, build retrofit locally, tried my local OSGi version with my changes and finally provided a fix for this. See Thanks a lot @JakeWharton for merging my pull request that fast.

Retrofit and its GSON converter can already be obtained from bintray as p2 update site:

For further information and a complete example please refer

This repository contains the conversion script for making OSGi bundles from retrofit artifacts and  a sample application, which shows how to make use of retrofit in an Eclipse 4 RCP application. Just clone the repository in an Eclipse workspace, activate the target platform from the retrofit-osgi-target project and start the product in the de.simonscholz.retrofit.product project.

Retrofit and Eclipse 4

Retrofit and Eclipse 4

Feedback is highly appreciated.

Happy retrofitting in your OSGi applications 😉

Posted in Eclipse, Java, OSGi, Simon Scholz | Leave a comment

Contributing to the Eclipse IDE – Second edition available as paper book and also as free download

I’m happy to announce that I finished the second edition of the Contributing to the Eclipse IDE book.


To help with the contribution process, I decided to release this edition also as free download.

Posted in Eclipse, Lars Vogel | Leave a comment

Git statistics from Eclipse Platform.UI in September 2015

Last month our cleanup hero was Sopot! He delete the 2.0 compatibility layer plug-in.

Developers with the most changesets
Lars Vogel 42 (40.4%)
Markus Keller 11 (10.6%)
Simon Scholz 8 (7.7%)
Dani Megert 6 (5.8%)
Brian de Alwis 6 (5.8%)
Dirk Fauth 5 (4.8%)
Jonas Helming 5 (4.8%)
Stefan Xenos 4 (3.8%)
Sopot Cela 3 (2.9%)
Matthias Becker 3 (2.9%)
Alexander Kurtakov 3 (2.9%)
Patrik Suzzi 2 (1.9%)
Sergey Prigogin 1 (1.0%)
Andrey Loskutov 1 (1.0%)
Dariusz Stefanowicz 1 (1.0%)
Christian Radspieler 1 (1.0%)
Christian Georgi 1 (1.0%)
Daniel Haftstein 1 (1.0%)

Developers with the most changed lines
Sopot Cela 9226 (40.0%)
Lars Vogel 5510 (23.9%)
Stefan Xenos 3266 (14.1%)
Markus Keller 1728 (7.5%)
Dirk Fauth 1107 (4.8%)
Simon Scholz 861 (3.7%)
Jonas Helming 504 (2.2%)
Brian de Alwis 439 (1.9%)
Alexander Kurtakov 228 (1.0%)
Matthias Becker 139 (0.6%)
Patrik Suzzi 37 (0.2%)
Andrey Loskutov 20 (0.1%)
Dani Megert 9 (0.0%)
Sergey Prigogin 6 (0.0%)
Christian Georgi 6 (0.0%)
Daniel Haftstein 2 (0.0%)
Dariusz Stefanowicz 1 (0.0%)
Christian Radspieler 1 (0.0%)

Developers with the most lines removed
Sopot Cela 9213 (43.6%)
Lars Vogel 2244 (10.6%)
Dirk Fauth 352 (1.7%)
Markus Keller 201 (1.0%)
Simon Scholz 171 (0.8%)
Alexander Kurtakov 80 (0.4%)
Daniel Haftstein 1 (0.0%)

Posted in Eclipse, Lars Vogel | 2 Comments

Eclipse Neon and Saneclipse adding full screen mode for Eclipse

In the Eclipse Neon build from yesterday you have the option to trigger a “Full Screen mode”. We added it simultaneously to saneclipse. saneclipse is a set of plug-ins to improve the user experience of the Eclipse IDE and can be installed into Eclipse Mars.

You can use the “Toggle Visibility of all Toolbars” command (via Quick Access) to hide all currently visible toolbars. Selecting the command again, reveals these toolbars again. This allows the developer to maximize the space available for editors and views. If you minimize a stack after you selected this command, the minimized stack will be visible, until you trigger the command to hide the toolbars again. This allows the developer to decide which minimized stacks are useful for him.

The following is a screenshot of the IDE with a maximized Java editor and several toolbars visible.


The next screenshot shows the same maximized editor but with hidden toolbar.


The shortcut to trigger this is Ctrl+Alt+M on Windows or Linux and Command+Alt+M on Mac.

Please note that we do not hide the main menu, we think that would be to confusing for the user, which accidently trigger this. And this command will soon be available via the Windows menu.

Combined with the upcoming shortcuts for increasing and decreasing the font size of the current editor this should make Eclipse also easier to use for people using Eclipse for presentations.

Posted in Eclipse, Lars Vogel | 5 Comments

vogella GmbH joins the Eclipse Foundation

On behave of the I’m happy to announce that we joined the Eclipse Foundation. While our employees were already heavily involved with the Eclipse open source framework since several years, this step makes our company commitment official.

We work on almost all Eclipse Platform projects and we are happy to currently be the second strongest contributor to the Eclipse Platform.


We are also leading the Eclipse Platform UI project and it is great to see more and more new people coming in and help with the project. Still we remain very active in this project and it is great for us to see that we are currently doing more than 50 % of the commits in Platform UI.


Many of our customers are using the plug-in development tools, we are also heavily involved in them.


But of course that is not all, we believe that it is important to also help other projects to improve the Eclipse IDE experience, so we contribute to various projects. Our Eclipse vogella GmbH company page lists the projects we are involved in, here is a current snapshot.


We definitely love the Eclipse Platform and are very impressed with the skills in the Platform team, we are looking forward to work closer together with the Eclipse Foundation. We also hope to continue and intensify our efforts in improving the Eclipse IDE and Platform experience and are looking for qualified developers located in Germany, fulltime or part time (students).

Posted in Eclipse, Lars Vogel | 3 Comments

Saneclipse now with keybindings to increase / decrease editor font size

Based on the work of Mickael Istria we added shortcuts for increasing and decreasing the editor font size to Saneclipse.

Install the latest version from and enjoy Ctrl++ or Ctrl+- for changing the font size.

We hope to integrate Mickaels change into Neon.

Posted in Eclipse, Lars Vogel | Leave a comment

Welcome Tony McCrary as a new eclipse.platform.ui Committer

I would like to welcome Tony McCrary as platform.ui committer.

Tony is the amazing guy behind the new Eclipse icons which look way better on a dark background. He has drawn these svg icons and created a Maven renderer to convert them into png files. I have not counted these icons recently, but the last time I looked he created more than 1500 icons. And Tony stayed in for several years, even though he got little thanks from the projects he contributed the icons to. Certain projects which received hundreds of icons complained about errors in 1-2 icons, instead of saying thank you.

Thanks Tony, for having such a thick skin.

Tony is also a kick-ass developer and maintain his closed source SWT port based on Open GL. Scary stuff if you ask me.

Welcome Tony!

Posted in Eclipse, Lars Vogel | 1 Comment

Welcome Jonas Helming as a new eclipse.platform.ui Committer

I would like to welcome Jonas Helming as platform.ui committer.

Jonas was the driving force behind the migration of the e4 tools to platform.ui and uses his awesome Eclipse modeling and programming skills to improve the e4 tools and the platform. Jonas is also helping actively with incoming Gerrit reviews.

Welcome Jonas!

Posted in Eclipse, Lars Vogel | Tagged | Comments Off on Welcome Jonas Helming as a new eclipse.platform.ui Committer

Extracting Git statistics from Eclipse Platform.UI in August

I found the nice Git repo for the gitdm tool to do Git commit statistics. In addition the mr tool allows to extract logs from multiple repositories.

Combining both let me extract the Git statics of platform UI relatively easy. Here is the command for last August:

mr log -p -M --after="2015-8-1" --before="2015-9-1" | ../gitdm/gitdm -b ../gitdm/

Processed 68 csets from 16 developers
15 employers found
A total of 8722 lines added, 10823 removed (delta -2101)

Developers with the most changesets
Lars Vogel 25 (36.8%)
Simon Scholz 6 (8.8%)
Brian de Alwis 6 (8.8%)
Dirk Fauth 5 (7.4%)
Markus Keller 4 (5.9%)
Stefan Xenos 4 (5.9%)
Matthias Becker 3 (4.4%)
Alexander Kurtakov 3 (4.4%)
Dani Megert 3 (4.4%)
Patrik Suzzi 2 (2.9%)
Sopot Cela 2 (2.9%)
Dariusz Stefanowicz 1 (1.5%)
Christian Radspieler 1 (1.5%)
Christian Georgi 1 (1.5%)
Daniel Haftstein 1 (1.5%)
Jonas Helming 1 (1.5%)

Developers with the most changed lines
Lars Vogel 4295 (34.9%)
Stefan Xenos 3266 (26.6%)
Markus Keller 1662 (13.5%)
Dirk Fauth 1107 (9.0%)
Simon Scholz 714 (5.8%)
Brian de Alwis 439 (3.6%)
Jonas Helming 389 (3.2%)
Alexander Kurtakov 228 (1.9%)
Matthias Becker 139 (1.1%)
Patrik Suzzi 37 (0.3%)
Sopot Cela 8 (0.1%)
Christian Georgi 6 (0.0%)
Dani Megert 5 (0.0%)
Daniel Haftstein 2 (0.0%)
Dariusz Stefanowicz 1 (0.0%)
Christian Radspieler 1 (0.0%)

Developers with the most lines removed
Lars Vogel 2382 (22.0%)
Dirk Fauth 352 (3.3%)
Simon Scholz 236 (2.2%)
Markus Keller 159 (1.5%)
Alexander Kurtakov 80 (0.7%)
Daniel Haftstein 1 (0.0%)

I like these statistics, as they are much more detailed compared to Eclipse Platform UI.

Posted in Eclipse, Lars Vogel | 2 Comments

Eclipse Activator startup sins – Tracing the startup time

Inspired by the Eclipse start optimisation by Alex Blewitt post, I traced my environment and reworked our Eclipse Tracing tutorial section to enable others to do the same.

On my machine starting the Eclipse IDE (with only the SDK, XML editor and Git installed) takes 4317 ms. Looking at the “bad” guys it looks like Eclipse could start approx. 18 % faster if PDE and JDT would not activating themself. If opened Bug for JDT core and Bug for PDE.

If case you experience long startup time in your setup, I recommend to turn on the tracing option and if you see a slow starting component, to open a bug report or code correction for it. In most cases removing the activator (and moving its logic to another place which is lazy initialized) should speed up the start process.

293 org.eclipse.pde.ui_3.8.300.v20150911-1533
259 org.eclipse.pde.core_3.10.200.v20150911-1533
199 org.eclipse.jdt.core_3.12.0.v20150913-1717
132 org.eclipse.ui.trace_1.0.300.v20150911-1533
127 org.eclipse.core.runtime_3.12.0.v20150912-0621
96 org.eclipse.ltk.core.refactoring_3.7.0.v20150811-0952
88 org.eclipse.core.resources_3.11.0.v20150909-2051
68 org.eclipse.ui.workbench_3.107.100.v20150915-1646
53 org.eclipse.equinox.simpleconfigurator_1.1.100.v20150907-2149
52 org.eclipse.jdt.ui_3.12.0.v20150914-0905
46 org.eclipse.core.jobs_3.8.0.v20150911-1658
44 org.eclipse.osgi_3.10.200.v20150831-0856
41 org.eclipse.equinox.console_1.1.100.v20141023-1406
36 org.eclipse.e4.ui.model.workbench_1.1.100.v20150813-1519
34 org.eclipse.equinox.p2.ui.sdk.scheduler_1.2.100.v20150907-2149
34 org.eclipse.emf.common_2.11.0.v20150805-0624
31 org.eclipse.update.configurator_3.3.300.v20140518-1928
27 org.eclipse.jdt.launching_3.8.0.v20150819-1826
24 org.eclipse.equinox.registry_3.6.100.v20150715-1528
24 org.eclipse.equinox.ds_1.4.300.v20150423-1356
24 org.eclipse.debug.ui_3.11.100.v20150911-0904
22 org.eclipse.equinox.app_1.3.400.v20150715-1528
20 org.eclipse.core.net_1.2.300.v20141118-1725
19 org.eclipse.equinox.preferences_3.6.0.v20150809-1729
16 org.apache.felix.gogo.runtime_0.10.0.v201209301036
14 org.eclipse.emf.ecore_2.12.0.v20150805-0624
12 org.eclipse.equinox.p2.reconciler.dropins_1.1.300.v20150907-2149
12 org.eclipse.debug.core_3.10.0.v20150911-0751
7 org.eclipse.equinox.common_3.8.0.v20150911-2106
7 org.apache.felix.gogo.shell_0.10.0.v201212101605
5 org.eclipse.equinox.util_1.0.500.v20130404-1337
5 org.eclipse.equinox.p2.engine_2.4.0.v20150907-2149
5 org.eclipse.equinox.p2.core_2.4.0.v20150527-1706
5 org.eclipse.e4.ui.workbench_1.3.0.v20150821-1750
5 org.apache.felix.gogo.command_0.10.0.v201209301215
2 org.eclipse.ui.ide_3.12.0.v20150915-2041
2 org.eclipse.ui_3.107.0.v20150914-1638
2 org.eclipse.ltk.ui.refactoring_3.8.0.v20150713-1605
1 org.eclipse.ui.workbench.texteditor_3.9.200.v20150901-0449
1 org.eclipse.ui.views.log_1.0.600.v20150911-1533
1 org.eclipse.ui.monitoring_1.0.0.v20150512-1436
1 org.eclipse.ui.externaltools_3.3.0.v20150903-1021
1 org.eclipse.ui.editors_3.9.100.v20150901-0449
1 org.eclipse.pde.launching_3.6.400.v20150911-1533
1 org.eclipse.jdt.core.manipulation_1.7.0.v20150713-1605
1 org.eclipse.help_3.6.0.v20130326-1254
1 org.eclipse.equinox.security_1.2.200.v20150715-1528
1 org.eclipse.equinox.p2.metadata_2.3.0.v20150907-2149
1 org.eclipse.equinox.p2.garbagecollector_1.0.200.v20150907-2149
1 org.eclipse.equinox.p2.directorywatcher_1.1.100.v20150423-1455
1 org.eclipse.emf.ecore.xmi_2.12.0.v20150805-0624
1 org.eclipse.e4.ui.workbench.swt_0.13.0.v20150915-1214
1 org.eclipse.e4.ui.workbench.renderers.swt_0.13.0.v20150908-1041
1 org.eclipse.e4.ui.css.swt_0.12.0.v20150824-1436
1 org.eclipse.e4.core.services_2.0.0.v20150827-1906
1 org.eclipse.core.filesystem_1.6.0.v20150824-0358
1 org.eclipse.core.filebuffers_3.5.500.v20140723-1040
1 org.eclipse.core.databinding.observable_1.6.0.v20150731-2248

Posted in Eclipse, Lars Vogel | 4 Comments