mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
IDEA-163185 [Gradle|Sync] fix: don't resolve the content root as a project root for the source set module
The content root at project root is taken by the module for the Gradle project. GitOrigin-RevId: 88f1656b648cce3097ab83c5b2d3235cf17ac661
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9f3a303592
commit
400f7f95b6
@@ -74,6 +74,9 @@ class GradleContentRootIndex {
|
||||
return sourceRootPath
|
||||
}
|
||||
val contentRootPath = sourceRootPath.parent
|
||||
if (contentRootPath == null || contentRootPath == projectRootPath) {
|
||||
return sourceRootPath
|
||||
}
|
||||
val contentRootWeight = contentRootWeightMap[contentRootPath]
|
||||
if (contentRootWeight == null || contentRootWeight > 1) {
|
||||
return sourceRootPath
|
||||
|
||||
@@ -422,4 +422,52 @@ class GradleContentRootSyncContributorTest : GradlePhasedSyncTestCase() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test content root configuration with single source root`() {
|
||||
|
||||
val projectRoot = projectRoot.toNioPath()
|
||||
val virtualFileUrlManager = project.workspaceModel.getVirtualFileUrlManager()
|
||||
|
||||
Disposer.newDisposable().use { disposable ->
|
||||
|
||||
val contentRootContributorAssertion = ListenerAssertion()
|
||||
|
||||
whenPhaseCompleted(disposable) { _, storage, phase ->
|
||||
if (phase == GradleModelFetchPhase.PROJECT_SOURCE_SET_PHASE) {
|
||||
contentRootContributorAssertion.trace {
|
||||
assertModules(storage, "project", "project.main", "project.test")
|
||||
assertContentRoots(virtualFileUrlManager, storage, "project", projectRoot)
|
||||
assertContentRoots(virtualFileUrlManager, storage, "project.main", projectRoot.resolve("src"))
|
||||
assertContentRoots(virtualFileUrlManager, storage, "project.test")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createSettingsFile {
|
||||
setProjectName("project")
|
||||
}
|
||||
createBuildFile {
|
||||
withJavaPlugin()
|
||||
addPostfix("""
|
||||
|sourceSets.main.java.srcDirs = ["src"]
|
||||
|sourceSets.main.resources.srcDirs = []
|
||||
|sourceSets.test.java.srcDirs = []
|
||||
|sourceSets.test.resources.srcDirs = []
|
||||
""".trimMargin())
|
||||
}
|
||||
|
||||
importProject()
|
||||
|
||||
assertModules(project, "project", "project.main", "project.test")
|
||||
assertContentRoots(project, "project", projectRoot)
|
||||
assertContentRoots(project, "project.main", projectRoot.resolve("src"))
|
||||
assertContentRoots(project, "project.test")
|
||||
|
||||
contentRootContributorAssertion.assertListenerFailures()
|
||||
contentRootContributorAssertion.assertListenerState(1) {
|
||||
"The project loaded phase should be finished only once"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user