From d68322ae57630d869a66a6ed4d2d9d85726e7cc0 Mon Sep 17 00:00:00 2001 From: nik Date: Mon, 2 Apr 2018 18:10:41 +0300 Subject: [PATCH] tests: extract method to load IntelliJ IDEA project configuration ... which specified MAVEN_REPOSITORY path variable properly to ensure that library configurations will have valid JAR URLs. --- .../intellij/project/IntelliJProjectConfiguration.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/testFramework/src/com/intellij/project/IntelliJProjectConfiguration.kt b/platform/testFramework/src/com/intellij/project/IntelliJProjectConfiguration.kt index 2ed6153e9ef9..e998d06359f5 100644 --- a/platform/testFramework/src/com/intellij/project/IntelliJProjectConfiguration.kt +++ b/platform/testFramework/src/com/intellij/project/IntelliJProjectConfiguration.kt @@ -22,6 +22,7 @@ import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.testFramework.UsefulTestCase import com.intellij.util.SmartList import com.intellij.util.SystemProperties +import org.jetbrains.jps.model.JpsProject import org.jetbrains.jps.model.library.JpsLibraryCollection import org.jetbrains.jps.model.library.JpsOrderRootType import org.jetbrains.jps.model.serialization.JpsSerializationManager @@ -41,8 +42,7 @@ class IntelliJProjectConfiguration { private val moduleLibraries: Map> init { - val m2Repo = FileUtil.toSystemIndependentName(File(SystemProperties.getUserHome(), ".m2/repository").absolutePath) - val project = JpsSerializationManager.getInstance().loadProject(projectHome, mapOf("MAVEN_REPOSITORY" to m2Repo)) + val project = loadIntelliJProject(projectHome) fun extractLibrariesRoots(collection: JpsLibraryCollection) = collection.libraries.associateBy({ it.name }, { LibraryRoots(SmartList(it.getFiles(JpsOrderRootType.COMPILED)), SmartList(it.getFiles(JpsOrderRootType.SOURCES))) }) @@ -87,6 +87,12 @@ class IntelliJProjectConfiguration { Assert.assertNotNull(jarRoot) return jarRoot!! } + + @JvmStatic + fun loadIntelliJProject(projectHome: String): JpsProject { + val m2Repo = FileUtil.toSystemIndependentName(File(SystemProperties.getUserHome(), ".m2/repository").absolutePath) + return JpsSerializationManager.getInstance().loadProject(projectHome, mapOf("MAVEN_REPOSITORY" to m2Repo)) + } } class LibraryRoots(val classes: List, val sources: List) {