mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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.
This commit is contained in:
@@ -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<String, Map<String, LibraryRoots>>
|
||||
|
||||
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<File>, val sources: List<File>) {
|
||||
|
||||
Reference in New Issue
Block a user