Bug 70417 - [classpath] Allow JARs in User Libraries to be defined with relative paths to classpath variables
Summary: [classpath] Allow JARs in User Libraries to be defined with relative paths to...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 enhancement with 72 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 83208 93061 185256 (view as bug list)
Depends on:
Blocks: 572743
  Show dependency tree
 
Reported: 2004-07-20 09:03 EDT by Stanimir Stamenkov CLA
Modified: 2021-04-11 02:47 EDT (History)
35 users (show)

See Also:


Attachments
Patch for eclipse bug 70417 (15.17 KB, patch)
2011-06-07 08:42 EDT, Thomas Reinhardt CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stanimir Stamenkov CLA 2004-07-20 09:03:00 EDT
Curretnly User Libraries are defined only as containing JARs from the file
system with absolute locations. It would be nice if User Libraries could define
JARs located as extension to classpath variables and/or workspace folders.
Adding Class Folders as library elements would be nice too. A related issue
would be defining a project specific libraries.

This would improve the organization in the Package Explorer view of projects
with many JAR dependencies and would allow the sharing of that library
information. Currently one could export/import the library definitions but as
they use local file system specific paths, they are not much useful for sharing.
Comment 1 Paul Ossenbruggen CLA 2004-07-28 19:34:17 EDT
This is the single most problematic issue we have with Eclipse. In every project I have worked on we 
have had libraries that exist outside the project folder at the same level. Relative paths where you can 
specify a parent folder like ../otherproject would solve this for us. Absolute paths cause problems 
because then you can not check out to another machine without configuring. It seems the Eclipse 
runtime settings recently added the ability to have relative paths, now we need it in the build settings. 
Relative paths also would be helpful for build results output we don't always want to put our build 
results in the same folder as the project subfolder. 
Comment 2 David Pletcher CLA 2004-07-29 13:38:46 EDT
I've been thinking about this same problem for the last few days.  There's an
issue to consider when referencing libraries in other projects by project name:
 the user may have checked out the foreign library by another name (when working
on multiple branches of a project, for example.)  It's a thorny problem.

I wholeheartedly endorse the idea of project-specific libraries.  We include
about 60 jar files in one project and the cluttering of the package explorer
pain is very unpleasant.  I've resorted to creating a stub project, importing
the jar files from the original project into the stub project, then re-exporting
the entire stub project into the original project's classpath.  This approach
has the unpalatable attribute of being dependent on the absolute project name. 
A user library might serve the same purpose but it can't be propagated to other
users.

It would also be nice if libraries in the classpath were not shown at the top
level of the project explorer pane, but were instead shown inside a collapsible
Libraries folder (the same way that collections of libraries are displayed for a
user-defined library.)  I'm filing this suggestion as a separate feature
request, #71101.
Comment 3 Darren Bell CLA 2005-02-16 18:02:05 EST
It would be nice to add jars to a user library using classpath variables.

MAVEN_REPO anyone.

We use this a hell of a lot in our projects.  It would be nice to, say, create a
hibernate-2.16 user library and add the jars relative to the MAVEN_REPO variable.

This would be advisable as each of our developers has the Maven repository
stored in a diff location on disk.
Comment 4 Philipe Mulet CLA 2005-04-07 09:44:12 EDT
Deferring post 3.1
Comment 5 Olivier Thomann CLA 2006-03-24 20:56:41 EST
Reopen to close bug 133191 as a dup
Comment 6 Olivier Thomann CLA 2006-03-24 20:56:52 EST

*** This bug has been marked as a duplicate of 133191 ***
Comment 7 Olivier Thomann CLA 2006-03-24 20:57:32 EST
Reopen. 133191 is a dup of this bug.
Comment 8 Olivier Thomann CLA 2006-03-24 20:57:54 EST
*** Bug 133191 has been marked as a duplicate of this bug. ***
Comment 9 Jimisola Laursen CLA 2006-03-25 08:40:41 EST
I can see that this issue has priority P3, but even though it is not a show stopper this issue causes teams to spend a lot of (unnecessary) time on setting up projects for each team memeber (including the headaches when people don't have the right JAR files in their library path).
Comment 10 Katalin Hornyik CLA 2006-06-09 12:28:46 EDT
We have a similar problem like others. 
We have a lot of external jars, and this situation makes package exploler useless.  So, we tried to use user libraries, but it is not flexible enough. Relative path, workspace relatives, user defined classpath variables... we can't use any of them to define user libraries. So every person of us have to configure user libaries by own, or we have to use unconfortable regulations, standards.
Comment 11 Philipe Mulet CLA 2006-07-18 10:35:09 EDT
We are considering relaxing some of the classpath rules for 3.3.
This one looks like a good candidate.
Comment 12 Jerome Lanneluc CLA 2006-07-18 10:40:49 EDT
*** Bug 93061 has been marked as a duplicate of this bug. ***
Comment 13 Jerome Lanneluc CLA 2006-07-18 10:41:43 EDT
Note that bug 93061 contains a patch that we might consider.
Comment 14 Frederic Fusier CLA 2007-05-11 05:33:58 EDT
Unfortunately, we did lack time to implement this enhancement and so have to defer it...
Comment 15 Nicolas Cornaglia CLA 2007-05-24 06:29:11 EDT
Defered again? We need it!
Comment 16 Matthew Conway CLA 2007-05-24 10:59:36 EDT
I wrote a script that helps till they have this - you may be able to modify it for your needs if you can't use something like ivy or mave to accomplish the same:

http://simplygenius.com/geekblog/2006/06/05/auto-generating-eclipse-user-libraries/
Comment 17 Ian McCall CLA 2007-06-05 11:34:21 EDT
This also stops me developing using the same user libraries cross-platform. For example, on Windows...

c:\workspace\libs\ourlib.jar  might be the path

On OS X:

~/workspace/libs/ourlib.jar is probably the path.



I need to be able to checkout between platforms and work on the same code, so the probable best solution would be...

${project_loc:libs}/ourlib.jar


I'm viewing this as critical for cross-platform development using user libraries. Without it, I can't make use of the user library feature.
Comment 18 Frederic Fusier CLA 2007-06-20 04:23:12 EDT
*** Bug 83208 has been marked as a duplicate of this bug. ***
Comment 19 Frederic Fusier CLA 2007-06-21 07:02:16 EDT
*** Bug 185256 has been marked as a duplicate of this bug. ***
Comment 20 TobyS CLA 2007-07-16 09:49:55 EDT
It would be really good to get a fix for this - as it is at the moment we're still using the individual jar file approach as it's the only way we can switch paths easily between various systems.
Comment 21 Scott Reed CLA 2007-09-10 22:50:22 EDT
Fixing this would be huge for us. The advantages of User Libraries are significant but obviated by the need to redefine the jar path names each time the project is checked out to a new location.
Comment 22 Robert Dean CLA 2007-11-07 14:47:42 EST
This is also a problem for our environment.  We currently use User Libraries, but do to a different bug (that I was searching to see if anyone had opened as an issue when I happend across this one) we're currently looking to implement Maven or Ivy.
Comment 23 Victor Ott CLA 2007-12-05 18:59:49 EST
Since Eclipse 3.3.x it's possible to choose paths relative to the workspace for the libraries JavaDoc archives, and this brought me the inspiration: libraries with paths relative to the workspace _might_ be working too, but the Eclipse UI is not ready yet?

Journal of my steps to prove it (freshly downloaded Eclipse 3.3.1.1 Build id: M20071023-1652):
- create new workspace and two test projects: 'LibJEE' + 'P';
- put JEE JARs into '/LibJEE/lib', e.g. 'servlet-api.jar', 'mail.jar', etc.;
- create Eclipse User Library 'JEE_LIBS' and add those JARs from to this
.    library (still absolute paths);
- add JEE_LIBS to build path of project P;
- create test class T with main method, e.g.
.   "System.out.println("hi: " + new SendFailedException("dummy"));"
- run T.main(), expected output: "hi: javax.mail.SendFailedException: dummy"
- go to Eclipse Preferences and _export_ the Eclipse user library!
- edit that export file and _remove_ the prefix of absolute paths => transform
.   them to a paths relative to the workspace:
.   D:/workspace/LibJEE/lib/mail.jar  => /LibJEE/lib/mail.jar
- return to Eclipse Preferences and _import_ back the library definition!
- clean + build the workspace;
- run again test class: works!

Test 1:
- remove project LibJEE from workspace (but not the files);
- move project directory somewhere outside of the workspace;
- import project LibJEE back to workspace from the new location;
-  clean, build and run test class: works!

Test 2:
- new blank Eclipse installation;
- create new blank workspace;
- copy directories of LibJEE + T projects somewhere else, different locations;
===============================================================================
- import those projects LibJEE + T to the workspace;
- import the library definition to the workspace;
- clean, build and run test class: works!

Summary:
it seems to me that only the UI is missing. Of course, tests have to be performed to ensure there are no corner cases.
Comment 24 Jerome Lanneluc CLA 2007-12-06 04:03:28 EST
(In reply to comment #23)
Victor, you are right that the underlying infrastructure (in JDT/Core) supports workspace root relative jars in user libraries. And you are right that the UI doesn't allow to select a jar in the workspace. 

However this bug asks for more. It asks to be able to add jars relatively to a classpath variable, or relatively to a workspace folder. This is currently not supported by JDT/Core.

So you should enter a separate bug report against JDT/UI to ask to be able to select a jar relatively to the workspace root. (Please add the bug number to this bug for future reference).
Comment 25 Victor Ott CLA 2007-12-06 05:07:35 EST
(In reply to comment #24)
Jerome, thanks for your reply. I will follow your suggestion and will request to reopen bug 133191, but for JDT/UI instead of JDT/Core.
Comment 26 Mario L CLA 2008-07-15 06:06:33 EDT
Hi all, now that JDT/UI bug was solved, is there and work undergoing to fix also this one? You know, sharing a workspace within the team and with the automatic build machine is a pain in the ***.

Of course the REAL and useful solution for team-wide development will be only when bug 139132 will be solved as well, but by judging by the number of votes it's got we can wait like forever...
Comment 27 Jerome Lanneluc CLA 2008-08-21 07:05:29 EDT
(In reply to comment #26)
Mario, I believe the only remaining issue is to be able to add a jar to the User library relatively to a classpath variable. Is this what you are asking for? Or do you need more?

(Note you can already add a jar that is inside the workspace and it will be stored relatively to the workspace folder.)
Comment 28 Scott Reed CLA 2008-08-21 09:45:37 EDT
As I understand the proposal is for all the jars in a User Library to be specified with paths relative to any common root, not necessarily the file system root. 

I suggest that when the user adds a User Library with relative paths to a Project, the system should prompt the user to select an existing Classpath element or to add a new one to serve as the root for that Project.
Comment 29 Jerome Lanneluc CLA 2008-08-22 10:00:04 EDT
(In reply to comment #0)
> Adding Class Folders as library elements would be nice too. 
See bug 115097.

> A related issue would be defining a project specific libraries.
See bug 139132.
Comment 30 Jerome Lanneluc CLA 2008-08-22 10:03:40 EDT
(In reply to comment #28)
> As I understand the proposal is for all the jars in a User Library to be
> specified with paths relative to any common root, not necessarily the file
> system root. 
> 
> I suggest that when the user adds a User Library with relative paths to a
> Project, the system should prompt the user to select an existing Classpath
> element or to add a new one to serve as the root for that Project.
> 
I think using a classpath variable to define this common root would be what you want. The UI part can be discussed later (i.e. how do you specify the value of the classpath variable when you import the User Library).
Comment 31 Mario L CLA 2008-08-23 19:01:41 EDT
(In reply to comment #27)
Yes, I think adding the variables is a real step forward. The other feats I'd love belong already to other entries as you underlined.
Comment 32 Nebojsa CLA 2009-07-09 10:59:14 EDT
we'd like to have this fixed very, very much; we have a lot of small eclipse projects (apps) and lot of contractors, outside team members and us who must move around, changing machines, and having to keep libraries consistent and well organized across projects and yet allow for different local directory structures is a huge struggle for us.  It would really help us out a lot to be able to export user libraries with path(s) relative to customizable variable(s).
Comment 33 Kevin Gorham CLA 2010-10-25 21:11:57 EDT
Keeping dependencies out of version control is ideal.  We use Ivy to manage our project's dependencies and place them all under one folder: [project_home]/lib.  Eclipse should provide an easy and flexible way to add any and all jars from that folder to the classpath.  For now, all our developers are forced to create custom user libraries where the only difference is the absolute path to their project home directory.
Comment 34 hinst CLA 2011-03-27 08:19:55 EDT
So much time passed, but you still didn't fix it. 
It is unbelievable!!!!11
Comment 35 Jay Arthanareeswaran CLA 2011-03-28 00:28:39 EDT
I will take a look.
Comment 36 Thomas Reinhardt CLA 2011-06-07 07:56:14 EDT
Disclaimer: I'm a newbie. Sorry for all the things newbies tend to do wrong :)

I've made a patch that allows to add workspace relative JARs. That was the easy part. Now for all the administrative stuff:

@Jayaprakash: I assumed You are not working on this. Correct?

@All committers:
Who wants to give me a helping hand for stupid questions and the like? Most important one: which patch format?
Comment 37 Jay Arthanareeswaran CLA 2011-06-07 08:32:14 EDT
(In reply to comment #36)
> @Jayaprakash: I assumed You are not working on this. Correct?

 No, not yet.
 
> @All committers:
> Who wants to give me a helping hand for stupid questions and the like? Most
> important one: which patch format?

I am assuming you have checked out the eclipse projects from CVS. If you are using eclipse, just generate the CVS patch from your Team Synchronizing perspective.
Comment 38 Thomas Reinhardt CLA 2011-06-07 08:42:46 EDT
Created attachment 197492 [details]
Patch for eclipse bug 70417

Please review the patch. It should be pretty obvious what I did. Otherwise feel free to ask.
Comment 39 Jay Arthanareeswaran CLA 2011-06-13 01:10:22 EDT
Sorry, I didn't realize the changes you were talking about are on the UI-side. Hence, I am requesting Markus to take a look at it.

Markus, what do you think of this approach?
Comment 40 Markus Keller CLA 2011-06-14 10:43:36 EDT
Since bug 133191, user libraries can also contain JARs in the workspace. It looks like the UI to select a JAR from the workspace is the only thing missing, see bug 300542 for that.

I quickly looked at the patch, and it contained too many unnecessary changes in the .properties file. Also most of the changes to the UserLibraryPreferencePage.IDX_* are not necessary (just choose a free idx for the new button).

Please attach a new patch with only the necessary changes to bug 300542, and I can take a look for 3.8 (not right now, since we're concentrating on Java 7).


This bug also seems to contain more requests, e.g. bug 270733 and bug 115097.
Comment 41 Jay Arthanareeswaran CLA 2012-02-01 10:43:09 EST
(In reply to comment #40)
> Please attach a new patch with only the necessary changes to bug 300542, and I
> can take a look for 3.8 (not right now, since we're concentrating on Java 7).

Thomas, any update on the new patch?
Comment 42 Thomas Reinhardt CLA 2012-02-02 08:38:08 EST
(In reply to comment #41)
> (In reply to comment #40)
> > Please attach a new patch with only the necessary changes to bug 300542, and I
> > can take a look for 3.8 (not right now, since we're concentrating on Java 7).
> 
> Thomas, any update on the new patch?

The patch from 2011-06-07 is the correct one. There was a misunderstanding between Markus Keller and me, hence comment #40 (Markus, can you please confirm this? See your email from 2011-06-15).
Comment 43 Jay Arthanareeswaran CLA 2012-03-07 00:45:25 EST
(In reply to comment #42)
> The patch from 2011-06-07 is the correct one. There was a misunderstanding
> between Markus Keller and me, hence comment #40 (Markus, can you please confirm
> this? See your email from 2011-06-15).

Markus, do you expect to be able to look at this for 3.8? Thanks.
Comment 44 Markus Keller CLA 2012-03-11 19:10:53 EDT
Comment on attachment 197492 [details]
Patch for eclipse bug 70417

Sorry for the long delay. I'll look at the new patch in bug 300542 for M7.

(In reply to comment #40)
> This bug also seems to contain more requests, e.g. bug 270733 and bug 115097.

This bug can cover the remaining requests.
Comment 45 Satyam Kandula CLA 2012-04-25 01:49:50 EDT
This looks to be only JDT/UI bug. Hence, moving it.
Comment 46 Markus Keller CLA 2012-04-25 10:09:29 EDT
> This looks to be only JDT/UI bug. Hence, moving it.
Nope. Bug 300542 was the open UI bug for internal JARs, but this is fixed now.
Bug 115097 is a similar UI request to support class folders in user libraries.

The remaining open issue for this bug is that user libraries should allow classpath variables. Comment 13 says bug 93061 has a patch, but that needs to be tested to make sure e.g. bug 93061 comment 4 is addressed and updates to classpath variables are properly propagated to the user library container. The patch also misses Javadoc updates, e.g. in IClasspathContainer and IClasspathContainer#getClasspathEntries().


There is also bug 139132 (and bug 270733) which seems to ask for "sharable" user libraries (stored in a workspace file). See my position on that in bug 139132 comment 7.
Comment 47 Satyam Kandula CLA 2012-04-26 01:42:50 EDT
(In reply to comment #46)
Markus, Thanks for summary of the state. My mistake of not reading the comments thoroughly :(

I had a quick glance at the patch in bug 93061 comment 13. I believe there will be some substantial work to be done before we could release. Hence not targetting for 3.8.
Comment 48 Franz Gotsis CLA 2018-12-27 18:31:57 EST
As there is no activity since 2012 (which is 6 years back in time) I would like to ask why the code  Markus Keller (see comment provided given on 2012-04-25 10:09:29) did not make it into a release. The bug (actually it is a feature request) is still labeled "NEW".

A feature that allows to provide classpath entries (or project entries) that are defined relative to workspace paths would facilitate cross platform development (in my case Linux and Windows). The problem is that the paths in the above mentioned files is hardcoded and full, meaning that allow most of the path is identical, the windows path contains drive letters that are unknown in Unix (and therefore in Linux).

Maybe Markus Keller and  Satyam Kandula share the status of the proposed changes and highlight exactly why the implementation is that problematic (as it seemed to be in 2012).

kind regards
Franz Gotsis
(Munich Germany)
Comment 49 Christoph Laeubrich CLA 2021-04-11 02:47:22 EDT
Would it be possible to have at least a minimal viable solution here after more than 15(!) years and more than 70 votes? I'm currently working on support for User Libraries in tycho and absolute path are of course a no-go for such use-case.

I think the absolute minimal enhancement would be:

- I create a Userlib with absolute path
- I export it to a file
- I can replace absolute references with a classpath variable
- If I import it the classpath variable is resolved (don't mind about updates) and remains its variable nature as long as I don't edit it (e.g. is exported as a variable, re-resolved on restart of eclipse...)

Here is an example:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<eclipse-userlibraries version="2">
    <library name="Mockito" systemlibrary="false">
        <archive path="$M2_REPO/org/mockito/mockito-core/3.8.0/mockito-core-3.8.0.jar"/>
    </library>
</eclipse-userlibraries>

$M2_REPO is a Eclipse-Classpath variable.


https://bugs.eclipse.org/bugs/show_bug.cgi?id=93061 contains patches to add support for class-path variables but it seems to be outdated but maybe a JDT maintainer can pick them up and apply to the current source accordingly?