| Summary: | IProjectNature.configure() does not get called if nature is added at project creation | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Zoltan Ujhelyi <zoltan.ujhelyi> |
| Component: | Resources | Assignee: | Platform-Resources-Inbox <platform-resources-inbox> |
| Status: | RESOLVED INVALID | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 3.6 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
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. (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)? (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. |
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.