Substring code completion in Eclipse JDK

As of yesterday yesterday in the Eclipse 4.6. integration build, we offer substring code completion by default in Eclipse JDK.

substring-code-completion

This brings this feature known from the IntelliJ IDE and the Eclipse Code Recommenders project to JDT users and will help to continue to enhance the Java Development Tools in Eclipse.

This feature was original developed within a Google Summer of Code project by Gábor Kövesdán with Noopur Gupta and myself as mentors. After the project finished, the JDT team polished this development quite a bit and activated it yesterday, including improve highlighting in the code proposal.

You find the latest and greatest integration build (I20160112-1800) on http://download.eclipse.org/eclipse/downloads/ if you want to try it out.

Posted in Eclipse, Lars Vogel | 5 Comments

POM-less Tycho builds for structured environments

With Tycho 0.24 POM-less Tycho builds where introduced. That approach uses convention-over-configuration to reduce the number of redundant information for setting up a Tycho build. In short, that means you don’t need to create and maintain pom.xml files for bundle, feature and test projects anymore, as the whole information can be extracted out of the already existing information in MANIFEST.MF or feature.xml.

Lars Vogel shows in his Tycho Tutorial a recommended folder structure, that is also widely used in Eclipse projects.

recommended_folder_structureThe meaning of that folder structure is:

  • bundles
    contains all plug-in projects
  • features
    contains all feature projects
  • products
  • contains all product projects
  • releng
    contains projects related to the release engineering, like

    • the project containing the parent POM
    • the aggregator project that contains the aggregator POM which defines the modules of a build and is also the starting point of a Tycho build
    • the target definition project that contains the target definition for the Tycho build
  • tests
    contains all test plug-in/fragment projects

This structure helps in organizing the project. But there is one convention for POM-less Tycho builds that is not working out-of-the-box with the given folder structure: “The parent pom for features and plugins must reside in the parent directory”. Knowing about the Maven mechanics, this convention can also be satisfied easily by introducing some POM files that simply connect to the real parent POM. I call them POM-less parent POM files. These POM-less parents need to be put into the base directories bundles, features and tests. And they do nothing else than specifying the real parent POM of the project (which is also located in a sub-directory of releng.

The following snippet shows a POM-less parent example for the bundles folder:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
    http://maven.apache.org/maven-v4_0_0.xsd"> 

    <modelVersion>4.0.0</modelVersion>

    <artifactId>org.fipro.example.bundles</artifactId>
 
    <packaging>pom</packaging>

    <parent>
        <groupId>org.fipro.example</groupId>
        <artifactId>org.fipro.example.parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../releng/org.fipro.example.parent</relativePath>
    </parent>
</project>

For the features and tests folder you simply need to modify the artifactId accordingly.

Note that you don’t need to reference the POM-less parent POM files in the modules section of the aggregator POM.

Following the best practices regarding the folder structures of a project and the conventions for POM-less Tycho builds, you will have at least 7 pom.xml files in your project.

  • parent POM
    the main build configuration
  • aggregator POM
    the collection of modules to build
  • target-definition POM
    the eclipse target definition build
  • product POM
    the eclipse product build
  • POM-less parent POM for bundles
    the connection to the real parent POM for POM-less plug-in builds
  • POM-less parent POM for features
    the connection to the real parent POM for POM-less feature builds
  • POM-less parent POM for tests
    the connection to the real parent POM for POM-less test plug-in builds

Of course there will be more if you provide a multi-product environment or if you need to customize the build of a plug-in for example.

With the necessary Maven extension descriptor for enabling the POM-less Tycho build (see POM-less Tycho builds), the folder structure will look similar to the following screenshot:

pom-less_folder_structure

I hope this blog post will help people setting up Tycho builds for their products more easily using POM-less Tycho.

 

Posted in Dirk Fauth, Eclipse | 6 Comments

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 {
		mavenCentral()
	}
	dependencies {
		classpath 'org.standardout:bnd-platform:1.2.0'
	}
}

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

repositories {
	mavenCentral()
}

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 https://github.com/SimonScholz/retrofit-osgi#make-use-of-retrofit-in-osgi

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
	bundle('com.squareup.retrofit:retrofit:2.0.0-beta2'){
		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') {
		bnd{
			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 https://github.com/square/retrofit/pull/1266. 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: https://dl.bintray.com/simon-scholz/retrofit-osgi/

For further information and a complete example please refer https://github.com/SimonScholz/retrofit-osgi

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 | Comments Off on Make Retrofit ready for usage in OSGi

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.

eclipsecontribution_book

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

Posted in Eclipse, Lars Vogel | Comments Off on Contributing to the Eclipse IDE – Second edition available as paper book and also as free download

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.

eclipseidewithtoolbars

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

eclipseideinnewfullscreenshot

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 http://www.vogella.com/company/ 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.

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.

platformui

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

pde

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.

companycontributions

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 https://dl.bintray.com/vogellacompany/saneclipse/ and enjoy Ctrl++ or Ctrl+- for changing the font size.

We hope to integrate Mickaels change into Neon.

Posted in Eclipse, Lars Vogel | Comments Off on Saneclipse now with keybindings to increase / decrease editor font size

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