diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index d49b4c45335..8233534b507 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -20,6 +20,7 @@ + diff --git a/libraries/tools/kotlin-gradle-plugin-idea/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-idea/build.gradle.kts index 0151a19a3c3..ce9784d0950 100644 --- a/libraries/tools/kotlin-gradle-plugin-idea/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-idea/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `java-test-fixtures` + `maven-publish` } object BackwardsCompatibilityTestConfiguration { @@ -29,10 +30,28 @@ dependencies { testFixturesImplementation(project(":kotlin-test:kotlin-test-junit")) } +repositories { + mavenLocal() +} + publish() javadocJar() sourcesJar() +//region Setup: Backwards compatibility tests + +/* +A special publication is necessary for later downloading such artifact from within this module. +If we wanted to download a publication with the same coordinates, Gradle would always rewrite +the dependency to a local project dependency (knowing, that the coodriantes belong to this project) + */ +publishing { + publications.create("for-compatibility-tests") { + artifactId = "kotlin-gradle-plugin-idea-for-compatibility-tests" + artifact(tasks.named("jar")) + } +} + /* Setup Backwards Compatibility Test */ run { /* When -Pkgp-idea-snapshot is set, then the test runs against a locally installed snapshot version (./gradlew install) */ @@ -48,23 +67,31 @@ run { val minimalBackwardsCompatibleVersionTestClasspath by configurations.creating { isCanBeResolved = true isCanBeConsumed = false - attributes { - attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME)) - } } dependencies { - minimalBackwardsCompatibleVersionTestClasspath("org.jetbrains.kotlin:kotlin-gradle-plugin-idea:$version") + minimalBackwardsCompatibleVersionTestClasspath( + "org.jetbrains.kotlin:kotlin-gradle-plugin-idea-for-compatibility-tests:$version" + ) + + minimalBackwardsCompatibleVersionTestClasspath( + "org.jetbrains.kotlin:kotlin-stdlib:$version" + ) } tasks.test { + dependsOnKotlinGradlePluginInstall() inputs.files(minimalBackwardsCompatibleVersionTestClasspath) doFirst { if (isSnapshotTest) logger.quiet("Running test against snapshot: $version") else logger.quiet("Running test against $version") + /* + Perform a check on the resolved classpath to ensure, that indeed the requested version is resolved. + This is a last line of defense against some unexpected Gradle resolution (like back resolving to this original project) + */ val resolvedClasspath = minimalBackwardsCompatibleVersionTestClasspath.files - if (resolvedClasspath.none { "kotlin-gradle-plugin-idea-$version.jar" in it.path }) { + if (resolvedClasspath.none { "kotlin-gradle-plugin-idea-for-compatibility-tests-$version.jar" in it.path }) { throw IllegalStateException(buildString { appendLine("Bad backwardsCompatibilityClasspath: $resolvedClasspath") appendLine("Dependencies:${minimalBackwardsCompatibleVersionTestClasspath.allDependencies.joinToString()}") @@ -78,3 +105,5 @@ run { } } } + +//endregion