Bug 3648 - Java source attachment lost when same JAR added to another project (1GDKX8O)
Summary: Java source attachment lost when same JAR added to another project (1GDKX8O)
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P1 major (vote)
Target Milestone: ---   Edit
Assignee: Martin Aeschlimann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-10 22:58 EDT by Jim des Rivieres CLA
Modified: 2001-11-01 04:45 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim des Rivieres CLA 2001-10-10 22:58:34 EDT
The Java source attachment for an external JAR gets lost when the same JAR is 
added to another project. While it is a desirable feature that all source attachments
are maintained at the workspace level (i.e., shared between probjects), this bug 
cripples that feature.

1. create a Java project P1; add an external JAR to P1
	D:/eclipse105-jdk/eclipse/plugins/org.eclipse.core.runtime/runtime.zip
with source attachment
	D:/eclipse105-jdk/eclipse/plugins/org.eclipse.core.runtime/runtimesrc.zip

2. In package view of P1, select the JAR and open its Properties.

Observe: It has a Java source attachment.

3. create a Java project P2; add the same external JAR to P2
	D:/eclipse105-jdk/eclipse/plugins/org.eclipse.core.runtime/runtime.zip
with no source attachment

4 [details]. In package view of P1, select the JAR and open its Properties.

Observe: It has lost its Java source attachment.

Expectation: As soon as I said I wanted to add the JAR, it should have
recognized that this JAR was already known in this workspace to have
a source attachment. The source attachment should have been picked
up and preserved (and had I opened the subdialog to set the source
attachment, I should see the value already primed).

NOTES:

OT (17/05/2001 3:53:28 PM)
	The problem seems to be related to the fact that the source attachement property are stored according to the path. So for two external jars the source attachement property is
	identical. Then when adding the second time the same external jar to a different project, the source attachement of the first one is deleted.
	The following method should test if the root has a source attachement path before deleting it. In the example, entry.getSourceAttachementPath() and 
	entry.getSourceAttachmentRootPath() are null when we add the second external jar without any source attachement. But if you check the value of root.getSourceAttachementPath()
	and root.getSourceAttachmentRootPath() before executing root.attachSource(sourcePath, sourcePrefix, null); you will find that the two values are not null and point to the previous
	source attachement settings for the first external jar added in the first project.

org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathsBlock.attachSource(IPath, CPListElement)
	private void attachSource(IPath path, CPListElement entry) throws CoreException {
		IPackageFragmentRoot root= fCurrJProject.findPackageFragmentRoot(path);
		if (root != null && root.isArchive()) {
			IPath sourcePath= entry.getSourceAttachmentPath();
			IPath sourcePrefix= entry.getSourceAttachmentRootPath();
			root.attachSource(sourcePath, sourcePrefix, null);
			JavaDocAccess.setJavaDocLocation(root, entry.getJavaDocLocation());
		}
	}

	Should move to ITPJUI.

MA (5/22/01 4:38:14 PM)
	lots of changes with source attachments
	please verify

PA (5/29/01 2:44:18 PM)
	build 113
	still problems:
	- 2 Projects
	- both use the same rt.jar and src.jar (but dont take ./jre/rt.jar, use rt.jar and src.jar provided by JDK)
	-> 2nd project has no source attachment !

MA (5/30/01 6:15:13 PM)
	cant reproduce. asked P for a reproducable case
Comment 1 DJ Houghton CLA 2001-10-24 07:15:30 EDT
PRODUCT VERSION:

build 105

Comment 2 Martin Aeschlimann CLA 2001-11-01 04:45:23 EST
close. seems to work.