I’m trying to import a mutiproject where the root-project has the same name as one of the subprojects, except for casing.
I’ve made an example here:
You could argue that the root project could just be renamed when the project is cloned. However, this will cause some gradle tasks and scripts not to work as they assume a default layout. And developers needs to keep this in mind when cloning, which is guaranteed to break sometimes.
I actually tried that, but it still fails with the following when importing:
Synchronize Gradle builds with workspace failed due to an error configuring Eclipse.
org.eclipse.core.internal.resources.ResourceException: A resource exists with a different case: '/gradlefoo'.
A resource exists with a different case: '/gradlefoo'.
org.eclipse.buildship.core.GradlePluginsRuntimeException: org.eclipse.core.internal.resources.ResourceException: A resource exists with a different case: '/gradlefoo'.
at org.eclipse.buildship.core.workspace.internal.DefaultWorkspaceOperations.createProject(DefaultWorkspaceOperations.java:140)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.addNewEclipseProjectToWorkspace(SynchronizeGradleBuildOperation.java:265)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeNonWorkspaceProject(SynchronizeGradleBuildOperation.java:243)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:179)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleBuildWithWorkspace(SynchronizeGradleBuildOperation.java:141)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.access$000(SynchronizeGradleBuildOperation.java:106)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation$1.run(SynchronizeGradleBuildOperation.j ava:123)
[SNIP]
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: org.eclipse.core.internal.resources.ResourceException: A resource exists with a different case: '/gradlefoo'.
at org.eclipse.core.internal.resources.Resource.checkDoesNotExist(Resource.java:323)
[SNIP]
... 19 more
Even with a fresh clone and workspace the import fails.
When showing up in the wizard the structure look correct:
GradleFoo-root
Foo
Bar
FooBar
GradleFoo
But clicking finish results in a dialog box where I can choose to overwrite existing project descriptors. If I choose Yes I’ll get the "another resource exists with a different case: ‘/gradlefoo’.
Choosing Keep results in "Workspace already contains a project with name gradlefoo"
In the file system and in eclipse I can see that the GradleFoo project that is created is the subproject, so I think it somehow fails when importing the root-project, somehow the eclipse project name is not set, though the root-project name is set in settings.gradle.
I clone the project from git in command line, then go to eclipse → import → gradle. I use the wrapper and press finish.
What should I do differently?
Eclipse is
Eclipse IDE for Java Developers
Version: Neon.2 Release (4.6.2)
Build id: 20161208-0600
And Buildship:
Eclipse Buildship
Version: 1.0.21.v20161010-1640
The resulting stack trace is:
org.eclipse.buildship.core.GradlePluginsRuntimeException: org.eclipse.core.internal.resources.ResourceException: A resource exists with a different case: '/JFoenix'.
at org.eclipse.buildship.core.workspace.internal.DefaultWorkspaceOperations.createProject(DefaultWorkspaceOperations.java:140)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.addNewEclipseProjectToWorkspace(SynchronizeGradleBuildOperation.java:265)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeNonWorkspaceProject(SynchronizeGradleBuildOperation.java:248)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:179)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleBuildWithWorkspace(SynchronizeGradleBuildOperation.java:141)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.access$000(SynchronizeGradleBuildOperation.java:106)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation$1.run(SynchronizeGradleBuildOperation.java:123)
at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:724)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5521)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5478)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:120)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.synchronizeBuild(SynchronizeGradleBuildsJob.java:79)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.runToolingApiJob(SynchronizeGradleBuildsJob.java:69)
at org.eclipse.buildship.core.util.progress.ToolingApiJob$1.run(ToolingApiJob.java:73)
at org.eclipse.buildship.core.util.progress.ToolingApiInvoker.invoke(ToolingApiInvoker.java:63)
at org.eclipse.buildship.core.util.progress.ToolingApiJob.run(ToolingApiJob.java:70)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: org.eclipse.core.internal.resources.ResourceException: A resource exists with a different case: '/JFoenix'.
at org.eclipse.core.internal.resources.Resource.checkDoesNotExist(Resource.java:323)
at org.eclipse.core.internal.resources.Resource.checkDoesNotExist(Resource.java:301)
at org.eclipse.core.internal.resources.Project.assertCreateRequirements(Project.java:52)
at org.eclipse.core.internal.resources.Project.create(Project.java:263)
at org.eclipse.core.internal.resources.Project.create(Project.java:247)
at org.eclipse.buildship.core.workspace.internal.DefaultWorkspaceOperations.createProject(DefaultWorkspaceOperations.java:125)
... 19 more
I just tried again with eclipse-jee 4.6.2, buildship 2 and java 1.8. I got the following:
Synchronize Gradle projects with workspace failed due to an unsupported configuration in the
referenced Gradle build.
Project at '/.../buildship-multiproject/gradlefoo' can't be named 'GradleFoo-root' because it's
located directly under the workspace root. If such a project is renamed, Eclipse would move the
container directory. To resolve this problem, move the project out of the workspace root or
configure it to have the name 'gradlefoo'.
org.eclipse.buildship.core.UnsupportedConfigurationException:
Project at '/.../buildship-multiproject/gradlefoo' can't be named 'GradleFoo-root' because it's
located directly under the workspace root. If such a project is renamed, Eclipse would move the
container directory. To resolve this problem, move the project out of the workspace root or
configure it to have the name 'gradlefoo'.
at org.eclipse.buildship.core.workspace.internal.DefaultWorkspaceOperations.validateProjectName(DefaultWorkspaceOperations.java:190)
at org.eclipse.buildship.core.workspace.internal.ProjectNameUpdater.checkProjectName(ProjectNameUpdater.java:107)
at org.eclipse.buildship.core.workspace.internal.ProjectNameUpdater.ensureProjectNameIsFree(ProjectNameUpdater.java:71)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.addNewEclipseProjectToWorkspace(SynchronizeGradleBuildOperation.java:274)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeNonWorkspaceProject(SynchronizeGradleBuildOperation.java:258)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:182)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.access$000(SynchronizeGradleBuildOperation.java:106)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation$1.run(SynchronizeGradleBuildOperation.java:141)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2262)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeProjectsWithWorkspace(SynchronizeGradleBuildOperation.java:138)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:122)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.synchronizeBuild(SynchronizeGradleBuildsJob.java:77)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.runToolingApiJob(SynchronizeGradleBuildsJob.java:68)
at org.eclipse.buildship.core.util.progress.ToolingApiJob$1.run(ToolingApiJob.java:73)
at org.eclipse.buildship.core.util.progress.ToolingApiInvoker.invoke(ToolingApiInvoker.java:62)
at org.eclipse.buildship.core.util.progress.ToolingApiJob.run(ToolingApiJob.java:70)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
So it seems like the root project name is tied hard to the name of the folder it is checked out in.
You are physically putting your project into the Eclipse workspace folder. Eclipse forbids giving your project a different name than the folder name if it is a child of the workspace folder. That’s nothing we can fix.
The solution is also given in the error message: Don’t check your projects out under the Eclipse workspace folder, but use a different folder instead.
Yes, I kind of figured that out from the error message also, its better than the last one, and clearly a core Eclipse thing, so yes nothing you can do about it in buildship.
Separating the git checkout(s) and the Eclipse workspace works excellent!
Thanks for the solution!
Just in case anybody is wondering why we insist on renaming projects to match the Gradle model: If we didn’t do this then other declarations like project dependencies, classpath attributes or wtp component assemblies would be out of sync, leading to broken projects. We decided it was better to fail early in a clear way than late in some corner cases.