views:

5914

answers:

3

I have a third-party library in my SVN repository and I'd like to associate source/javadoc with it locally in Eclipse. I.e., there should be some local setting (for example, an entry in the local.properties file) that associates the source/javadoc with the JAR file, but which doesn't introduce local dependencies into the repository via .classpath. Ideally I'd have

lib_src_dir = /my/path/to/lib/src

in local.properties and then

<classpathentry kind="lib" path="lib.jar" sourcepath="${lib_src_dir}">

in .classpath. Can this be done?

[EDIT] @VonC's answer is helpful... Is there a way to load Path Variables from a text file (e.g., local.properties) instead of going through Window -> Preferences -> General -> Workspace -> Linked Resources?

+4  A: 
VonC
This works nicely for source paths, but: (1) doc paths must be absolute, or to an archive? (2) how does one locally modify the variable?
Chris Conway
Thanks for your replies. But the .epf thing is really no better than diddling with the Preferences UI. Is there no way to set up a project so that it loads path variables automatically from a pre-defined file?
Chris Conway
nope, I am afraid you are pointing out the limit of that system: http://dev.eclipse.org/newslists/news.eclipse.newcomer/msg22823.html
VonC
A: 

You can do this with classpath variables.

Each developer creates a couple of new variables at Window -> Preferences -> Java -> Build Path -> Classpath Variables.

Define a variable (say, JAVA_LIB_DIR) that points to a directory containing the third-party JAR (or JARS). Define another variable that points to a directory containing the third-party source code (JAVA_SRC_DIR). You can set this up how you like, but we have a structure like this:

common/   
  lib/
    java/       <-- JAVA_LIB_DIR variable points to this directory
      axis/
      bitronix/
        1.0/bitronix.jar   "extension" is "bitronix/1.0/bitronix.jar"
      ...

In your project's build path, use the "Add Variable..." option to add the library. Then you when "attach source," you'll be prompted for a variable and extension to the source code.

This way, a single, shared .classpath file can be checked-in, while allowing each developer to locate their own library and source directories where they like.

erickson
+1  A: 

Take a look at Improving Linked Resources in Ganymede

Very cool. This is almost exactly what I want.
Chris Conway