void (Element rootElement) { checkDisposed(); Element element = new Element(JpsLibraryTableSerializer.LIBRARY_TAG); if (myName != null) { element.setAttribute(JpsLibraryTableSerializer.NAME_ATTRIBUTE, myName); } if (myKind != null) { element.setAttribute(JpsLibraryTableSerializer.TYPE_ATTRIBUTE, myKind.getKindId()); LOG.assertTrue(myProperties != null, "Properties is 'null' in library with kind " + myKind); final Object state = myProperties.getState(); if (state != null) { final Element propertiesElement = state instanceof Element ? ((Element)state).clone() : XmlSerializer.serialize(state); if (propertiesElement != null) { element.addContent(propertiesElement.setName(JpsLibraryTableSerializer.PROPERTIES_TAG)); } } } if (myExternalSource != null) { Module module = getModule(); Project project; if (module == null) { project = myLibraryTable instanceof ProjectLibraryTable ? ((ProjectLibraryTable)myLibraryTable).getProject() : null; } else { project = module.getProject(); } if (ProjectUtilCore.isExternalStorageEnabled(project)) { //we can add this attribute only if the library configuration will be stored separately, otherwise we will get modified files in .idea/libraries. element.setAttribute(SerializationConstants.EXTERNAL_SYSTEM_ID_ATTRIBUTE, myExternalSource.getId()); } } List<OrderRootType> storableRootTypes = new ArrayList<>(Arrays.asList(OrderRootType.getAllTypes())); if (myKind != null) { storableRootTypes.addAll(Arrays.asList(myKind.getAdditionalRootTypes())); } for (OrderRootType rootType : sortRootTypes(storableRootTypes)) { VirtualFilePointerContainer roots = myRoots.get(rootType); if ((roots == null || roots.isEmpty()) && rootType.skipWriteIfEmpty()) { //compatibility iml/ipr continue; } final Element rootTypeElement = new Element(rootType.name()); if (roots != null) { roots.writeExternal(rootTypeElement, JpsLibraryTableSerializer.ROOT_TAG, false); } element.addContent(rootTypeElement); } if (myExcludedRoots != null && !myExcludedRoots.isEmpty()) { Element excluded = new Element(EXCLUDED_ROOTS_TAG); myExcludedRoots.writeExternal(excluded, JpsLibraryTableSerializer.ROOT_TAG, false); element.addContent(excluded); } writeJarDirectories(element); rootElement.addContent(element); }