Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Creating an IProject at an arbitrary location
Creating an IProject at an arbitrary location [message #156637] Fri, 14 November 2003 08:13 Go to next message
Eclipse UserFriend
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 21:46 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:Is M5 still going to be released today (EOM)?
Next Topic:Editor use in RCP
Goto Forum:
  


Current Time: Wed Jul 03 10:33:49 GMT 2024

Powered by FUDForum. Page generated in 0.02935 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top