[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-dev] Copy, clean and build automatically a C++ project
|
Hi,
I am trying to duplicate a project, do some processing on the duplicated
project and (clean &) build it automatically. I managed to write the code
for duplicating a project (given below) but there are still some issues.
(i) .cproject file still has some remnant of the source project (Example
instead of Example2)
e.g., <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"/>
Do I need to change anything in project description? Am I missing any
command?
(ii) clean and build the project automatically
I looked into the CCorePlugin and CoreModel classes but couldn't find any
suitable.
Any idea how can I achieve this programmatically?
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;
}
}
Thanks,
Simos
--
View this message in context: http://eclipse.1072660.n5.nabble.com/Copy-clean-and-build-automatically-a-C-project-tp188566.html
Sent from the Eclipse CDT - Development mailing list archive at Nabble.com.