JpsLibrary (Element libraryElement, String name, @NotNull JpsPathMapper pathMapper) { String typeId = libraryElement.getAttributeValue(TYPE_ATTRIBUTE); final JpsLibraryPropertiesSerializer<?> loader = getLibraryPropertiesSerializer(typeId); JpsLibrary library = createLibrary(name, loader, libraryElement.getChild(PROPERTIES_TAG)); MultiMap<JpsOrderRootType, String> jarDirectories = new MultiMap<>(); MultiMap<JpsOrderRootType, String> recursiveJarDirectories = new MultiMap<>(); for (Element jarDirectory : JDOMUtil.getChildren(libraryElement, JAR_DIRECTORY_TAG)) { String url = pathMapper.mapUrl(jarDirectory.getAttributeValue(URL_ATTRIBUTE)); String rootTypeId = jarDirectory.getAttributeValue(TYPE_ATTRIBUTE); final JpsOrderRootType rootType = rootTypeId != null ? getRootType(rootTypeId) : JpsOrderRootType.COMPILED; boolean recursive = Boolean.parseBoolean(jarDirectory.getAttributeValue(RECURSIVE_ATTRIBUTE)); jarDirectories.putValue(rootType, url); if (recursive) { recursiveJarDirectories.putValue(rootType, url); } } for (Element rootsElement : libraryElement.getChildren()) { final String rootTypeId = rootsElement.getName(); if (!rootTypeId.equals(JAR_DIRECTORY_TAG) && !rootTypeId.equals(PROPERTIES_TAG) && !rootTypeId.equals("excluded")) { final JpsOrderRootType rootType = getRootType(rootTypeId); for (Element rootElement : JDOMUtil.getChildren(rootsElement, ROOT_TAG)) { String url = pathMapper.mapUrl(rootElement.getAttributeValue(URL_ATTRIBUTE)); JpsLibraryRoot.InclusionOptions options; if (jarDirectories.get(rootType).contains(url)) { final boolean recursive = recursiveJarDirectories.get(rootType).contains(url); options = recursive ? JpsLibraryRoot.InclusionOptions.ARCHIVES_UNDER_ROOT_RECURSIVELY : JpsLibraryRoot.InclusionOptions.ARCHIVES_UNDER_ROOT; } else { options = JpsLibraryRoot.InclusionOptions.ROOT_ITSELF; } library.addRoot(url, rootType, options); } } } return library; }