From ca7e083dbf479818ef235e89175ad154dffc65e8 Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Tue, 26 Nov 2013 12:44:25 +0400 Subject: [PATCH] IDEA-116891 gradle import creates a lot of extra empty directories --- .../i18n/ExternalSystemBundle.properties | 1 + .../settings/ExternalProjectSettings.java | 10 +++++ .../manage/ContentRootDataService.java | 44 ++++++++++++++----- ...bstractExternalProjectSettingsControl.java | 11 ++++- 4 files changed, 53 insertions(+), 13 deletions(-) diff --git a/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties b/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties index 17078c097875..a1511838a4c7 100644 --- a/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties +++ b/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties @@ -11,6 +11,7 @@ setting.type.location.explicit.correct={0} location is defined setting.type.location.explicit.incorrect={0} location is incorrect settings.label.select.project={0} project: settings.label.use.auto.import=Use auto-import +settings.label.create.empty.content.root.directories=Create directories for known content roots automatically settings.title.linked.projects=Linked {0} projects settings.title.project.settings=Project-level settings settings.title.system.settings=Global {0} settings diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/ExternalProjectSettings.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/ExternalProjectSettings.java index c7a6ecbd5443..c3e68dea3942 100644 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/ExternalProjectSettings.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/ExternalProjectSettings.java @@ -28,6 +28,7 @@ public abstract class ExternalProjectSettings implements Comparable data : datas) { final ContentRootData contentRoot = data.getData(); + final ContentEntry contentEntry = findOrCreateContentRoot(model, contentRoot.getRootPath()); contentEntry.clearExcludeFolders(); contentEntry.clearSourceFolders(); LOG.info(String.format("Importing content root '%s' for module '%s'", contentRoot.getRootPath(), module.getName())); for (String path : contentRoot.getPaths(ExternalSystemSourceType.SOURCE)) { - createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.SOURCE, false); + createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.SOURCE, false, createEmptyContentRootDirectories); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.TEST)) { - createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.TEST_SOURCE, false); + createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.TEST_SOURCE, false, createEmptyContentRootDirectories); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.RESOURCE)) { - createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaResourceRootType.RESOURCE, false); + createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaResourceRootType.RESOURCE, false, createEmptyContentRootDirectories); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.TEST_RESOURCE)) { - createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaResourceRootType.TEST_RESOURCE, false); + createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaResourceRootType.TEST_RESOURCE, false, createEmptyContentRootDirectories); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.SOURCE_GENERATED)) { - createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.SOURCE, true); + createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.SOURCE, true, createEmptyContentRootDirectories); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.TEST_GENERATED)) { - createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.TEST_SOURCE, true); + createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.TEST_SOURCE, true, createEmptyContentRootDirectories); } for (String path : contentRoot.getPaths(ExternalSystemSourceType.EXCLUDED)) { createExcludedRootIfAbsent(contentEntry, path, module.getName()); @@ -154,7 +172,7 @@ public class ContentRootDataService implements ProjectDataService folders = entry.getSourceFolders(sourceRootType); for (SourceFolder folder : folders) { VirtualFile file = folder.getFile(); @@ -173,11 +191,13 @@ public class ContentRootDataService implements ProjectDataService