[KPM] kotlin-gradle-plugin-idea: Improve testing with snapshots

KT-51262
KT-51220
This commit is contained in:
sebastian.sellmair
2022-02-15 16:21:00 +01:00
committed by Space
parent 969222c372
commit 06b2f83774
@@ -22,16 +22,16 @@ dependencies {
publish() publish()
tasks.test { /* Setup Backwards Compatibility Test */
/* When -Psnapshot is set, then the test runs against a locally installed snapshot version (./gradlew install) */ run {
val isSnapshotTest = project.providers.gradleProperty("snapshot").isPresent /* When -Pkgp-idea-snapshot is set, then the test runs against a locally installed snapshot version (./gradlew install) */
val isSnapshotTest = project.providers.gradleProperty("kotlin-gradle-plugin-idea.snapshot").isPresent
repositories { repositories {
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev") maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
if (isSnapshotTest) mavenLocal() if (isSnapshotTest) mavenLocal()
} }
/* Setup for backwards compatibility test */
val version = if (isSnapshotTest) properties["defaultSnapshotVersion"].toString() val version = if (isSnapshotTest) properties["defaultSnapshotVersion"].toString()
else BackwardsCompatibilityTestConfiguration.minimalBackwardsCompatibleVersion else BackwardsCompatibilityTestConfiguration.minimalBackwardsCompatibleVersion
@@ -41,12 +41,16 @@ tasks.test {
minimalBackwardsCompatibleVersionTestClasspath("org.jetbrains.kotlin:kotlin-gradle-plugin-idea:$version") minimalBackwardsCompatibleVersionTestClasspath("org.jetbrains.kotlin:kotlin-gradle-plugin-idea:$version")
} }
dependsOn(minimalBackwardsCompatibleVersionTestClasspath) tasks.test {
inputs.files(minimalBackwardsCompatibleVersionTestClasspath)
doFirst {
if (isSnapshotTest) logger.quiet("Running test against snapshot: $version")
else logger.quiet("Running test against $version")
doFirst { systemProperty(
systemProperty( "backwardsCompatibilityClasspath",
"backwardsCompatibilityClasspath", minimalBackwardsCompatibleVersionTestClasspath.files.joinToString(";") { it.absolutePath }
minimalBackwardsCompatibleVersionTestClasspath.files.joinToString(";") { it.absolutePath } )
) }
} }
} }