[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] Re: How to specify the location of project created programmatically?

Balaji wrote:

>  IWorkspace workspace = ResourcesPlugin.getWorkspace();
>  IWorkspaceRoot workspaceroot = workspace.getRoot();
>  IProject dummyproj = workspaceroot.getProject("TestPrj");
>  IProjectDescription projDesc = workspace.newProjectDescription("TestPrj");
>  try { dummyproj.create(projDesc,null); }
>  catch(CoreException e){}

> This will create the project "TestPrj"under runtime workspace / workspace
> (workspaceroot determines this) if it does not exists. The project
> description file .project is present under the TestPrj directory.

> If the project is not going to placed under default workspace root
> directory, Eclipse maintains a .location file in
> ..metadata/.plugins/org.eclipse.core.resources/.projects/TestPrj to get the
> correct location of the file. I have not tried this; but you might want to
> set the location using the project descriptor using
> projDesc.setLocation(<Path Name>) before creating the project.

> Thanks
> Balaji


Thanks for your help Balaji. I tried what you suggested and it worked! 

I was trying to create the project folder under the user specified
location, "C:\XYZ". This was the extra line reqd. to make it work.
 projDesc.setLocation(new Path("C://XYZ/TestPrj"));

Regards,
Nirmalya