diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleContentRootIndex.kt b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleContentRootIndex.kt index aa06694f020f..b67463bdc2bd 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleContentRootIndex.kt +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleContentRootIndex.kt @@ -59,21 +59,25 @@ class GradleContentRootIndex { ): Set { val projectRootPath = externalProject.projectDir.toPath() + val buildRootPath = externalProject.buildDir.toPath() val contentRootPaths = NioPathPrefixTreeFactory.createSet() for (sourceDirectorySet in sources.values) { for (sourceRootPath in sourceDirectorySet) { - val contentRootPath = resolveContentRoot(projectRootPath, sourceRootPath) + val contentRootPath = resolveContentRoot(projectRootPath, buildRootPath, sourceRootPath) contentRootPaths.add(contentRootPath) } } return contentRootPaths.getRoots() } - private fun resolveContentRoot(projectRootPath: Path, sourceRootPath: Path): Path { + private fun resolveContentRoot(projectRootPath: Path, buildRootPath: Path, sourceRootPath: Path): Path { if (!sourceRootPath.startsWith(projectRootPath)) { return sourceRootPath } + if (sourceRootPath.startsWith(buildRootPath)) { + return sourceRootPath + } val contentRootPath = sourceRootPath.parent if (contentRootPath == null || contentRootPath == projectRootPath) { return sourceRootPath