private static GradleProject populateProject(
     @NotNull IdeaProject project, @NotNull String projectPath) {
   String projectDirPath = GradleUtil.toCanonicalPath(PathUtil.getParentPath(projectPath));
   // Gradle API doesn't expose project compile output path yet.
   GradleProject result = new GradleProject(projectDirPath, projectDirPath + "/out");
   result.setName(project.getName());
   result.setJdkVersion(project.getJdkName());
   result.setLanguageLevel(project.getLanguageLevel().getLevel());
   return result;
 }
 @NotNull
 private static Map<String, Pair<GradleModule, IdeaModule>> createModules(
     @NotNull IdeaProject gradleProject, @NotNull GradleProject intellijProject)
     throws IllegalStateException {
   DomainObjectSet<? extends IdeaModule> gradleModules = gradleProject.getModules();
   if (gradleModules == null || gradleModules.isEmpty()) {
     throw new IllegalStateException("No modules found for the target project: " + gradleProject);
   }
   Map<String, Pair<GradleModule, IdeaModule>> result =
       new HashMap<String, Pair<GradleModule, IdeaModule>>();
   for (IdeaModule gradleModule : gradleModules) {
     if (gradleModule == null) {
       continue;
     }
     String moduleName = gradleModule.getName();
     if (moduleName == null) {
       throw new IllegalStateException("Module with undefined name detected: " + gradleModule);
     }
     GradleModule intellijModule =
         new GradleModule(moduleName, intellijProject.getProjectFileDirectoryPath());
     Pair<GradleModule, IdeaModule> previouslyParsedModule = result.get(moduleName);
     if (previouslyParsedModule != null) {
       throw new IllegalStateException(
           String.format(
               "Modules with duplicate name (%s) detected: '%s' and '%s'",
               moduleName, intellijModule, previouslyParsedModule));
     }
     result.put(moduleName, new Pair<GradleModule, IdeaModule>(intellijModule, gradleModule));
     intellijProject.addModule(intellijModule);
   }
   return result;
 }