From 5cb55734bec4d22f46faf2bea1cb2f40b87405fc Mon Sep 17 00:00:00 2001 From: Nikolay Chashnikov Date: Wed, 12 Jan 2022 17:49:04 +0300 Subject: [PATCH] [maven] import to workspace model: don't create duplicating sources roots (IDEA-284414) GitOrigin-RevId: 75451f034c88a85ccbdc9b917faf598c38731f10 --- .../importing/workspaceModel/WorkspaceModuleImporter.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/workspaceModel/WorkspaceModuleImporter.kt b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/workspaceModel/WorkspaceModuleImporter.kt index 6708dc2458d4..b8dc2c9e8298 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/workspaceModel/WorkspaceModuleImporter.kt +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/workspaceModel/WorkspaceModuleImporter.kt @@ -251,7 +251,10 @@ class WorkspaceModuleImporter( private fun addGeneratedJavaSourceFolder(path: String, type: JavaSourceRootType, contentRootEntity: ContentRootEntity) { if (File(path).list().isNullOrEmpty()) return - val sourceRootEntity = builder.addSourceRootEntity(contentRootEntity, virtualFileUrlManager.fromPath(path), + val url = virtualFileUrlManager.fromPath(path) + if (contentRootEntity.sourceRoots.any { it.url == url }) return + + val sourceRootEntity = builder.addSourceRootEntity(contentRootEntity, url, SourceRootPropertiesHelper.findSerializer(type)?.typeId!!, contentRootEntity.entitySource) builder.addJavaSourceRootEntity(sourceRootEntity, true, "")