Search in sources :

Example 1 with JpsModuleClasspathSerializer

use of org.jetbrains.jps.model.serialization.module.JpsModuleClasspathSerializer in project intellij-community by JetBrains.

the class JpsProjectLoader method loadModule.

@Nullable
private static JpsModule loadModule(@NotNull File file, @NotNull Element moduleRoot, List<String> paths, @Nullable JpsSdkType<?> projectSdkType, Map<String, String> pathVariables) {
    String name = FileUtil.getNameWithoutExtension(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.getParentFile()));
    for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) {
        extension.loadModuleOptions(module, moduleRoot);
    }
    String baseModulePath = FileUtil.toSystemIndependentName(file.getParent());
    String classpath = moduleRoot.getAttributeValue(CLASSPATH_ATTRIBUTE);
    if (classpath == null) {
        JpsModuleRootModelSerializer.loadRootModel(module, JDomSerializationUtil.findComponent(moduleRoot, "NewModuleRootManager"), projectSdkType);
    } 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);
            }
        }
    }
    JpsFacetSerializer.loadFacets(module, JDomSerializationUtil.findComponent(moduleRoot, "FacetManager"));
    return module;
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsModuleClasspathSerializer(org.jetbrains.jps.model.serialization.module.JpsModuleClasspathSerializer) JpsModuleSerializationDataExtensionImpl(org.jetbrains.jps.model.serialization.impl.JpsModuleSerializationDataExtensionImpl) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Nullable (org.jetbrains.annotations.Nullable)1 JpsModule (org.jetbrains.jps.model.module.JpsModule)1 JpsModuleSerializationDataExtensionImpl (org.jetbrains.jps.model.serialization.impl.JpsModuleSerializationDataExtensionImpl)1 JpsModuleClasspathSerializer (org.jetbrains.jps.model.serialization.module.JpsModuleClasspathSerializer)1