Package com.intellij.openapi.module

Examples of com.intellij.openapi.module.ModifiableModuleModel


    @Nullable
    @Override
    public List<Module> commit(final Project project, ModifiableModuleModel model, ModulesProvider modulesProvider, ModifiableArtifactModel artifactModel) {
        //Create Module and iml-file
        final ModifiableModuleModel moduleModel = model != null ? model : ModuleManager.getInstance(project).getModifiableModel();
        Module myModule = moduleModel.newModule(project.getBasePath() + File.separator + project.getName() + ".iml", "GO_MODULE");
        final ModifiableRootModel mrm = ModuleRootManager.getInstance(myModule).getModifiableModel();
        mrm.inheritSdk();

        ApplicationManager.getApplication().runWriteAction(new Runnable() {
            @Override
            public void run() {
                //Add the default content entry
                VirtualFile baseDir = project.getBaseDir();
                ContentEntry entry = mrm.addContentEntry(baseDir);

                //Set src-folder as SourceFolder, if it exists
                VirtualFile srcFolder = baseDir.findFileByRelativePath("src");
                if(srcFolder != null) {
                    entry.addSourceFolder(srcFolder, false);
                }

                mrm.commit();
                moduleModel.commit();
            }
        });


        return Arrays.asList(myModule);
View Full Code Here


        ClassPathUtils.getInstance().switchToPluginClassLoader();
        Map projectMap = LeiningenAPI.loadProject(leinProjectFile.getPath());
        String name = (String) projectMap.get(LEIN_PROJECT_NAME);

        final ModifiableModuleModel moduleManager = createModuleManager(ideaProject);
        final ModifiableRootModel module = createModule(moduleManager, leinProjectFile.getParent().getPath(), name);
        initializeModulePaths(projectMap, module, leinProjectFile.getParent());

        ProjectRootManagerEx rootManager = ProjectRootManagerEx.getInstanceEx(ideaProject);
        module.setSdk(rootManager.getProjectSdk());

        //Setup the dependencies
        // Based loosely on org.jetbrains.idea.maven.importing.MavenRootModelAdapter#addLibraryDependency

        //We could use the module table here, but then the libraries wouldn't be shared across modules.
        final LibraryTable.ModifiableModel projectLibraries = ProjectLibraryTable.getInstance(ideaProject).getModifiableModel();

        //Load all the dependencies from the project file
        List dependencyMaps = LeiningenAPI.loadDependencies(leinProjectFile.getCanonicalPath());
        final List<LibraryInfo> dependencies = initializeDependencies(module, projectLibraries,dependencyMaps);

        new WriteAction() {
            @Override
            protected void run(Result result) throws Throwable {

                for (LibraryInfo library : dependencies) {
                    library.modifiableModel.commit();
                }

                //Save the project libraries
                projectLibraries.commit();

                //Save the module itself to the module file.
                module.commit();

                //Save the list of modules that are in this project to the IDEA project file
                moduleManager.commit();
            }
        }.execute();

        return projectMap;
    }
View Full Code Here

      selectedAppNames.add(importedOtpApp.getName());
    }
    Sdk projectSdk = fixProjectSdk(project);
    List<Module> createdModules = new ArrayList<Module>();
    final List<ModifiableRootModel> createdRootModels = new ArrayList<ModifiableRootModel>();
    final ModifiableModuleModel obtainedModuleModel =
      moduleModel != null ? moduleModel : ModuleManager.getInstance(project).getModifiableModel();
    for (ImportedOtpApp importedOtpApp : mySelectedOtpApps) {
      VirtualFile ideaModuleDir = importedOtpApp.getRoot();
      String ideaModuleFile = ideaModuleDir.getCanonicalPath() + File.separator + importedOtpApp.getName() + ".iml";
      Module module = obtainedModuleModel.newModule(ideaModuleFile, ErlangModuleType.getInstance().getId());
      createdModules.add(module);
      importedOtpApp.setModule(module);
      if (importedOtpApp.getIdeaModuleFile() == null) {
        ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
        // Make it inherit SDK from the project.
        rootModel.inheritSdk();
        // Initialize source and test paths.
        ContentEntry content = rootModel.addContentEntry(importedOtpApp.getRoot());
        addSourceDirToContent(content, ideaModuleDir, "src", false);
        addSourceDirToContent(content, ideaModuleDir, "test", true);
        addIncludeDirectories(content, importedOtpApp);
        // Exclude standard folders
        excludeDirFromContent(content, ideaModuleDir, "doc");
        // Initialize output paths according to Rebar conventions.
        CompilerModuleExtension compilerModuleExt = rootModel.getModuleExtension(CompilerModuleExtension.class);
        compilerModuleExt.inheritCompilerOutputPath(false);
        compilerModuleExt.setCompilerOutputPath(ideaModuleDir + File.separator + "ebin");
        compilerModuleExt.setCompilerOutputPathForTests(ideaModuleDir + File.separator + ".eunit");
        createdRootModels.add(rootModel);
        // Set inter-module dependencies
        resolveModuleDeps(rootModel, importedOtpApp, projectSdk, selectedAppNames);
      }
    }
    // Commit project structure.
    LOG.info("Commit project structure");
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      public void run() {
        for (ModifiableRootModel rootModel : createdRootModels) {
          rootModel.commit();
        }
        obtainedModuleModel.commit();
      }
    });

    addErlangFacets(mySelectedOtpApps);
    RebarSettings.getInstance(project).setRebarPath(myRebarPath);
View Full Code Here

TOP

Related Classes of com.intellij.openapi.module.ModifiableModuleModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.