[FIR] Look for jar with plugin annotations in system property and by direct path in tests
This is needed to make those tests work in JPS, because corresponding system property is set only by gradle
This commit is contained in:
committed by
teamcity
parent
a85d25d7a6
commit
f5637e5077
+22
-12
@@ -15,20 +15,30 @@ import java.io.File
|
||||
import java.io.FilenameFilter
|
||||
|
||||
class PluginAnnotationsProvider(testServices: TestServices) : EnvironmentConfigurator(testServices) {
|
||||
|
||||
private val firPluginAnnotationsJar: File by lazy {
|
||||
val firPluginAnnotationsPath = System.getProperty("firPluginAnnotations.path") ?: error("firPluginAnnotations.path system property is not set")
|
||||
val firPluginAnnotationsFile = File(firPluginAnnotationsPath)
|
||||
if (!firPluginAnnotationsFile.isFile &&
|
||||
firPluginAnnotationsFile.name.startsWith("plugin-annotations") &&
|
||||
firPluginAnnotationsFile.name.endsWith(".jar")
|
||||
) {
|
||||
error("Can't find fir plugin annotations jar file in firPluginAnnotations.path system property")
|
||||
}
|
||||
firPluginAnnotationsFile
|
||||
companion object {
|
||||
private const val ANNOTATIONS_JAR_DIR = "plugins/fir-plugin-prototype/plugin-annotations/build/libs/"
|
||||
private val ANNOTATIONS_JAR_FILTER = FilenameFilter { _, name -> name.startsWith("plugin-annotations") && name.endsWith(".jar") }
|
||||
}
|
||||
|
||||
override fun configureCompilerConfiguration(configuration: CompilerConfiguration, module: TestModule) {
|
||||
configuration.addJvmClasspathRoot(firPluginAnnotationsJar)
|
||||
val pluginAnnotationsJar = findJarFromProperty()
|
||||
?: findJarByPath()
|
||||
?: error("Jar with annotations does not exist. Please run :plugins:fir-plugin-prototype:plugin-annotations:jar or specify firPluginAnnotations.path system property")
|
||||
configuration.addJvmClasspathRoot(pluginAnnotationsJar)
|
||||
}
|
||||
|
||||
private fun findJarByPath(): File? {
|
||||
val libDir = File(ANNOTATIONS_JAR_DIR)
|
||||
if (!libDir.exists() || !libDir.isDirectory) return null
|
||||
return libDir.listFiles(ANNOTATIONS_JAR_FILTER)?.firstOrNull()
|
||||
}
|
||||
|
||||
private fun findJarFromProperty(): File? {
|
||||
val firPluginAnnotationsPath = System.getProperty("firPluginAnnotations.path") ?: return null
|
||||
return File(firPluginAnnotationsPath).takeIf {
|
||||
it.isFile &&
|
||||
it.name.startsWith("plugin-annotations") &&
|
||||
it.name.endsWith(".jar")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user