mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[workspace model] don't add 'external.system.id' attribute when saving modules imported from Maven in internal storage
Also add a test which checks saving imported project in internal storage. GitOrigin-RevId: 855ecc556678f2e032e58b517e20335bf07e20b0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
49b83ee097
commit
e6b8a50bf2
+4
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" />
|
||||
</project>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/test.iml" filepath="$PROJECT_DIR$/test.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
+36
-9
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -450,16 +450,18 @@ internal open class ModuleImlFileEntitiesSerializer(internal val modulePath: Mod
|
||||
writer: JpsFileContentWriter) {
|
||||
val optionsMap = TreeMap<String, String?>()
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user