[Gradle] Move compiler version choosing logic into testHelpers.kt
Also, migrate from custom Kotlin versions to TestVersions.Kotlin.STABLE_RELEASE to avoid adding custom repositories
This commit is contained in:
committed by
Space Team
parent
a904ded5f2
commit
f507b19bd3
+3
-21
@@ -29,18 +29,15 @@ class BuildToolsApiJvmCompilationIT : KGPBaseTest() {
|
||||
runViaBuildToolsApi = false,
|
||||
incremental = false,
|
||||
),
|
||||
dependencyManagement = DependencyManagement.DefaultDependencyManagement(
|
||||
setOf("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
|
||||
)
|
||||
) {
|
||||
build("assemble") {
|
||||
assertNoDiagnostic(KotlinToolingDiagnostics.BuildToolsApiVersionInconsistency)
|
||||
}
|
||||
enableOtherVersionBuildToolsImpl()
|
||||
chooseCompilerVersion(TestVersions.Kotlin.STABLE_RELEASE)
|
||||
buildAndFail("assemble") {
|
||||
assertHasDiagnostic(KotlinToolingDiagnostics.BuildToolsApiVersionInconsistency)
|
||||
assertOutputContains("Expected version: ${defaultBuildOptions.kotlinVersion}")
|
||||
assertOutputContains("Actual resolved version: $OTHER_KOTLIN_VERSION")
|
||||
assertOutputContains("Actual resolved version: ${TestVersions.Kotlin.STABLE_RELEASE}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,12 +48,9 @@ class BuildToolsApiJvmCompilationIT : KGPBaseTest() {
|
||||
project(
|
||||
"simpleProject", gradleVersion, buildOptions = defaultBuildOptions.copy(
|
||||
incremental = false,
|
||||
),
|
||||
dependencyManagement = DependencyManagement.DefaultDependencyManagement(
|
||||
setOf("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
|
||||
)
|
||||
) {
|
||||
enableOtherVersionBuildToolsImpl()
|
||||
chooseCompilerVersion(TestVersions.Kotlin.STABLE_RELEASE)
|
||||
build("assemble") {
|
||||
assertNoDiagnostic(KotlinToolingDiagnostics.BuildToolsApiVersionInconsistency)
|
||||
}
|
||||
@@ -151,16 +145,4 @@ class BuildToolsApiJvmCompilationIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private const val OTHER_KOTLIN_VERSION = "1.9.30-dev-460"
|
||||
|
||||
private fun TestProject.enableOtherVersionBuildToolsImpl() {
|
||||
buildGradle.append(
|
||||
"""
|
||||
kotlin {
|
||||
compilerVersion.set("$OTHER_KOTLIN_VERSION")
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
+20
@@ -191,4 +191,24 @@ internal fun TestProject.addArchivesBaseNameCompat(
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Chooses compiler version used for JVM compilation in the build tools API mode.
|
||||
*
|
||||
* If the chosen version requires additional repositories, please consider using [DependencyManagement.DefaultDependencyManagement].
|
||||
*
|
||||
* Ensure [BuildOptions.runViaBuildToolsApi] is set to true for the builds!
|
||||
*/
|
||||
internal fun TestProject.chooseCompilerVersion(
|
||||
version: String,
|
||||
) {
|
||||
buildGradle.append(
|
||||
//language=Gradle
|
||||
"""
|
||||
kotlin {
|
||||
compilerVersion.set("$version")
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user