JpsModule (@NotNull Path file, @NotNull Element moduleRoot, List<String> paths, @Nullable JpsSdkType<?> projectSdkType, Map<String, String> pathVariables, @NotNull JpsPathMapper pathMapper) { String name = getModuleName(file); final String typeId = moduleRoot.getAttributeValue("type"); final JpsModulePropertiesSerializer<?> serializer = getModulePropertiesSerializer(typeId); final JpsModule module = createModule(name, moduleRoot, serializer); module.getContainer().setChild(JpsModuleSerializationDataExtensionImpl.ROLE, new JpsModuleSerializationDataExtensionImpl(file.getParent())); for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) { extension.loadModuleOptions(module, moduleRoot); } String baseModulePath = FileUtilRt.toSystemIndependentName(file.getParent().toString()); String classpath = moduleRoot.getAttributeValue(CLASSPATH_ATTRIBUTE); if (classpath == null) { try { JpsModuleRootModelSerializer.loadRootModel(module, JDomSerializationUtil.findComponent(moduleRoot, "NewModuleRootManager"), projectSdkType, pathMapper); } catch (JpsSerializationFormatException e) { LOG.warn("Failed to load module configuration from " + file + ": " + e.getMessage(), e); } } else { for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) { JpsModuleClasspathSerializer classpathSerializer = extension.getClasspathSerializer(); if (classpathSerializer != null && classpathSerializer.getClasspathId().equals(classpath)) { String classpathDir = moduleRoot.getAttributeValue(CLASSPATH_DIR_ATTRIBUTE); final JpsMacroExpander expander = createModuleMacroExpander(pathVariables, file); classpathSerializer.loadClasspath(module, classpathDir, baseModulePath, expander, paths, projectSdkType); } } } Element facetsTag = JDomSerializationUtil.findComponent(moduleRoot, JpsFacetSerializer.FACET_MANAGER_COMPONENT_NAME); Element externalFacetsTag = JDomSerializationUtil.findComponent(moduleRoot, "ExternalFacetManager"); Element mergedFacetsTag; if (facetsTag == null) { mergedFacetsTag = externalFacetsTag; } else if (externalFacetsTag != null) { mergedFacetsTag = JDOMUtil.deepMerge(facetsTag, externalFacetsTag); } else { mergedFacetsTag = facetsTag; } JpsFacetSerializer.loadFacets(module, mergedFacetsTag); return module; }