Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eclipse plugin code to create IProject in specified location

IProgressMonitor progressMonitor = new NullProgressMonitor();

IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(page1.getProjectName());

I am using this code to create a project in workspace.

Now I want to create a project in a specified location other than workspace.

Can anyone give some suggestions?

like image 664
eswar jayavarapu Avatar asked Jul 12 '26 00:07

eswar jayavarapu


1 Answers

Finally I found the code to specify the location of the project to be created. This can be done by using the setLocation() method of IProjectDescription class as follows:

IProgressMonitor progressMonitor = new NullProgressMonitor();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();


IProject project = root.getProject(page1.getProjectName());
    IWorkspace w = ResourcesPlugin.getWorkspace();
    IProjectDescription desc=w.newProjectDescription(project.getName()); 
    String projectLocation=page1.getProjectLocation();
    IPath path1=new Path(projectLocation+"/"+page1.getProjectName());
    desc.setLocation(path1); 
    project.create(desc, progressMonitor); 
    project.open(progressMonitor);
like image 77
eswar jayavarapu Avatar answered Jul 17 '26 04:07

eswar jayavarapu