void (@NotNull IdeModifiableModelsProvider modelsProvider, @NotNull final Collection<? extends DataNode<ContentRootData>> data, @NotNull final Module module) { final ModifiableRootModel modifiableRootModel = modelsProvider.getModifiableRootModel(module); for (final DataNode<ContentRootData> node : data) { final ContentRootData contentRoot = node.getData(); final String rootPath = contentRoot.getRootPath(); final ContentEntry contentEntry = findContentRoot(modifiableRootModel, rootPath); if(contentEntry == null) { continue; } final Collection<String> toExclude = new HashSet<>(GradleConstants.KNOWN_GRADLE_FILES.size()); for (SourceFolder sourceFolder : contentEntry.getSourceFolders()) { final VirtualFile sourceFolderRoot = sourceFolder.getFile(); if (sourceFolderRoot != null && sourceFolderRoot.isDirectory()) { for (String knownGradleFile : GradleConstants.KNOWN_GRADLE_FILES) { final VirtualFile buildFile = sourceFolderRoot.findChild(knownGradleFile); if (buildFile != null && buildFile.exists()) { toExclude.add(knownGradleFile); } } } } final List<String> existingPatterns = contentEntry.getExcludePatterns(); for (String toExcludeFile : toExclude) { if (!existingPatterns.contains(toExcludeFile)) { logDebug("Excluding build file '%s' for module '%s'", toExcludeFile, module.getName()); contentEntry.addExcludePattern(toExcludeFile); } } } }