我正在尝试复制一个项目,对复制的项目进行一些处理,并(clean&)自动构建它。我设法编写了复制项目的代码(如下所示),但仍然存在一些问题。
(i).cproject文件仍然有一些源项目的残余(示例而不是Example2) 如,
<builder buildPath="${workspace_loc:/Example}/Debug" id="cdt.managedbuild.target.gnu.builder.macosx.exe.debug.1434305598" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.macosx.exe.debug"/>
我是否需要更改项目说明中的任何内容?我错过了任何命令吗?
(ii)自动清理并构建项目
我查看了CCorePlugin和CoreModel类,但找不到任何合适的类。 知道如何以编程方式实现此目的?
public static IProject copyProject(IProject project, String newProject) throws CoreException {
try{
IProgressMonitor monitor = new NullProgressMonitor();
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IProjectDescription projectDescription = project.getDescription();
// create clone project in workspace
IProjectDescription cloneDescription = workspaceRoot.getWorkspace().newProjectDescription(newProject);
// copy project files
project.copy(cloneDescription, true, monitor);
IProject clone = workspaceRoot.getProject(newProject);
//make it a CPP project
CCorePlugin.getDefault().convertProjectToCC(clone, monitor, clone.getFullPath().toOSString());
// copy the project properties
cloneDescription.setNatureIds(projectDescription.getNatureIds());
cloneDescription.setReferencedProjects(projectDescription.getReferencedProjects());
cloneDescription.setDynamicReferences(projectDescription.getDynamicReferences());
cloneDescription.setBuildSpec(projectDescription.getBuildSpec());
cloneDescription.setReferencedProjects(projectDescription.getReferencedProjects());
clone.setDescription(cloneDescription, null);
return clone;
}
catch (CoreException e){
e.printStackTrace();
MessageUtility.writeToConsole("console", e.getMessage());
return null;
}
}
由于