eclipse plugin code to create IProject in specified location

前端 未结 1 1691
半阙折子戏
半阙折子戏 2021-01-06 15:17
IProgressMonitor progressMonitor = new NullProgressMonitor();

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


        
相关标签:
1条回答
  • 2021-01-06 15:36

    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);
    
    0 讨论(0)
提交回复
热议问题