[BTA tests] Get BTA implementation version via the API

^KT-61860 In Progress
This commit is contained in:
Alexander.Likhachev
2024-03-05 22:07:48 +01:00
committed by Space Team
parent 3f6b5ae86d
commit f634f9dacf
4 changed files with 12 additions and 26 deletions
@@ -91,10 +91,6 @@ testing {
targets.all {
projectTest(taskName = testTask.name, jUnitMode = JUnitMode.JUnit5) {
ensureExecutedAgainstExpectedBuildToolsImplVersion(implVersion)
systemProperty(
"kotlin.build-tools-api.impl-version",
implVersion.toString()
) // TODO: remove after KT-63862
}
}
}
@@ -119,12 +115,6 @@ testing {
targets.all {
projectTest(taskName = testTask.name, jUnitMode = JUnitMode.JUnit5) {
systemProperty("kotlin.build-tools-api.log.level", "DEBUG")
if (isRegular) {
systemProperty(
"kotlin.build-tools-api.impl-version",
project.version.toString()
) // TODO: remove after KT-63862
}
}
}
}
@@ -1,14 +0,0 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.buildtools.api.tests
import org.jetbrains.kotlin.tooling.core.KotlinToolingVersion
// TODO: remove after KT-63862
const val IMPL_VERSION_SYSTEM_PROPERTY = "kotlin.build-tools-api.impl-version"
val buildToolsVersion = System.getProperty(IMPL_VERSION_SYSTEM_PROPERTY)
?.let { KotlinToolingVersion(it) }
?: error("The build tools implementation version must be passed via the `$IMPL_VERSION_SYSTEM_PROPERTY` system property to the tests")
@@ -6,11 +6,22 @@
package org.jetbrains.kotlin.buildtools.api.tests.compilation.model
import org.jetbrains.kotlin.buildtools.api.CompilationService
import org.jetbrains.kotlin.tooling.core.KotlinToolingVersion
abstract class BaseTest {
companion object {
val compilationService: CompilationService by lazy {
CompilationService.loadImplementation(BaseTest::class.java.classLoader)
}
private val _compilerVersion by lazy {
try {
compilationService.getCompilerVersion()
} catch (_: NoSuchMethodError) {
"1.9.20" // getCompilerVersion is introduced since 2.0.0
}
}
val compilerVersion: KotlinToolingVersion by lazy {
KotlinToolingVersion(_compilerVersion)
}
}
}
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.buildtools.api.CompilationResult
import org.jetbrains.kotlin.buildtools.api.CompilerExecutionStrategyConfiguration
import org.jetbrains.kotlin.buildtools.api.SourcesChanges
import org.jetbrains.kotlin.buildtools.api.jvm.*
import org.jetbrains.kotlin.buildtools.api.tests.buildToolsVersion
import org.jetbrains.kotlin.buildtools.api.tests.compilation.model.Module
import org.jetbrains.kotlin.tooling.core.KotlinToolingVersion
import java.io.File
@@ -98,7 +97,7 @@ class JvmModule(
options.setBuildDir(buildDirectory.toFile())
options.setRootProjectDir(project.projectDirectory.toFile())
if (buildToolsVersion < KotlinToolingVersion(2, 0, 0, "Beta2")) {
if (BaseTest.compilerVersion < KotlinToolingVersion(2, 0, 0, "Beta2")) {
// workaround for the incorrect default value
options.useOutputDirs(setOf(icCachesDir.toFile(), outputDirectory.toFile()))
}