/**
  * Populates {@link GradleModule#getContentRoots() content roots} of the given intellij module on
  * the basis of the information contained at the given gradle module.
  *
  * @param gradleModule holder of the module information received from the gradle tooling api
  * @param intellijModule corresponding module from intellij gradle plugin domain
  * @throws IllegalArgumentException if given gradle module contains invalid data
  */
 private static void populateContentRoots(
     @NotNull IdeaModule gradleModule, @NotNull GradleModule intellijModule)
     throws IllegalArgumentException {
   DomainObjectSet<? extends IdeaContentRoot> contentRoots = gradleModule.getContentRoots();
   if (contentRoots == null) {
     return;
   }
   for (IdeaContentRoot gradleContentRoot : contentRoots) {
     if (gradleContentRoot == null) {
       continue;
     }
     File rootDirectory = gradleContentRoot.getRootDirectory();
     if (rootDirectory == null) {
       continue;
     }
     GradleContentRoot intellijContentRoot =
         new GradleContentRoot(intellijModule, rootDirectory.getAbsolutePath());
     populateContentRoot(
         intellijContentRoot, SourceType.SOURCE, gradleContentRoot.getSourceDirectories());
     populateContentRoot(
         intellijContentRoot, SourceType.TEST, gradleContentRoot.getTestDirectories());
     Set<File> excluded = gradleContentRoot.getExcludeDirectories();
     if (excluded != null) {
       for (File file : excluded) {
         intellijContentRoot.storePath(SourceType.EXCLUDED, file.getAbsolutePath());
       }
     }
     intellijModule.addContentRoot(intellijContentRoot);
   }
 }
 /**
  * Stores information about given directories at the given content root
  *
  * @param contentRoot target paths info holder
  * @param type type of data located at the given directories
  * @param dirs directories which paths should be stored at the given content root
  * @throws IllegalArgumentException if specified by {@link GradleContentRoot#storePath(SourceType,
  *     String)}
  */
 private static void populateContentRoot(
     @NotNull GradleContentRoot contentRoot,
     @NotNull SourceType type,
     @Nullable Iterable<? extends IdeaSourceDirectory> dirs)
     throws IllegalArgumentException {
   if (dirs == null) {
     return;
   }
   for (IdeaSourceDirectory dir : dirs) {
     contentRoot.storePath(type, dir.getDirectory().getAbsolutePath());
   }
 }