Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipse-dev] Project natures are not applied after Project open

please file a bugzilla and attach all the info / data there.
Kind regards,
Andrey Loskutov

Спасение утопающих - дело рук самих утопающих
Gesendet: Dienstag, 26. November 2019 um 17:51 Uhr
Von: "Popescu, Lidia" <lidia.popescu@xxxxxxxxxxxxx>
An: "General development mailing list of the Eclipse project." <eclipse-dev@xxxxxxxxxxx>
Betreff: Re: [eclipse-dev] Project natures are not applied after Project open

Thanks Mickael, Ed for your replays,


I have attached the demo project I prepared.

With this project I am able to reproduce the problem on eclipse oxygen (March 21, 2018 ) I am using and in latest available eclipse (v. 4.13 September 18, 2019).


Steps to reproduce:

-          Import attached eclipse project

-          Update in StartupExtension.copyTemplate()   the absolute path to the template (com.demo.projecttest\\.demo-project) . I tested on Windows.

-          Run eclipse application.


Three projects will be created, based on copied .project template. And will be left closed.

-          Open first project, the natures will be applied.

I have a resource change listener that prints the logs about the natures on open action.

       NatureIds -> P/DemoProject1 [org.eclipse.cdt.core.cnature, org.eclipse.cdt.core.ccnature,…]


-          Close workbench

-          Relaunch eclipse Application, don’t clean the workspace. Open next project created in previous session. The natures will not be applied.

      NatureIds -> P/DemoProject2 []


-          Close the project DemoProject2 and reopen, This time the natures are applied. And it means that on Project properties I have C/CPP properties on my case.

NatureIds -> P/DemoProject2 [org.eclipse.cdt.core.cnature, org.eclipse.cdt.core.ccnature,…]



Thank you in advance

Kind Regards



From: eclipse-dev-bounces@xxxxxxxxxxx [mailto:eclipse-dev-bounces@xxxxxxxxxxx] On Behalf Of Ed Willink
Sent: Tuesday, November 26, 2019 11:53 AM
To: eclipse-dev@xxxxxxxxxxx
Subject: Re: [eclipse-dev] Project natures are not applied after Project open



Your problem appears close to a philosophy change that occurred only recently (? six months ago) when it was recognized that the 'deliberate' non-refresh of a project on open was not justifiable. Have you tried a recent platform?


        Ed Willink


On 25/11/2019 18:47, Popescu, Lidia wrote:

Hello eclipse developers ,


I am a question for plugin developers of ‘org.eclipse.core.resources’ & ‘org.eclipse.ui.ide’.


I am facing following problem with the projects:


We are generating some projects programmatically at eclipse start-up based on some templates, including .project , and then close projects after generation. 

Then if I open project A, it's natures are successfully applied from .project.

But if I leave closed the project B, then restart eclipse, and then open project B, the natures are not applied. I have to close and reopen the project B, and only then the natures are properly applied.


Based on the debug that I did in 'org.eclipse.core.resources' & 'org.eclipse.ui.ide' it seems to be by intention.

I found the cause of this problem and a potential fix but it implies to use restricted API. 

The question is, if there is a better way to fix this?

I am working on eclipse oxygen 4.7.3


In detail:

The projects are generated using general workflow:


IPath path = new Path(projectName);

IProject projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment());  
IPath projectLocation = Platform.getLocation().append(path);


IProjectDescription pDesc = ResourcesPlugin.getWorkspace().newProjectDescription(path.lastSegment());


projectHandle.create( pDesc , progressMonitor);

// and, by default, the project is not open after creation


If I open project now, same instance of IProjectDescription is used that I provided, that has natures, and it works as expected.

When projects are created for the first time they have the flag M_USED= false

It reaches IDEWorkbenchActivityHelper.processProjects() where natures ids array is not null, needsUpdates is true, and the natures are applied before the project is open.


But if I restart eclipse and open project B that never has been opened after creation, On open action, it also has the flag  M_USED= false

but this time, the project description instance is new and does not have required natures (ids = [empty] ; needsUpdate =false)

I close and reopen the project, now it has  M_USED= true, and goes through different stacktrace that suppose to restore the project and to reload the natures, and thanks to that, second time, all natures are applied. The  (ids = [is not empty] ; needsUpdate = true) .




Is it a bug that can be fixed, or It's an unusual case, and it is supposed that first time when project is created is has natures already, and not need to restore it ?


The only solution I found is to use restricted API, and force to set the flag  M_USED right after project creation. 


int M_USED = 0x10;
org.eclipse.core.internal.resources.ResourceInfo resinfo = ((org.eclipse.core.internal.resources.Project) projectHandle).getResourceInfo(false, true);




Thank you in advance

Kind Regards




eclipse-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
_______________________________________________ eclipse-dev mailing list eclipse-dev@xxxxxxxxxxx To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top