Index: model/org/eclipse/jdt/internal/core/ClasspathEntry.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java,v retrieving revision 1.77 diff -u -r1.77 ClasspathEntry.java --- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 7 May 2005 18:24:42 -0000 1.77 +++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 17 May 2005 08:31:03 -0000 @@ -179,7 +179,7 @@ /* * The extra attributes */ - private IClasspathAttribute[] extraAttributes; + IClasspathAttribute[] extraAttributes; /** * Creates a class path entry of the specified kind with the given path. @@ -274,7 +274,7 @@ return result; } - private static IClasspathAttribute[] decodeExtraAttributes(Element element) { + static IClasspathAttribute[] decodeExtraAttributes(Element element) { Node extra = element.getElementsByTagName(TAG_ATTRIBUTES).item(0); if (extra == null) return NO_EXTRA_ATTRIBUTES; NodeList attributes = element.getElementsByTagName(TAG_ATTRIBUTE); @@ -299,7 +299,7 @@ return result; } - private static IAccessRule[] decodeAccessRules(Element element) { + static IAccessRule[] decodeAccessRules(Element element) { Node accessRules = element.getElementsByTagName(TAG_ACCESS_RULES).item(0); if (accessRules == null || accessRules.getNodeType() != Node.ELEMENT_NODE) return null; NodeList list = ((Element) accessRules).getElementsByTagName(TAG_ACCESS_RULE); @@ -449,7 +449,7 @@ writer.endTag(TAG_CLASSPATHENTRY, indent); } - private void encodeExtraAttributes(XMLWriter writer, boolean indent, boolean newLine) { + void encodeExtraAttributes(XMLWriter writer, boolean indent, boolean newLine) { writer.startTag(TAG_ATTRIBUTES, indent); for (int i = 0; i < this.extraAttributes.length; i++) { IClasspathAttribute attribute = this.extraAttributes[i]; @@ -461,7 +461,7 @@ writer.endTag(TAG_ATTRIBUTES, indent); } - private void encodeAccessRules(XMLWriter writer, boolean indent, boolean newLine) { + void encodeAccessRules(XMLWriter writer, boolean indent, boolean newLine) { writer.startTag(TAG_ACCESS_RULES, indent); AccessRule[] rules = getAccessRuleSet().getAccessRules(); Index: model/org/eclipse/jdt/internal/core/UserLibrary.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibrary.java,v retrieving revision 1.4 diff -u -r1.4 UserLibrary.java --- model/org/eclipse/jdt/internal/core/UserLibrary.java 8 Apr 2005 20:30:28 -0000 1.4 +++ model/org/eclipse/jdt/internal/core/UserLibrary.java 17 May 2005 08:31:04 -0000 @@ -21,6 +21,8 @@ import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.IAccessRule; +import org.eclipse.jdt.core.IClasspathAttribute; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.internal.core.util.Messages; @@ -61,7 +63,7 @@ public boolean isSystemLibrary() { return this.isSystemLibrary; } - + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @@ -105,17 +107,35 @@ xmlWriter.printTag(TAG_USERLIBRARY, library, true, true, false); for (int i = 0; i < this.entries.length; ++i) { - IClasspathEntry curr= this.entries[i]; - + ClasspathEntry cpEntry = (ClasspathEntry) this.entries[i]; + HashMap archive = new HashMap(); - archive.put(TAG_PATH, curr.getPath().toString()); - IPath sourceAttach= curr.getSourceAttachmentPath(); + archive.put(TAG_PATH, cpEntry.getPath().toString()); + IPath sourceAttach= cpEntry.getSourceAttachmentPath(); if (sourceAttach != null) archive.put(TAG_SOURCEATTACHMENT, sourceAttach); - IPath sourceAttachRoot= curr.getSourceAttachmentRootPath(); + IPath sourceAttachRoot= cpEntry.getSourceAttachmentRootPath(); if (sourceAttachRoot != null) archive.put(TAG_SOURCEATTACHMENTROOT, sourceAttachRoot); - xmlWriter.printTag(TAG_ARCHIVE, archive, true, true, true); + + boolean hasExtraAttributes = cpEntry.extraAttributes != null && cpEntry.extraAttributes.length != 0; + boolean hasRestrictions = cpEntry.getAccessRuleSet() != null; // access rule set is null if no access rules + xmlWriter.printTag(TAG_ARCHIVE, archive, true, true, !(hasExtraAttributes || hasRestrictions)); + + // write extra attributes if necessary + if (hasExtraAttributes) { + cpEntry.encodeExtraAttributes(xmlWriter, true, true); + } + + // write extra attributes and restriction if necessary + if (hasRestrictions) { + cpEntry.encodeAccessRules(xmlWriter, true, true); + } + + // write archive end tag if necessary + if (hasExtraAttributes || hasRestrictions) { + xmlWriter.endTag(TAG_ARCHIVE, true); + } } xmlWriter.endTag(TAG_USERLIBRARY, true); writer.flush(); @@ -157,7 +177,10 @@ String path = element.getAttribute(TAG_PATH); IPath sourceAttach= element.hasAttribute(TAG_SOURCEATTACHMENT) ? new Path(element.getAttribute(TAG_SOURCEATTACHMENT)) : null; IPath sourceAttachRoot= element.hasAttribute(TAG_SOURCEATTACHMENTROOT) ? new Path(element.getAttribute(TAG_SOURCEATTACHMENTROOT)) : null; - res.add(JavaCore.newLibraryEntry(new Path(path), sourceAttach, sourceAttachRoot)); + IClasspathAttribute[] extraAttributes = ClasspathEntry.decodeExtraAttributes(element); + IAccessRule[] accessRules = ClasspathEntry.decodeAccessRules(element); + IClasspathEntry entry = JavaCore.newLibraryEntry(new Path(path), sourceAttach, sourceAttachRoot, accessRules, extraAttributes, false/*not exported*/); + res.add(entry); } } }