Q:

How to attach source to a Web App Libraries in eclipse?

Is there a way to attach source to a web app library in eclipse 3.5/3.6?
What I have tried:

Till eclipse 3.3, I could attach source to jars inside the web app library, though individually.
Now attaching source to jars inside a web app library does not work.
External jars can be included, or even a jar inside the web app library can be included again and source can be attached, and it works.
Adding source paths to classpath.decorations.xml and .classpath files works for jars but not for the web app library.
even tried it this way for a library: <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container" sourcepath="<source path>"/> on the same lines of the jar, does not work, got overwritten when I restarted eclipse, sourcepath removed.

Now how do I assign sources to a web app library?
(BTW, the workaround is to include the jars externally, instead of web app library, but its tedious and the reason why the web app library is used..!)

A:

By trial and error I have found that source attachment in 3.3-3.7 can be done using the same file: classpath.decorations.xml which can be found at location: .metadata.plugins\org.eclipse.jst.common.frameworks\ . But there is a difference in how the path is to be passed for various versions of eclipse.
for 3.3, it requires the path relative to the workspace location.
for 3.5-3.7, eclipse requires the path to be absolute path, like starting with drive name..
(not sure about 3.4)
This is the same file that gets updated when sources are added from UI, but if that does not work, you can manually modify the file as well. Reopen the workspace for the changes to reflect.

