Search code examples
javaeclipsepluginsgradlelibgdx

Null Pointer Importing Gradle Project Into Eclipse


I used libGDX to generate some gradle projects that I now need to import into Eclipse. So, I opened Eclipse, installed the gradle plugin, and went to File -> Import -> Gradle Project. At that point, I chose the directory that contained my generated gradle projects. Then, I clicked 'Build Model' and then added my projects to the list of available projects to import. After I select 'Finish' Eclipse begins importing them. Right at the very end I get this dialog:

enter image description here

Looking in the log file, I found this stack trace:

java.lang.NullPointerException
at org.springsource.ide.eclipse.gradle.core.wizards.GradleImportOperation.refreshProjects(GradleImportOperation.java:256)
at org.springsource.ide.eclipse.gradle.core.wizards.GradleImportOperation.perform(GradleImportOperation.java:195)
at org.springsource.ide.eclipse.gradle.ui.wizards.GradleImportWizard$1.doit(GradleImportWizard.java:66)
at org.springsource.ide.eclipse.gradle.core.util.GradleRunnable$1.run(GradleRunnable.java:49)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

I've tried reinstalling everything relevant. I've created the projects several times. I've downloaded a fresh version of eclipse. But, the same issue occurs everytime. Any help would be great. Thank you.


Solution

  • As it turns out, when importing a gradle project, there is a field called "Run After" which defaults to "afterEclipseImport". This doesn't exist unless it is defined in the project you are importing. The documentation says that if it doesn't exist then the gradle import project skips over it. Well, once I unchecked this option, the import worked correctly.

    Edit: Just as an aside. This assumes that your project is in a subdirectory inside your workspace as opposed to the workspace directory itself. (See the other answer).