mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
To determine which modules should be compiled in IntellijDevLauncher, we need to load product-modules.xml and plugin.xml files. Currently, they are loaded via RuntimeModuleRepository from output directories, so obsolete variant may be loaded or file may not be found at all if modules containing these files aren't compiled yet. This change introduces the ModuleResourceFileFinder class, which can locate resource files in source directories instead. It doesn't use existing functionality for that to avoid adding additional modules to the system classloader. Also, it parses necessary *.iml files only to speed up the process. GitOrigin-RevId: d55083ba879a3ae8c7985ba6e5f0211ad3062959
39 lines
1.5 KiB
Kotlin
39 lines
1.5 KiB
Kotlin
package com.intellij.tools.devLauncher
|
|
|
|
import com.intellij.openapi.application.ex.PathManagerEx
|
|
import org.junit.jupiter.api.Assertions.assertEquals
|
|
import org.junit.jupiter.api.BeforeEach
|
|
import org.junit.jupiter.api.Test
|
|
import java.nio.file.Path
|
|
import kotlin.io.path.Path
|
|
import kotlin.io.path.invariantSeparatorsPathString
|
|
import kotlin.io.path.relativeTo
|
|
|
|
class ModuleResourceFileFinderTest {
|
|
private lateinit var projectDir: Path
|
|
private lateinit var finder: ModuleResourceFileFinder
|
|
|
|
@BeforeEach
|
|
fun setUp() {
|
|
projectDir = Path(PathManagerEx.getCommunityHomePath()).resolve("tools/devLauncher/tests/testData/moduleResourceFinderProject")
|
|
finder = ModuleResourceFileFinder(projectDir)
|
|
}
|
|
|
|
@Test
|
|
fun `simple roots`() {
|
|
assertPath("simple/resources/a.txt", finder.findResourceFile("simple", "a.txt"))
|
|
assertPath("simple/src/b/b.txt", finder.findResourceFile("simple", "b/b.txt"))
|
|
assertPath(null, finder.findResourceFile("simple", "c.txt"))
|
|
}
|
|
|
|
@Test
|
|
fun `roots with prefixes`() {
|
|
assertPath("withPrefix/resources/a.txt", finder.findResourceFile("withPrefix", "prefix1/a.txt"))
|
|
assertPath("withPrefix/src/b/b.txt", finder.findResourceFile("withPrefix", "prefix2/b/b.txt"))
|
|
assertPath("additional-resources/c.txt", finder.findResourceFile("withPrefix", "prefix3/c.txt"))
|
|
}
|
|
|
|
private fun assertPath(expectedPath: String?, file: Path?) {
|
|
assertEquals(expectedPath, file?.relativeTo(projectDir)?.invariantSeparatorsPathString)
|
|
}
|
|
} |