Creating an IProject at an arbitrary location [message #156637] |
Fri, 14 November 2003 03:13  |
Eclipse User |
|
|
|
Originally posted by: nirmalya.nirmalya.net
Hi,
I want to create an IProject at an arbitrary location other than the
platform root directory, (which in my case is C:\Eclipse\workspace).
For example, lets say I want to created my project under C:\temp
Since, IProject has no way of directly setting the location, I was trying
to set it using its IProjectDescription's "setLocation" method, but I kept
getting an exception
(org.eclipse.core.internal.resources.ResourceException)
complaining about an "Invalid project description".
This is how I was trying to creeate the IProject :
//Creating the IProjectDescription
IProjectDescription projDesc =
workspace.newProjectDescription(projectName);
projDesc.setName(projData.getName());
projDesc.setNatureIds(natureIDs);
//projDesc.setLocation((new Path("C:\temp")).makeAbsolute());
//Setting the builder details
BuildCommand buildcomm = new BuildCommand();
buildcomm.setBuilderName("org.eclipse.jdt.core.javabuilder");
ICommand[] buildspecs = {buildcomm};
projDesc.setBuildSpec(buildspecs);
//Creating the IProject, "iproj"
try
{ IProject iproj = null;
iproj.create(projDesc,null);
}
catch(CoreException e){ /* do something about exception */ }
Doing it this way created my project under the platform root directory,
but if I uncomment out the "projDesc.setLocation", I get the exception
complaining about an "Invalid project description".
So could anyone please advise how I can create my project at soem other
location? (say, C:\temp)
Thanks a lot in advance.
Regards,
Nirmalya
|
|
|
Re: Creating an IProject at an arbitrary location [message #160334 is a reply to message #156637] |
Fri, 21 November 2003 16:46  |
Eclipse User |
|
|
|
Originally posted by: John_Arthorne.oti.com_
Look at the status of the thrown exception. It will be a MultiStatus
and its children will describe what is wrong. Note also that
"BuildCommand" is not an API class. Use
IProjectDescription.newCommand() instead.
--
Nirmalya Ghosh wrote:
> Hi,
>
> I want to create an IProject at an arbitrary location other than the
> platform root directory, (which in my case is C:\Eclipse\workspace).
> For example, lets say I want to created my project under C:\temp
>
> Since, IProject has no way of directly setting the location, I was trying
> to set it using its IProjectDescription's "setLocation" method, but I kept
> getting an exception
> (org.eclipse.core.internal.resources.ResourceException)
> complaining about an "Invalid project description".
>
> This is how I was trying to creeate the IProject :
>
> //Creating the IProjectDescription
> IProjectDescription projDesc =
> workspace.newProjectDescription(projectName);
> projDesc.setName(projData.getName());
> projDesc.setNatureIds(natureIDs);
> //projDesc.setLocation((new Path("C:\temp")).makeAbsolute());
>
> //Setting the builder details
> BuildCommand buildcomm = new BuildCommand();
> buildcomm.setBuilderName("org.eclipse.jdt.core.javabuilder");
> ICommand[] buildspecs = {buildcomm};
> projDesc.setBuildSpec(buildspecs);
>
> //Creating the IProject, "iproj"
> try
> { IProject iproj = null;
> iproj.create(projDesc,null);
> }
> catch(CoreException e){ /* do something about exception */ }
>
> Doing it this way created my project under the platform root directory,
> but if I uncomment out the "projDesc.setLocation", I get the exception
> complaining about an "Invalid project description".
>
> So could anyone please advise how I can create my project at soem other
> location? (say, C:\temp)
>
> Thanks a lot in advance.
>
> Regards,
> Nirmalya
>
|
|
|
Powered by
FUDForum. Page generated in 0.02503 seconds