Bug 297663 - [JUnit] JUnit not found when JDT installed as dropin
Summary: [JUnit] JUnit not found when JDT installed as dropin
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5.1   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.5.2   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 269496
Blocks:
  Show dependency tree
 
Reported: 2009-12-12 09:23 EST by Patrick Higgins CLA
Modified: 2010-02-10 15:17 EST (History)
5 users (show)

See Also:


Attachments
Patch to org.eclipse.jdt.junit plugin (1.37 KB, patch)
2009-12-12 09:26 EST, Patrick Higgins CLA
no flags Details | Diff
Patch to org.eclipse.jdt.junit plugin, v2 (1.37 KB, patch)
2009-12-12 09:31 EST, Patrick Higgins CLA
no flags Details | Diff
Patch to P2Utils, v3 (6.25 KB, patch)
2009-12-16 17:10 EST, Patrick Higgins CLA
no flags Details | Diff
Patched version of P2Utils.java (6.81 KB, text/plain)
2009-12-16 17:11 EST, Patrick Higgins CLA
no flags Details
Patch to P2Utils, v4 (7.99 KB, patch)
2009-12-16 18:51 EST, Patrick Higgins CLA
no flags Details | Diff
Patched version of P2Utils.java (6.42 KB, text/plain)
2009-12-16 18:52 EST, Patrick Higgins CLA
markus.kell.r: iplog+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Higgins CLA 2009-12-12 09:23:50 EST
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.5) Gecko/20091105 Fedora/3.5.5-1.fc12 Firefox/3.5.5
Build Identifier: M20090917-0800

Fedora 12 packages JDT as a dropin in the shared installation area, which is read-only to normal users. If you try to add the JUnit library to a project, you receive a message in the wizard saying "The selected JUnit version is not available".

I've tracked this down to the following problem:

The install area bundles.info does not have the org.junit plugin in it. This file is in:

/usr/lib/eclipse/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info

The config area bundles.info actually does have the org.junit plugin in it. It looks like:

[phiggins@xeno ~]$ grep '^org.junit' .eclipse/*/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info 
org.junit,3.8.2.v20090203-1005,dropins/jdt/plugins/org.junit_3.8.2.v20090203-1005/,4,false
org.junit4,4.5.0.v20090824,dropins/jdt/plugins/org.junit4_4.5.0.v20090824/,4,false

As you can see, it uses a relative URL to the dropins directory, which is actually in the shared install location: /usr/lib/eclipse/dropins

The plugin does not exist in my private config area.

I have created a patch to org/eclipse/jdt/internal/junit/buildpath/P2Utils.java which resolves relative URLs first to the config area and then to the install location when reading bundles from the config area. This patch fixes the problem for me.

I will attach the patch shortly.

Reproducible: Always

Steps to Reproduce:
1. Install the org.junit plugin in a shared install location
2. Remove the org.junit plugin from your config area if it exists
3. Remove the reference to the org.junit plugin from the shared install location bundles.info
4. Add a reference to the org.junit plugin to your config area bundles.info using a relative URL
5. Try to add a junit library to a project
Comment 1 Patrick Higgins CLA 2009-12-12 09:26:34 EST
Created attachment 154364 [details]
Patch to org.eclipse.jdt.junit plugin

The problem appears to be that the P2Utils class in the org.eclipse.jdt.junit plugin will only resolve relative URLs in the config area to URLs under the config area. I've patched it so that it will look there first, but will also check the install area if a relative URL is found.

This patch works for me.
Comment 2 Patrick Higgins CLA 2009-12-12 09:31:50 EST
Created attachment 154365 [details]
Patch to org.eclipse.jdt.junit plugin, v2

I updated my patch because there was an erroneous return statement in it.
Comment 3 Olivier Thomann CLA 2009-12-13 20:06:58 EST
Move to JDT/UI
Comment 4 Dani Megert CLA 2009-12-14 02:22:35 EST
JUnit is already part of the install. Why do you put a second copy into the dropins?
Comment 5 Alexander Kurtakov CLA 2009-12-14 04:18:05 EST
(In reply to comment #4)
> JUnit is already part of the install. Why do you put a second copy into the
> dropins?

It is not a second copy it is the only location where the junit bundle is found.
This is different installation layout. We are installing in a read-only location the platform and all the other plugins(jdt, cdt, mylyn and etc.) in dropins. This way we can have cdt without jdt and etc.  Also we don't know what plugins/features the user will have installed so we are letting p2 to create bundles.info in ~/.eclipse.

What do you think for the patch is it correct for you?
Comment 6 Markus Keller CLA 2009-12-15 07:00:31 EST
This code will soon go away (bug 269496), and I don't want to waste time reviewing and testing this now.
Comment 7 Patrick Higgins CLA 2009-12-16 17:10:32 EST
Created attachment 154604 [details]
Patch to P2Utils, v3

This patch addresses what may be a bug as noted in comment #13 on bug 269496.

I have removed the useConfigArea parameter and search Platform.getConfigLocation() and it's parents (as returned by Location.getParentLocation()).

I also resolve plugins by searching Platform.getConfigLocation() and it's parents, but I use getParentFile() on the config location, because plugins do not get installed in the config location, but into its parent directory.

I will also attach my modified version of P2Utils.java so that the developers working on bug 269496 can review it directly.
Comment 8 Patrick Higgins CLA 2009-12-16 17:11:35 EST
Created attachment 154605 [details]
Patched version of P2Utils.java

Patched version of P2Utils.java
Comment 9 Patrick Higgins CLA 2009-12-16 18:51:39 EST
Created attachment 154613 [details]
Patch to P2Utils, v4

The previous patch forgot to search the install location. This version does.
Comment 10 Patrick Higgins CLA 2009-12-16 18:52:34 EST
Created attachment 154614 [details]
Patched version of P2Utils.java

P2Utils.java with version 4 of the patch applied.
Comment 11 Markus Keller CLA 2010-01-07 13:31:53 EST
Comment on attachment 154614 [details]
Patched version of P2Utils.java

Dani has released this to HEAD.
Comment 12 Dani Megert CLA 2010-01-08 02:07:27 EST
Yep, committed the patch to HEAD with the following addition to the copyright notice:

 *     Patrick Higgins <patrick133t@yahoo.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=297663

Still have to do some final testing on the upcoming N-build.
Comment 13 Markus Keller CLA 2010-01-08 08:31:25 EST
Released attachment 154614 [details] to head (added copyright notice in header comment) and updated version of org.eclipse.jdt.junit to 3.5.2.

In HEAD, I restored the functionality from bug 272418 comment 4.
Comment 14 Markus Keller CLA 2010-01-21 05:05:58 EST
(In reply to comment #13)
> Released attachment 154614 [details] to head [..]

I actually meant: Released to R3_5_maintenance.

Patrick, could you please verify that your scenario works with M20100120-0800 or later?
Comment 15 Deepak Azad CLA 2010-01-21 08:52:15 EST
Following scenario verified with 3.5.2 (Build id: M20100120-0800)

Setup
- Win XP
- Eclipse install directory : read only. 
- Configuration directory - created in user home directory.

Steps
- Start eclipse with new workspace
- Create a new Java project
- Configure Build path -> Add Library -> JUnit 
==> Correct jars are identified on 3.5.2 and 3.5.1
==> 'Not found' message comes on 3.5
Comment 16 Dani Megert CLA 2010-02-04 05:25:25 EST
Patrick, please verify the fix in M20100203-0800.
Comment 17 Patrick Higgins CLA 2010-02-10 15:17:00 EST
(In reply to comment #16)
> Patrick, please verify the fix in M20100203-0800.

I'm trying to recreate the Fedora 12 build layout, but I have been unable to get JDT recognized. I don't really know how Alexander has been doing this, but it seems pretty hard to duplicate. I've been editing artifacts.xml, configuration/org.eclipse.equinox.simpleconfigurator/bundles.info, and other low-level files to try and put JDT into a dropin, but it just isn't working for me. Do you have plans to upgrade Eclipse to 3.5.2 for Fedora, Alexander? I will test out JDT in the packages if you do build it.