Skip to main content

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

Hello,

Does anyone know if it is a bug?
We are generating some projects programmatically based on some predefined templates.

copyTemplates();

IProjectDescription pDesc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName);

pDesc.setLocation(projectLocation);

project.create(pDesc, null);

// do not open, keep closed


Then when I manually open that project, corresponding natures from .project template (e.g. org.eclipse.cdt.core.cnature, org.eclipse.cdt.core.ccnature) are not applied.


If I close this project, and then reopen again, all required natures are successfully loaded.

Why it works at second try? the action is same?



Based on debug/logs/print stack traces:


at org.eclipse.ui.internal.ide.IDEWorkbenchActivityHelper.processProjects(IDEWorkbenchActivityHelper.java:231)

                    at org.eclipse.ui.internal.ide.IDEWorkbenchActivityHelper.lambda$1(IDEWorkbenchActivityHelper.java:175)

                    at org.eclipse.ui.internal.ide.IDEWorkbenchActivityHelper$$Lambda$32/1041117256.resourceChanged(Unknown Source)

                    at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:303)

                    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)

                    at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:293)

                    at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:156)

                    at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:374)

                    at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1469)

                    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:46)

                    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)    


Workspace broadcast changes, one of listeners that is notified is anonim change listener from  IDEWorkbenchActivityHelper  .


In IDEWorkbenchActivityHelper.processProjects

String[] ids = project.getDescription().getNatureIds();

ids.lengh ==0 when it should have over 4 natures.


Those natures comes from
org.eclipse.core.internal.resources.ProjectInfo.natures

This class also has 
ProjectInfo.discardNatures()
Seems it discards natures any time project description has changed, but new value is not loaded correctly.

I am tired debugging it, going to deep into the code. Can anyone help me please?


Thank you
Lidia

Back to the top