Fix parcelize test dependencies on android plugin layoutlib

#KTI-82
This commit is contained in:
Vyacheslav Gerasimov
2021-12-02 01:11:09 +03:00
committed by teamcity
parent 049066f8ac
commit 318e001d1b
3 changed files with 23 additions and 37 deletions
@@ -30,25 +30,17 @@ abstract class AbstractParcelBoxTest : CodegenTestCase() {
private fun String.withoutAndroidPrefix(): String = removePrefix("studio.android.sdktools.")
private val androidPluginPath: String by lazy {
System.getProperty("ideaSdk.androidPlugin.path")?.takeIf { File(it).isDirectory }
?: throw RuntimeException("Unable to get a valid path from 'ideaSdk.androidPlugin.path' property, please point it to the Idea android plugin location")
private fun getLayoutLibFile(property: String): File {
val layoutLibFile = File(System.getProperty(property))
if (!layoutLibFile.isFile) {
error("Can't find jar file in $property system property")
}
return layoutLibFile
}
val layoutlibJar: File by lazy {
File(androidPluginPath).listFiles { _, rawName ->
val name = rawName.withoutAndroidPrefix()
name.startsWith("layoutlib-") && name.endsWith(".jar")
&& !name.startsWith("layoutlib-api-") && !name.startsWith("layoutlib-loader")
}?.firstOrNull() ?: error("Unable to locate layoutlib jar in '$androidPluginPath'")
}
val layoutlibJar: File by lazy { getLayoutLibFile("layoutLib.path") }
val layoutlibApiJar: File by lazy {
File(androidPluginPath).listFiles { _, rawName ->
val name = rawName.withoutAndroidPrefix()
name.startsWith("layoutlib-api-") && name.endsWith(".jar")
}?.firstOrNull() ?: error("Unable to locate layoutlib-api jar in '$androidPluginPath'")
}
val layoutlibApiJar: File by lazy { getLayoutLibFile("layoutLibApi.path") }
private val JUNIT_GENERATED_TEST_CLASS_BYTES by lazy { constructSyntheticTestClass() }
private const val JUNIT_GENERATED_TEST_CLASS_FQNAME = "test.JunitTest"
@@ -113,11 +105,6 @@ abstract class AbstractParcelBoxTest : CodegenTestCase() {
}
}
private val androidPluginPath: String by lazy {
System.getProperty("ideaSdk.androidPlugin.path")?.takeIf { File(it).isDirectory }
?: throw RuntimeException("Unable to get a valid path from 'ideaSdk.androidPlugin.path' property, please point it to the Idea android plugin location")
}
private fun getClasspathForTest(): List<File> {
val kotlinRuntimeJar = PathUtil.kotlinPathsForIdeaPlugin.stdlibPath