38

As an Eclipse user, I always liked the Gradle IDE. However, this plugin is now deprecated in favor of the new Buildship plugin.

After setting up a fresh Eclipse IDE with Buildship installed, I'm faced with the following error in all my Gradle projects:

missing gradle project configuration file: .settings/org.eclipse.buildship.core.prefs

There are several pages on google that deal with this issue, but all of them seem pretty outdated. There is also an entry in the bugtracker of the plugin which is set to "CLOSED FIXED". Well, apparently, it's not fixed.

Am I doing something wrong? Any ideas how to tackle this issue?

Martin Häusler
  • 6,544
  • 8
  • 39
  • 66
  • I got this error when checking out a project from version control, where `org.eclipse.buildship.core.prefs` was lacking, because the committing user doesn't even use Buildship. Question is: can `org.eclipse.buildship.core.prefs` be safely committed to version control? – Markus Pscheidt Dec 19 '17 at 10:49
  • I don't think that you *can* add these files to version control because Eclipse places them in the workspace metadata folder - which can reside in a totally different directory than your actual project. So, no. At the moment you have to re-import the project through the wizard if the problem occurs. – Martin Häusler Dec 19 '17 at 15:55
  • `org.eclipse.buildship.core.prefs` resides in the project's `.settings` folder, isn't it? – Markus Pscheidt Dec 20 '17 at 20:00
  • Ah yes you are right. I thought it was in `.metadata`. I always put `.settings` on gitignore. So maybe it could be possible to check the `org.eclipse.buildship.core.prefs` into version control. I have no idea if there are any absolute paths in there or other dependencies that might break if you check it out on another computer. I personally would advise against it. – Martin Häusler Dec 21 '17 at 08:39
  • Remove the Gradle nature of project and add Gradle nature again, it started working for me. Great @SWiggels – SUDARSHAN BHALERAO Dec 10 '21 at 10:25

7 Answers7

51

I've figured it out myself. The issue with the "missing gradle project configuration file" arises from the way the gradle project(s) are imported into Eclipse.

When importing a gradle project via the regular File -> Import -> General -> Existing Project into Workspace command, then it will not work and produce the aforementioned error.

However, if you import the very same project via File -> Import -> Gradle -> Existing Gradle Project, then you get a different import wizard, and with this wizard, it works like a charm.

I still think it's a bug because the choice of the import wizard should not matter. Still, choosing the proper wizard is a viable workaround.

Martin Häusler
  • 6,544
  • 8
  • 39
  • 66
  • 2
    Note this can be ambiguous, as there might be multiple build-system files present (Maven + Gradle, or ant + Gradle) say during a migration period. Plus these wizards are created by 3rd party authors. So what should the core framework do? Perhaps it could provide a hook so plugins can inject logic into the "generic project" wizard, letting them detect from the files if their "importer" might apply and (offer to) redirect them to a different wizard step? (But then, what if multiple plugins accept that hook?) I think this is probably a hard symptom to avoid in such an extensible platform. – Luke Usherwood Apr 11 '18 at 12:47
30

Another option is to:

  1. Move to your projects path (where gradle or gradlew is found)
  2. Unix: sh gradlew cleaneclipse Win: gradlew cleaneclipse

Requires the apply plugin: 'eclipse' in your build.gradle

  1. Refresh your Project in eclipse.
  2. After that for Unix: sh gradlew eclipse Win: gradlew eclipse

Now the gradle nature will be missing in your eclipse-project. Open the context menu of your project -> configure -> add gradle nature

Now everything should be fine again.

SWiggels
  • 2,159
  • 1
  • 21
  • 35
  • strangely enough, `/gradlew tasks` shows me that the generated task is called `cleanEclipse`. Both versions, with and without a capital E, do run without errors though. And I`m pretty sure in general gradle task names are case sensitive? Either way, it did work. – Christian W Apr 16 '18 at 15:42
  • 1
    in gradles `NamedDomainObjectCollection` they write that `equals` is used for name matching. So maybe Buildship overwrote `equals` for us to add some convenience. :-) – SWiggels Apr 17 '18 at 08:33
11

I seriously searched for the solution, but only found workarounds. Alan47's solution created the file for me, but couldn't create the project properly in my case. So I just copied the file created and imported the project again in the default way:

File -> Import -> General -> Existing Project into Workspace

and pasted the file again at the directory

./.settings

The name of the file:

org.eclipse.buildship.core.prefs

The content of the file is only:

connection.project.dir=
eclipse.preferences.version=1
Ilya Kurnosov
  • 3,180
  • 3
  • 23
  • 37
  • 2
    Saved my day. It's a pity Buildship doesn't recover from this on its own. – Ilya Kurnosov Sep 18 '19 at 11:40
  • This was the only suggestion that worked for me. Note that the `connection.project.dir` setting might be different if it is a subproject. – rghome Sep 21 '21 at 18:04
3

The easiest solution, using just the mouse

As is told here by oehme (Stefan Oehme - core dev):
https://github.com/eclipse/buildship/issues/504

"Buildship can't recreate that file as it cannot know what your root project was (Gradle supports arbitrary project layouts). You should either check the settings file in or not check in any Eclipse files at all. Checking in .project while leaving out .settings is not supported."

Or here (Stefan Oehme - core dev):
https://discuss.gradle.org/t/do-i-need-to-check-in-settings-org-eclipse-buildship-core-prefs-file/22457/2:

"This would happen if you have a checked in .project file with the buildship nature, but no checked in settings file. The choice is between checking in both or checking in neither and using the Gradle import wizard."


The easiest solution, using just the mouse is the following:

  1. Right click on the project then click Properties
  2. In the properties window go to the Project Natures and remove the Gradle Nature then click Apply and Close button
  3. Open again the same window and add Gradle Nature back, then click Apply and Close button
  4. Right Click on the project > Gradle > Refresh Gradle project

After each step: 1,2,3,4 let eclipse do its update job, do not push it quickly.

Other solution is to have the file saved somewhere and paste it again in the project or create from scratch manually, then do: Right Click on the project > Gradle > Refresh Gradle project.

Useful details:

File name: org.eclipse.buildship.core.prefs
File usual encoding: ISO_8859_1
File path: ./setting/org.eclipse.buildship.core.prefs
File content, one line: connection.project.dir = eclipse.preferences.version=1

Community
  • 1
  • 1
Marian
  • 191
  • 1
  • 4
2

maybe you can use this method. by making the file back

I accidentally deleted or lost the file in my flutter project.

then I make a new method enter the ./android folder in your flutter project. copy to your terminal for mac:

touch "org.eclipse.buildship.core.prefs"; echo "connection.project.dir=
eclipse.preferences.version=1" >> org.eclipse.buildship.core.prefs

then to your ./android/app folder in your flutter project.

touch "org.eclipse.buildship.core.prefs"; echo "connection.project.dir=..
eclipse.preferences.version=1" >> org.eclipse.buildship.core.prefs
2

Step 1

Right-click on your project name in IDE > Properties > Project Natures > Choose Gradle Project Nature on the right pane > Remove > Apply and Close

Step 2

Right-click on your project name in IDE > Configure > Add Gradle Nature

Result

Give it a few seconds for Gradle to synchronize with the IDE, and .settings file will be automatically generated in the project root.

Delete error

Delete the error in Problems view.

jumping_monkey
  • 5,941
  • 2
  • 43
  • 58
0

Maybe less of a solution but more of a workaround:

If the application works despite this error (like it was for me).

Then a possible solution would be to simply delete the error:

how to delete error

It worked for me and the error did not appear again.

Timon
  • 132
  • 2
  • 9