diff --git a/platform/external-system-impl/testData/jpsSerialization/singleModuleInInternalStorage/project/.idea/misc.xml b/platform/external-system-impl/testData/jpsSerialization/singleModuleInInternalStorage/project/.idea/misc.xml
new file mode 100644
index 000000000000..0b9bbe1d6a48
--- /dev/null
+++ b/platform/external-system-impl/testData/jpsSerialization/singleModuleInInternalStorage/project/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/platform/external-system-impl/testData/jpsSerialization/singleModuleInInternalStorage/project/.idea/modules.xml b/platform/external-system-impl/testData/jpsSerialization/singleModuleInInternalStorage/project/.idea/modules.xml
new file mode 100644
index 000000000000..ea6e2e719328
--- /dev/null
+++ b/platform/external-system-impl/testData/jpsSerialization/singleModuleInInternalStorage/project/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/platform/external-system-impl/testData/jpsSerialization/singleModuleInInternalStorage/project/test.iml b/platform/external-system-impl/testData/jpsSerialization/singleModuleInInternalStorage/project/test.iml
new file mode 100644
index 000000000000..2ec2ef0acd6e
--- /dev/null
+++ b/platform/external-system-impl/testData/jpsSerialization/singleModuleInInternalStorage/project/test.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/configurationStore/ExternalSystemStorageTest.kt b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/configurationStore/ExternalSystemStorageTest.kt
index 6dad93806421..7022f81610ec 100644
--- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/configurationStore/ExternalSystemStorageTest.kt
+++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/configurationStore/ExternalSystemStorageTest.kt
@@ -43,6 +43,8 @@ import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.assertj.core.api.Assertions.assertThat
import org.junit.*
+import org.junit.Assert.assertFalse
+import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
@@ -63,7 +65,14 @@ class ExternalSystemStorageTest {
val tempDirManager = TemporaryDirectory()
@Test
- fun `save single module`() = saveProjectAndCheckResult("singleModule") { project, projectDir ->
+ fun `save single module`() = saveProjectInExternalStorageAndCheckResult("singleModule") { project, projectDir ->
+ val module = ModuleManager.getInstance(project).newModule(projectDir.resolve("test.iml").systemIndependentPath, ModuleTypeId.JAVA_MODULE)
+ ModuleRootModificationUtil.addContentRoot(module, projectDir.systemIndependentPath)
+ ExternalSystemModulePropertyManager.getInstance(module).setMavenized(true)
+ }
+
+ @Test
+ fun `save imported module in internal storage`() = saveProjectInInternalStorageAndCheckResult("singleModuleInInternalStorage") { project, projectDir ->
val module = ModuleManager.getInstance(project).newModule(projectDir.resolve("test.iml").systemIndependentPath, ModuleTypeId.JAVA_MODULE)
ModuleRootModificationUtil.addContentRoot(module, projectDir.systemIndependentPath)
ExternalSystemModulePropertyManager.getInstance(module).setMavenized(true)
@@ -79,7 +88,7 @@ class ExternalSystemStorageTest {
}
@Test
- fun `save mixed modules`() = saveProjectAndCheckResult("mixedModules") { project, projectDir ->
+ fun `save mixed modules`() = saveProjectInExternalStorageAndCheckResult("mixedModules") { project, projectDir ->
val regular = ModuleManager.getInstance(project).newModule(projectDir.resolve("regular.iml").systemIndependentPath, ModuleTypeId.JAVA_MODULE)
ModuleRootModificationUtil.addContentRoot(regular, projectDir.resolve("regular").systemIndependentPath)
val imported = ModuleManager.getInstance(project).newModule(projectDir.resolve("imported.iml").systemIndependentPath, ModuleTypeId.JAVA_MODULE)
@@ -108,7 +117,7 @@ class ExternalSystemStorageTest {
}
@Test
- fun `save regular facet in imported module`() = saveProjectAndCheckResult("regularFacetInImportedModule") { project, projectDir ->
+ fun `save regular facet in imported module`() = saveProjectInExternalStorageAndCheckResult("regularFacetInImportedModule") { project, projectDir ->
val imported = ModuleManager.getInstance(project).newModule(projectDir.resolve("imported.iml").systemIndependentPath, ModuleTypeId.JAVA_MODULE)
FacetManager.getInstance(imported).addFacet(MockFacetType.getInstance(), "regular", null)
ExternalSystemModulePropertyManager.getInstance(imported).setMavenized(true)
@@ -132,7 +141,7 @@ class ExternalSystemStorageTest {
}
@Test
- fun `save imported facet in imported module`() = saveProjectAndCheckResult("importedFacetInImportedModule") { project, projectDir ->
+ fun `save imported facet in imported module`() = saveProjectInExternalStorageAndCheckResult("importedFacetInImportedModule") { project, projectDir ->
val imported = ModuleManager.getInstance(project).newModule(projectDir.resolve("imported.iml").systemIndependentPath, ModuleTypeId.JAVA_MODULE)
val facetManager = FacetManager.getInstance(imported)
val model = facetManager.createModifiableModel()
@@ -152,7 +161,7 @@ class ExternalSystemStorageTest {
}
@Test
- fun `save libraries`() = saveProjectAndCheckResult("libraries") { project, _ ->
+ fun `save libraries`() = saveProjectInExternalStorageAndCheckResult("libraries") { project, _ ->
val libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(project)
val model = libraryTable.modifiableModel
model.createLibrary("regular", null)
@@ -176,7 +185,7 @@ class ExternalSystemStorageTest {
}
@Test
- fun `save artifacts`() = saveProjectAndCheckResult("artifacts") { project, projectDir ->
+ fun `save artifacts`() = saveProjectInExternalStorageAndCheckResult("artifacts") { project, projectDir ->
val model = ArtifactManager.getInstance(project).createModifiableModel()
val regular = model.addArtifact("regular", PlainArtifactType.getInstance())
regular.outputPath = projectDir.resolve("out/artifacts/regular").systemIndependentPath
@@ -211,10 +220,22 @@ class ExternalSystemStorageTest {
private val externalSource get() = ExternalProjectSystemRegistry.getInstance().getSourceById("test")
- private fun saveProjectAndCheckResult(testDataDirName: String, setupProject: (Project, Path) -> Unit) {
+ private fun saveProjectInInternalStorageAndCheckResult(testDataDirName: String, setupProject: (Project, Path) -> Unit) {
+ doNotEnableExternalStorageByDefaultInTests {
+ saveProjectAndCheckResult(testDataDirName, false, setupProject)
+ }
+ }
+
+ private fun saveProjectInExternalStorageAndCheckResult(testDataDirName: String, setupProject: (Project, Path) -> Unit) {
+ saveProjectAndCheckResult(testDataDirName, true, setupProject)
+ }
+
+ private fun saveProjectAndCheckResult(testDataDirName: String,
+ storeExternally: Boolean,
+ setupProject: (Project, Path) -> Unit) {
runBlocking {
createProjectAndUseInLoadComponentStateMode(tempDirManager, directoryBased = true, useDefaultProjectSettings = false) { project ->
- ExternalProjectsManagerImpl.getInstance(project).setStoreExternally(true)
+ ExternalProjectsManagerImpl.getInstance(project).setStoreExternally(storeExternally)
val projectDir = Paths.get(project.stateStore.directoryStorePath).parent
val cacheDir = ExternalProjectsDataStorage.getProjectConfigurationDir(project)
cacheDir.delete()
@@ -236,7 +257,13 @@ class ExternalSystemStorageTest {
FileUtil.copyDir(testDataRoot.resolve(testDataDirName).toFile(), expectedDir.toFile())
projectDir.toFile().assertMatches(directoryContentOf(expectedDir.resolve("project")))
- cacheDir.toFile().assertMatches(directoryContentOf(expectedDir.resolve("cache")), FileTextMatcher.ignoreBlankLines())
+ val expectedCacheDir = expectedDir.resolve("cache")
+ if (Files.exists(expectedCacheDir)) {
+ cacheDir.toFile().assertMatches(directoryContentOf(expectedCacheDir), FileTextMatcher.ignoreBlankLines())
+ }
+ else {
+ assertFalse("$cacheDir doesn't exist", Files.exists(cacheDir))
+ }
}
}
}
diff --git a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/jps/serialization/ModuleImlFileEntitiesSerializer.kt b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/jps/serialization/ModuleImlFileEntitiesSerializer.kt
index 2fa65952f347..74f21af66635 100644
--- a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/jps/serialization/ModuleImlFileEntitiesSerializer.kt
+++ b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/jps/serialization/ModuleImlFileEntitiesSerializer.kt
@@ -450,16 +450,18 @@ internal open class ModuleImlFileEntitiesSerializer(internal val modulePath: Mod
writer: JpsFileContentWriter) {
val optionsMap = TreeMap()
if (externalSystemOptions != null) {
- optionsMap["external.system.id"] = externalSystemOptions.externalSystem
+ if (externalSystemOptions.externalSystem == ExternalProjectSystemRegistry.MAVEN_EXTERNAL_SOURCE_ID) {
+ optionsMap[ExternalProjectSystemRegistry.IS_MAVEN_MODULE_KEY] = true.toString()
+ }
+ else {
+ optionsMap["external.system.id"] = externalSystemOptions.externalSystem
+ }
optionsMap["external.root.project.path"] = externalSystemOptions.rootProjectPath
optionsMap["external.linked.project.id"] = externalSystemOptions.linkedProjectId
optionsMap["external.linked.project.path"] = externalSystemOptions.linkedProjectPath
optionsMap["external.system.module.type"] = externalSystemOptions.externalSystemModuleType
optionsMap["external.system.module.group"] = externalSystemOptions.externalSystemModuleGroup
optionsMap["external.system.module.version"] = externalSystemOptions.externalSystemModuleVersion
- if (externalSystemOptions.externalSystem == ExternalProjectSystemRegistry.MAVEN_EXTERNAL_SOURCE_ID) {
- optionsMap[ExternalProjectSystemRegistry.IS_MAVEN_MODULE_KEY] = true.toString()
- }
}
optionsMap["type"] = moduleType
if (customImlData != null) {