简体   繁体   中英

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:

  1. 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.

  2. 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.

  3. Adding source paths to classpath.decorations.xml and .classpath files works for jars but not for the web app library.

  4. 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..!)

The server adapter needs to provide it. Unfortunately they rarely do.

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.

The option to set java source attachment is available in the properties for an individual jar file, under the web app libraries tree in package explorer. It is there in eclipse galileo but not sure about eclipse 3.6

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM