private Set<String> getDuplicates(Set<GradleLibrary> libraries) {
   Set<String> duplicates = new HashSet<String>();
   Set<String> seen = new HashSet<String>();
   for (GradleLibrary library : libraries) {
     if (library.getFile() != null && !seen.add(library.getFile().getName())) {
       duplicates.add(library.getFile().getName());
     }
   }
   return duplicates;
 }
 private void libraries(Set<GradleLibrary> libraries, LibraryCallback callback)
     throws IOException {
   if (libraries != null) {
     Set<String> duplicates = getDuplicates(libraries);
     for (GradleLibrary library : libraries) {
       if (!isExcluded(library)) {
         library.setIncludeGroupName(duplicates.contains(library.getName()));
         callback.library(library);
       }
     }
   }
 }
 private Set<GradleLibrary> minus(Set<GradleLibrary> source, Set<GradleLibrary> toRemove) {
   if (source == null || toRemove == null) {
     return source;
   }
   Set<File> filesToRemove = new HashSet<File>();
   for (GradleLibrary library : toRemove) {
     filesToRemove.add(library.getFile());
   }
   Set<GradleLibrary> result = new LinkedHashSet<GradleLibrary>();
   for (GradleLibrary library : source) {
     if (!filesToRemove.contains(library.getFile())) {
       result.add(library);
     }
   }
   return result;
 }
  @NotNull
  private static AbstractGradleDependency buildDependency(
      @NotNull GradleModule ownerModule,
      @NotNull IdeaSingleEntryLibraryDependency dependency,
      @NotNull GradleProject intellijProject)
      throws IllegalStateException {
    File binaryPath = dependency.getFile();
    if (binaryPath == null) {
      throw new IllegalStateException(
          String.format(
              "Can't parse external library dependency '%s'. Reason: it doesn't specify path to the binaries",
              dependency));
    }

    // Gradle API doesn't provide library name at the moment.
    GradleLibrary library = new GradleLibrary(FileUtil.getNameWithoutExtension(binaryPath));
    library.addPath(LibraryPathType.BINARY, binaryPath.getAbsolutePath());

    File sourcePath = dependency.getSource();
    if (sourcePath != null) {
      library.addPath(LibraryPathType.SOURCE, sourcePath.getAbsolutePath());
    }

    File javadocPath = dependency.getJavadoc();
    if (javadocPath != null) {
      library.addPath(LibraryPathType.DOC, javadocPath.getAbsolutePath());
    }

    if (!intellijProject.addLibrary(library)) {
      for (GradleLibrary registeredLibrary : intellijProject.getLibraries()) {
        if (registeredLibrary.equals(library)) {
          return new GradleLibraryDependency(ownerModule, registeredLibrary);
        }
      }
    }

    return new GradleLibraryDependency(ownerModule, library);
  }
 private boolean isDevToolsJar(GradleLibrary library) {
   return "org.springframework.boot".equals(library.getGroup())
       && library.getName().startsWith("spring-boot-devtools");
 }