Import gradle project into eclipse

1 minute read

I have to work with some projects that are created using gradle. And when I tried to import the project into eclipse, I had run into issues and it took me quite some time to figure it out.

First, there are several different eclipse plugins that allow you to work with Gradel. At first, I used Gradle Integration for Eclipse. But I always got a ‘null error’ in the eclipse UI and an error like this Could not fetch model of type ‘HierarchicalEclipseProject’ using Gradle distribution in the eclipse log file.

And in the log under the .metadata folder you probably could see something like the following:

	at org.eclipse.jface.operation.ModalContext$
Caused by: org.eclipse.core.runtime.CoreException: Could not fetch model of type 'HierarchicalEclipseProject' using Gradle distribution ''.
	at org.springsource.ide.eclipse.gradle.core.util.ExceptionUtil.coreException(
	... 1 more
Caused by: org.gradle.tooling.GradleConnectionException: Could not fetch model of type 'HierarchicalEclipseProject' using Gradle distribution ''.
	at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(
	at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$
	at org.springsource.ide.eclipse.gradle.core.modelmanager.GradleProjectModelManager.getModelInternal(
	... 6 more
Caused by: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':testRuntime'.
Caused by: java.lang.RuntimeException: Problems reading data from Binary store in /private/var/folders/14/c5cqz92j17z1nvz6hg3tynp40000gn/T/gradle105063885390697438.bin (exist: true)
	... 68 more
Caused by: java.lang.NullPointerException
	at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.DefaultResolutionResultBuilder.resolvedConfiguration(
	at org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory.deserialize(

I tried various suggestions I found in Google, stackoverlow. e.g.

  • Using JDK7
  • Delete the /private/var/folders/14
  • Using the gradle in my system instead of the one in the wrapper.
  • Recreate a new eclipse project, and re-import
  • Switch to a different gradle plugin Gradle Eclipse IDE by BuildShip, which is the official one suggested by Gradle.

Unfortunately, none of them work.

At last, I tried to specify the latest version for gradle using the Gradle Eclipse IDE by BuildShip plugin. And this time, it works!!! So it seems that the error I have been seeing is really related to the version of gradle. It needs the latest version to make the import work. The version used in the wrapper is not new enough. It is really frustrating to spend so much time to figure this out.

Configure the gradle version