Confusing error when renaming project

(davidmichaelkarr) #1

I had a Gradle project in my workspace that I wanted to rename. It is not associated with SCM yet. When I executed the rename (from “estimator” to “estimatorold”), I got an error dialog that said this:

    org.eclipse.buildship.core.UnsupportedConfigurationException: Project at '...\estimatorold' can't be named 'estimator' 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 'estimatorold'.
    at org.eclipse.buildship.core.workspace.internal.DefaultWorkspaceOperations.validateProjectName(
    at org.eclipse.buildship.core.workspace.internal.ProjectNameUpdater.checkProjectName(
    at org.eclipse.buildship.core.workspace.internal.ProjectNameUpdater.updateProjectName(
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeOpenWorkspaceProject(
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeWorkspaceProject(
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.access$000(
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation$
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeProjectsWithWorkspace(
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.synchronizeBuild(
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.runToolingApiJob(
    at org.eclipse.buildship.core.util.progress.ToolingApiJob$
    at org.eclipse.buildship.core.util.progress.ToolingApiInvoker.invoke(

(davidmichaelkarr) #2

So I noticed that the “settings.gradle” file was setting the root project name, and after the project rename, it still had the old name. Once I changed that name to the new name and refreshed the project, that error went away.

Ideally, I would expect a project rename would fully perform the refactoring steps required to effect that rename, including changing the setting of the root project name in the settings.gradle file. I can understand why a general solution for that could be complicated, as the file is a Groovy script, which would have to be fully parsed to determine what value to change, and the value could potentially be an expression, not just a simple value (not very likely, however). However, in the vast majority of cases, that file will be pretty simple, and the setting of that pretty simple.

Failing a proper refactoring solution, wouldn’t it be better if the error message was a little more explicit about what exactly needs to be done (referring to the project name setting in the settings.gradle file)? It also doesn’t really need to present a stacktrace (although I would expect that would go into the log).

(William Deich) #3

Open your settings.gradle file. At the bottom you should see something like “ = ‘TheNameOfYourProject’” Rename the folder that contains your project to TheNameOfYourProject and try to reload it

(Donát Csikós) #4

This would be a really nice feature indeed. But if you think about it, we’d have to implement full editor and refactoring support to resolve that. Since the Groovy support for Eclipse is in maintenance mode, we’d need to find a different solution and potentially reimplement the whole language tooling. Given that there’s a simple workaround (use an external folder for your projects) I doubt that the benefits would justify the investment. Besides, there are much more pressing issues in Buildship that our users need (task execution upon synchronization, elaborate preferences, build scan support, dependency scope support, just to name a few).