I use this lib
org.eclipse.core.resourcesI'm trying to change name of project in the project file to match with the actual name of project progammaticaly. I imported a project from a SVN repo and then rename the folder that content this project with a new name, but if I refresh the workspace, the name in the project file doesn't change. Even if I tell him specifically :
IProjectDescription description = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(targetProject.replace("\\", "/") + "/.project"));
description.setName(targetProject.substring(targetProject.lastIndexOf("com."))); // here the name in description is changed
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName()); // a get project from the actual description name that match with the folder name
if (!project.exists()) {
project.create(description, monitor);
}
if (!project.isOpen()) {
project.open(monitor);
}
project.setDescription(description, monitor); // force the name in project to change
project.refreshLocal(IProject.DEPTH_INFINITE, monitor); // refresh project in case that matter
// Check change
System.out.println(project.getDescription().equals(descritpion)); // false !
System.out.println(project.getDescription().getName().equals(description.getName())); // false !
It's like nothing can change this name. The name in workspace is the new name. I also try to close and open the project again but nothing happen.
What is wrong in this code ? Any help will be appreciate.
Thanks.
I figured out how to do this :
IProjectDescription description = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(targetProject.replace("\\", "/") + "/.project"));
description.setName(targetProject.substring(targetProject.lastIndexOf("com.")));
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
if (!project.exists()) {
project.create(description, monitor);
}
if (!project.isOpen()) {
project.open(monitor);
}
project.move(description, IProject.DEPTH_ONE, monitor); // This change name
Thanks for your help.