Source:
<code>private IProject importProject(File projectPath) throws CoreException { File dotProject = new File(projectPath, IProjectDescription.DESCRIPTION_FILE_NAME); if (!dotProject.isFile()) { System.err.println("Expected `" + dotProject.getAbsolutePath() + "` file doesn't exist."); return null; } IProjectDescription projectDescription = ResourcesPlugin.getWorkspace() .loadProjectDescription(Path.fromOSString(dotProject.getAbsolutePath())); projectDescription.setLocation(Path.fromOSString(projectPath.getAbsolutePath())); IProject res = ResourcesPlugin.getWorkspace().getRoot().getProject(projectDescription.getName()); if (res.exists()) { if (!res.getDescription().getLocationURI().equals(projectDescription.getLocationURI())) { System.err.println("Project with same name and different location exists in workspace."); return null; } res.open(new NullProgressMonitor()); res.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); } else { res.create(projectDescription, new NullProgressMonitor()); res.open(new NullProgressMonitor()); } projectDescription = res.getDescription(); if (Arrays.stream(res.getDescription().getBuildSpec()).map(ICommand::getBuilderName) .noneMatch(ApiPlugin.BUILDER_ID::equals)) { ICommand[] builders = new ICommand[projectDescription.getBuildSpec().length + 1]; System.arraycopy(projectDescription.getBuildSpec(), 0, builders, 0, projectDescription.getBuildSpec().length); ICommand buildCommand = projectDescription.newCommand(); buildCommand.setBuilderName(ApiPlugin.BUILDER_ID); builders[builders.length - 1] = buildCommand; projectDescription.setBuildSpec(builders); res.setDescription(projectDescription, 0, new NullProgressMonitor()); } ICommand[] buildSpec = projectDescription.getBuildSpec(); List<ICommand> newBuilders = removeManifestAndSchemaBuilders(buildSpec); projectDescription.setBuildSpec( <START> newBuilders.toArray(new ICommand[newBuilders.size()])); <END> return res; }</code><technical_language>need invoke project.setDescription(projectDescription) again</technical_language>

Target:
private IProject importProject(File projectPath) throws CoreException { File dotProject = new File(projectPath, IProjectDescription.DESCRIPTION_FILE_NAME); if (!dotProject.isFile()) { System.err.println("Expected `" + dotProject.getAbsolutePath() + "` file doesn't exist."); return null; } IProjectDescription projectDescription = ResourcesPlugin.getWorkspace() .loadProjectDescription(Path.fromOSString(dotProject.getAbsolutePath())); projectDescription.setLocation(Path.fromOSString(projectPath.getAbsolutePath())); IProject res = ResourcesPlugin.getWorkspace().getRoot().getProject(projectDescription.getName()); if (res.exists()) { if (!res.getDescription().getLocationURI().equals(projectDescription.getLocationURI())) { System.err.println("Project with same name and different location exists in workspace."); return null; } res.open(new NullProgressMonitor()); res.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); } else { res.create(projectDescription, new NullProgressMonitor()); res.open(new NullProgressMonitor()); } projectDescription = res.getDescription(); if (Arrays.stream(res.getDescription().getBuildSpec()).map(ICommand::getBuilderName) .noneMatch(ApiPlugin.BUILDER_ID::equals)) { ICommand[] builders = new ICommand[projectDescription.getBuildSpec().length + 1]; System.arraycopy(projectDescription.getBuildSpec(), 0, builders, 0, projectDescription.getBuildSpec().length); ICommand buildCommand = projectDescription.newCommand(); buildCommand.setBuilderName(ApiPlugin.BUILDER_ID); builders[builders.length - 1] = buildCommand; projectDescription.setBuildSpec(builders); res.setDescription(projectDescription, 0, new NullProgressMonitor()); } ICommand[] buildSpec = projectDescription.getBuildSpec(); List<ICommand> newBuilders = removeManifestAndSchemaBuilders(buildSpec); projectDescription.setBuildSpec( newBuilders.toArray(new ICommand[newBuilders.size()])); res.setDescription(projectDescription, new NullProgressMonitor()); return res; }