Summary: | Dynamic classpath container contents are not being processed | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | James Leone <jleone> | ||||
Component: | Core | Assignee: | Jerome Lanneluc <jerome_lanneluc> | ||||
Status: | VERIFIED INVALID | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | david_audel, philippe_mulet | ||||
Version: | 3.3.1 | ||||||
Target Milestone: | 3.4 M6 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
James Leone
2008-02-11 20:16:51 EST
The problem comes from the fact that the JDT infrastructure is not notified that the classpath entries of the container have changed. The confusion comes from the fact that the UI always shows the latest classpath entries, but the infrastructure (for performance reasons) uses the classpath entries set by the last call to JavaCore#setClasspathContainer(...). To solve this problem, you should do as the "Plug-in Dependencies" does. I.e. register a pre-processing-resource listener with JavaCore (using addPreProcessingResourceChangedListener(..., IResourceChangeEvent.PRE_BUILD)). And when notified that the project is closed or re-opened, use JavaCore#setClasspathContainer(...) to notify the infrastructure that the container has changed. For example: public class DynamicClasspathInitializer extends ClasspathContainerInitializer implements IResourceChangeListener { { JavaCore.addPreProcessingResourceChangedListener(this, IResourceChangeEvent.PRE_BUILD); } @Override public void initialize(IPath containerPath, IJavaProject javaProject) throws CoreException { IClasspathContainer container = new DynamicClasspathContainer(javaProject); JavaCore.setClasspathContainer(containerPath, new IJavaProject[] {javaProject}, new IClasspathContainer[] {container}, null); } public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta = event.getDelta().findMember(new Path("/ProjectB")); if ((delta.getFlags() & IResourceDelta.OPEN) != 0) { try { initialize(new Path(Activator.CLASSPATH_CONTAINER_ID), JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject("ProjectA"))); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } I'm closing this bug as INVALID. Please reopen if the solution above doesn't work for you. Verified for 3.4M6. I incorporated the sample code into my plugin and it worked out great! Thanks again for clarifying my point of problems. I had a feeling I was missing a step. |