List<Module> () { final List<Module> newModules = new ArrayList<>(); ApplicationManager.getApplication().runWriteAction(() -> { ModifiableModuleModel modifiableModel = ModuleManager.getInstance(getProject()).getModifiableModel(); Module module2 = modifiableModel.newModule("a.iml", StdModuleTypes.JAVA.getId()); newModules.add(module2); ModuleRootModificationUtil.addDependency(module2, getModule()); File repoLib = new File(PathManagerEx.getTestDataPath(), "/psi/cls/repo/"); VirtualFile repoRoot = LocalFileSystem.getInstance().findFileByIoFile(repoLib); assertNotNull(repoRoot); ModuleRootModificationUtil.addModuleLibrary(module2, repoRoot.getUrl()); newModules.add(modifiableModel.newModule("b.iml", StdModuleTypes.JAVA.getId())); modifiableModel.commit(); }); return newModules; }