Tuesday, September 08, 2009

Is Eclipse deleting XML resources from my build path?

eclipse 3.4.0 ganymede FileNotFoundException xml properties build classpath filtered resources deleted excluded "class path resource cannot be resolved"

I have a project where configuration resources (mostly hibernate - hibernate.cfg.xml & *.hbm.xml) exist in the same folders as the java source and it's expected that these are copied to the build output so they can be loaded from the classpath.

It seems eclipse is "cleaning up" the XML files from the build output folder. Check the include/exclude settings on the project and Included is set to (All). Adding *.xml explicitly to the included list makes no difference.

Out of curiosity, manually copying an XML file to the build output folder and refreshing the project causes the XML to be deleted. Why?

I'm not sure if it was an update or plugin that caused this, but the problem is with the Filtered Resources setting.

In Window -> Preferences:
go to: Java > Compiler > Building
in Output folder section:
  • check the Filtered resources value
  • if *.xml is in the comma separated list, this is the cause.
    Remove from the list and allow the Project rebuild.

As mentioned, even if you explicitly add *.xml to be included in your Project settings the above global setting will cause it to be excluded.