Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323371 - IProjectNature.configure() does not get called if nature is added at project creation
Summary: IProjectNature.configure() does not get called if nature is added at project ...
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.6   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Resources-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-23 05:21 EDT by Zoltan Ujhelyi CLA
Modified: 2010-08-27 14:45 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zoltan Ujhelyi CLA 2010-08-23 05:21:12 EDT
Build Identifier: 3.6.0.20100618-0524

I tried to create a custom project with a dedicated nature and builders. I created a projectdescription with a nature added, and then called an IProject.create() with this description. This solution worked, the project was assigned with the correct nature, etc.

On the other hand, the IProjectNature implementations configure() method was not called.

If the nature was added after the project creation phase using the setDescription() method, the nature was called correctly.

I would like to ask whether this behaviour is intentional or not, and if it is, then what is the reason for that.

Thanks for your help,
Zoltán Ujhelyi

PS.: Here is a code snippet, that was problemful.

IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProjectDescription description = workspace
	.newProjectDescription(projectHandle.getName());
description.setLocationURI(projectURI);
description.setNatureIds(new String[] {IncQueryNature.NATURE_ID});
IProject proj = ...; //Getting from a WizardCreateNewProjectCreationPage class
proj.create(description, new SubProgressMonitor(monitor, 1000));

Reproducible: Always

Steps to Reproduce:
1. Create a new project description with a nature definition.
2. Execute project creation.
3. See, that IProjectNature.configure() gets not called.
Comment 1 John Arthorne CLA 2010-08-23 11:02:32 EDT
Yes this is intentional. In the javadoc of IProject#create it says, "this method does not cause natures to be configured."  The reason for this, is that when a project is checked out a repository, it needs to get created in the local workspace, but at this point the nature has already been configured. So, IProject#create(IProjectDescription) is intended really for recreating a project that has previously existed in some workspace.

When configuring a nature for the first time, you need to #create the project, then #setDescription in a separate method call to cause natures to get configured.
Comment 2 Zoltan Ujhelyi CLA 2010-08-23 11:43:13 EDT
(In reply to comment #1)
Thank you for your quick response - although at first re-read I did not find the mentioned passage in the Javadoc. Is it possible to emphasize it somehow (e.g. marking the word 'not' with strong)?
Comment 3 Szymon Brandys CLA 2010-08-27 14:45:02 EDT
(In reply to comment #2)
> Is it possible to emphasize it somehow (e.g. marking the word 'not' with strong)?
Yup. It is already done.