Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 311603

Summary: [build path] editing user library properties drops classpath entry attributes
Product: [Eclipse Project] JDT Reporter: Karen Butzke <karenfbutzke>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: daniel_megert, konstantin
Version: 3.6Flags: markus.kell.r: review+
Target Milestone: 3.7 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch v1 markus.kell.r: iplog+

Description Karen Butzke CLA 2010-05-04 14:29:44 EDT
In the Java Persistence properties for a JPA project choose the JPA implementation type of User Library and select an appropriate library.  Close and save the project properties.  Right click on the library in the Project Explorer and choose 'Properties'.  Select 'User Libraries...' and add/remove a jar from the user library.  It can be any jar, doesn't have to be one that is needed for this library to be valid for the particular JPA platform.  Now go back to the Project properties and view the Java Persistence page and you will see that the library has been unselected and there is an error.

I can only get this to happen if I edit the library as described above.  If you instead edit it through the Project properties 'Java Build Path' page, the JPA implementation library never gets unselected.
Comment 1 Karen Butzke CLA 2010-05-05 16:30:18 EDT
I'm not sure how this could be a Dali bug, so I'm going to set it to the library provider framework.  Any ideas?
Comment 2 Konstantin Komissarchik CLA 2010-06-01 14:55:00 EDT
Reproduced the scenario and confirmed this as framework bug.
Comment 3 Konstantin Komissarchik CLA 2010-10-21 14:58:27 EDT
Taking another looks at this. This looks to be a bug in JDT UI. Editing User Library properties via entry on the project properties wipes classpath entry attributes.

Repro for JDT UI:

1. Create a java project.
2. Create a user library called "mylib".
3. Add the following entry to .classpath file:

<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/mylib">
   <attributes>
       <attribute name="owner.project.facets" value="jpt.jpa"/>
   </attributes>
</classpathentry>

4. Find library entry in package explorer. Right click -> mylib -> properties.
5. User Libraries... 
6. Edit library content by adding another jar.
7. Close all dialogs.
8. Notice that classpath entry has been stripped of attributes:

<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/mylib"/>

Attributes are a critical facility for layered projects to extend JDT behavior.
Comment 4 Konstantin Komissarchik CLA 2010-10-21 15:14:03 EDT
Replace steps 5-8, with this:

5. Hit ok to close classpath container properties dialog without making any changes.
Comment 5 Konstantin Komissarchik CLA 2010-10-21 15:31:00 EDT
Created attachment 181441 [details]
Patch v1

This patches UserLibraryWizardPage to preserve all of the information in the input classpath entry if the entry path doesn't change (user didn't select a different user library). There was already logic to preserve the setting of the export flag. I consolidated that logic with my changes.

Testing the described scenario as well as other editing and creation scenarios. 

Can this patch be considered for inclusion into 3.7?
Comment 6 Dani Megert CLA 2010-10-22 02:31:56 EDT
Markus, please take a look during M4.
Comment 7 Markus Keller CLA 2010-12-01 15:31:27 EST
That makes perfectly sense. Thanks a lot for the patch. Released to HEAD.