From 4c1015990524fbedd49d0d6f7660910bbe6cefb9 Mon Sep 17 00:00:00 2001 From: Gabriel Ittner Date: Fri, 23 Jun 2023 00:10:46 +0200 Subject: [PATCH] Update tested versions (#592) * update tested versions * adjustments * update test fixture workaround * ktlint * Update plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt Co-authored-by: Niklas Baudy --------- Co-authored-by: Niklas Baudy --- .../publish/MavenPublishPluginPlatformTest.kt | 48 ++++++++++++++----- .../MavenPublishPluginSpecialCaseTest.kt | 38 +++++++++++---- .../com/vanniktech/maven/publish/Pom.kt | 1 + .../maven/publish/ProjectSpecRunner.kt | 13 ++--- .../vanniktech/maven/publish/TestOptions.kt | 16 +++++-- .../com/vanniktech/maven/publish/Platform.kt | 39 +++++++++++---- 6 files changed, 113 insertions(+), 42 deletions(-) diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginPlatformTest.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginPlatformTest.kt index 031df32a..81dade98 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginPlatformTest.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginPlatformTest.kt @@ -287,7 +287,15 @@ class MavenPublishPluginPlatformTest { assertThat(result).artifact("klib").isSigned() assertThat(result).pom().exists() assertThat(result).pom().isSigned() - assertThat(result).pom().matchesExpectedPom("klib", kotlinStdlibJs(kotlinVersion)) + if (kotlinVersion >= KotlinVersion.KT_1_9_0) { + assertThat(result).pom().matchesExpectedPom( + "klib", + kotlinStdlibJs(kotlinVersion), + kotlinDomApi(kotlinVersion), + ) + } else { + assertThat(result).pom().matchesExpectedPom("klib", kotlinStdlibJs(kotlinVersion)) + } assertThat(result).module().exists() assertThat(result).module().isSigned() assertThat(result).sourcesJar().exists() @@ -366,11 +374,20 @@ class MavenPublishPluginPlatformTest { assertThat(nodejsResult).artifact("klib").isSigned() assertThat(nodejsResult).pom().exists() assertThat(nodejsResult).pom().isSigned() - assertThat(nodejsResult).pom().matchesExpectedPom( - "klib", - kotlinStdlibJs(kotlinVersion), - kotlinStdlibCommon(kotlinVersion), - ) + if (kotlinVersion >= KotlinVersion.KT_1_9_0) { + assertThat(nodejsResult).pom().matchesExpectedPom( + "klib", + kotlinStdlibJs(kotlinVersion), + kotlinDomApi(kotlinVersion), + kotlinStdlibCommon(kotlinVersion), + ) + } else { + assertThat(nodejsResult).pom().matchesExpectedPom( + "klib", + kotlinStdlibJs(kotlinVersion), + kotlinStdlibCommon(kotlinVersion), + ) + } assertThat(nodejsResult).module().exists() assertThat(nodejsResult).module().isSigned() assertThat(nodejsResult).sourcesJar().exists() @@ -452,11 +469,20 @@ class MavenPublishPluginPlatformTest { assertThat(nodejsResult).artifact("klib").isSigned() assertThat(nodejsResult).pom().exists() assertThat(nodejsResult).pom().isSigned() - assertThat(nodejsResult).pom().matchesExpectedPom( - "klib", - kotlinStdlibJs(kotlinVersion), - kotlinStdlibCommon(kotlinVersion), - ) + if (kotlinVersion >= KotlinVersion.KT_1_9_0) { + assertThat(nodejsResult).pom().matchesExpectedPom( + "klib", + kotlinStdlibJs(kotlinVersion), + kotlinDomApi(kotlinVersion), + kotlinStdlibCommon(kotlinVersion), + ) + } else { + assertThat(nodejsResult).pom().matchesExpectedPom( + "klib", + kotlinStdlibJs(kotlinVersion), + kotlinStdlibCommon(kotlinVersion), + ) + } assertThat(nodejsResult).module().exists() assertThat(nodejsResult).module().isSigned() assertThat(nodejsResult).sourcesJar().exists() diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginSpecialCaseTest.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginSpecialCaseTest.kt index b1e7d414..98b01f19 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginSpecialCaseTest.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginSpecialCaseTest.kt @@ -76,11 +76,20 @@ class MavenPublishPluginSpecialCaseTest { assertThat(nodejsResult).outcome().succeeded() assertThat(nodejsResult).artifact("klib").exists() assertThat(nodejsResult).pom().exists() - assertThat(nodejsResult).pom().matchesExpectedPom( - "klib", - kotlinStdlibJs(kotlinVersion), - kotlinStdlibCommon(kotlinVersion), - ) + if (kotlinVersion >= KotlinVersion.KT_1_9_0) { + assertThat(nodejsResult).pom().matchesExpectedPom( + "klib", + kotlinStdlibJs(kotlinVersion), + kotlinDomApi(kotlinVersion), + kotlinStdlibCommon(kotlinVersion), + ) + } else { + assertThat(nodejsResult).pom().matchesExpectedPom( + "klib", + kotlinStdlibJs(kotlinVersion), + kotlinStdlibCommon(kotlinVersion), + ) + } assertThat(nodejsResult).module().exists() assertThat(nodejsResult).sourcesJar().exists() assertThat(nodejsResult).sourcesJar().containsSourceSetFiles("commonMain", "nodeJsMain") @@ -142,11 +151,20 @@ class MavenPublishPluginSpecialCaseTest { assertThat(nodejsResult).outcome().succeeded() assertThat(nodejsResult).artifact("klib").exists() assertThat(nodejsResult).pom().exists() - assertThat(nodejsResult).pom().matchesExpectedPom( - "klib", - kotlinStdlibJs(kotlinVersion), - kotlinStdlibCommon(kotlinVersion), - ) + if (kotlinVersion >= KotlinVersion.KT_1_9_0) { + assertThat(nodejsResult).pom().matchesExpectedPom( + "klib", + kotlinStdlibJs(kotlinVersion), + kotlinDomApi(kotlinVersion), + kotlinStdlibCommon(kotlinVersion), + ) + } else { + assertThat(nodejsResult).pom().matchesExpectedPom( + "klib", + kotlinStdlibJs(kotlinVersion), + kotlinStdlibCommon(kotlinVersion), + ) + } assertThat(nodejsResult).module().exists() assertThat(nodejsResult).sourcesJar().exists() assertThat(nodejsResult).sourcesJar().containsSourceSetFiles("commonMain", "nodeJsMain") diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/Pom.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/Pom.kt index 1b4127b5..a41bbb6c 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/Pom.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/Pom.kt @@ -18,6 +18,7 @@ data class PomDependency( fun kotlinStdlibCommon(version: KotlinVersion) = PomDependency("org.jetbrains.kotlin", "kotlin-stdlib-common", version.value, "compile") fun kotlinStdlibJdk(version: KotlinVersion) = PomDependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk8", version.value, "compile") fun kotlinStdlibJs(version: KotlinVersion) = PomDependency("org.jetbrains.kotlin", "kotlin-stdlib-js", version.value, "compile") +fun kotlinDomApi(version: KotlinVersion) = PomDependency("org.jetbrains.kotlin", "kotlin-dom-api-compat", version.value, "compile") fun createPom( groupId: String, diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt index ba39f836..bcab1d47 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt @@ -40,12 +40,13 @@ fun ProjectSpec.run(fixtures: Path, temp: Path, options: TestOptions): ProjectRe } private fun TestOptions.supportsConfigCaching(plugins: List): Boolean { - // TODO: Kotlin Multiplatform plugin has configuration cache issues - // - https://youtrack.jetbrains.com/issue/KT-49933 (meta ticket) - // - https://youtrack.jetbrains.com/issue/KT-43293 (closed but still has issues) - // - https://youtrack.jetbrains.com/issue/KT-55051 - if (plugins.any { it.id == kotlinMultiplatformPlugin.id }) { - return false + // Kotlin MPP supports config cache since 1.9.0 + val multiplatform = plugins.find { it.id == kotlinMultiplatformPlugin.id } + if (multiplatform != null) { + val parts = multiplatform.version!!.split(".") + if (parts[0].toInt() == 1 && parts[1].toInt() < 9) { + return false + } } // TODO https://github.com/Kotlin/dokka/issues/2231 if (plugins.any { it.id == dokkaPlugin.id }) { diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/TestOptions.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/TestOptions.kt index 547ad41a..8411df12 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/TestOptions.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/TestOptions.kt @@ -33,21 +33,21 @@ enum class AgpVersion( // stable AGP_8_0( - value = "8.0.1", + value = "8.0.2", minGradleVersion = GradleVersion.GRADLE_8_0, minJdkVersion = JavaVersion.VERSION_17, ), // beta channel AGP_8_1( - value = "8.1.0-beta03", - minGradleVersion = GradleVersion.GRADLE_8_0, + value = "8.1.0-beta05", + minGradleVersion = GradleVersion.GRADLE_8_1, minJdkVersion = JavaVersion.VERSION_17, ), // canary channel AGP_8_2( - value = "8.2.0-alpha04", + value = "8.2.0-alpha09", minGradleVersion = GradleVersion.GRADLE_8_1, minJdkVersion = JavaVersion.VERSION_17, ), @@ -58,7 +58,10 @@ enum class KotlinVersion(val value: String) { KT_1_7_0("1.7.0"), // stable - KT_1_8_20("1.8.21"), + KT_1_8_20("1.8.22"), + + // eap + KT_1_9_0("1.9.0-RC"), } enum class GradleVersion(val value: String) { @@ -67,6 +70,9 @@ enum class GradleVersion(val value: String) { // stable GRADLE_8_1("8.1.1"), + + // preview + GRADLE_8_2("8.2-rc-2"), ; companion object { diff --git a/plugin/src/main/kotlin/com/vanniktech/maven/publish/Platform.kt b/plugin/src/main/kotlin/com/vanniktech/maven/publish/Platform.kt index 3144c869..fbd0a5a0 100644 --- a/plugin/src/main/kotlin/com/vanniktech/maven/publish/Platform.kt +++ b/plugin/src/main/kotlin/com/vanniktech/maven/publish/Platform.kt @@ -4,13 +4,19 @@ import com.android.build.api.dsl.LibraryExtension import com.vanniktech.maven.publish.tasks.JavadocJar.Companion.javadocJarTask import org.gradle.api.Action import org.gradle.api.Project +import org.gradle.api.attributes.DocsType +import org.gradle.api.internal.project.ProjectInternal import org.gradle.api.plugins.JavaPluginExtension -import org.gradle.api.plugins.jvm.internal.JvmModelingServices -import org.gradle.api.plugins.jvm.internal.JvmVariantBuilder +import org.gradle.api.plugins.internal.JavaConfigurationVariantMapping +import org.gradle.api.plugins.internal.JavaPluginHelper +import org.gradle.api.plugins.internal.JvmPluginsHelper +import org.gradle.api.plugins.jvm.internal.JvmPluginServices import org.gradle.api.provider.Provider import org.gradle.api.publish.maven.MavenPublication import org.gradle.api.tasks.TaskProvider import org.gradle.configurationcache.extensions.serviceOf +import org.gradle.internal.component.external.model.ProjectDerivedCapability +import org.gradle.jvm.component.internal.DefaultJvmSoftwareComponent import org.gradle.jvm.tasks.Jar import org.gradle.util.GradleVersion @@ -492,18 +498,31 @@ private fun setupTestFixtures(project: Project, sourcesJar: Boolean) { project.plugins.withId("java-test-fixtures") { if (sourcesJar) { // TODO: remove after https://github.com/gradle/gradle/issues/20539 is resolved - val services = project.serviceOf() - val variant = "testFixtures" - val action = Action { - it.withSourcesJar().published() - } + val testFixtureSourceSetName = "testFixtures" if (GradleVersion.current() >= GradleVersion.version("8.1")) { val extension = project.extensions.getByType(JavaPluginExtension::class.java) - val testFixturesSourceSet = extension.sourceSets.maybeCreate(variant) - services.createJvmVariant(variant, testFixturesSourceSet, action) + val testFixturesSourceSet = extension.sourceSets.maybeCreate(testFixtureSourceSetName) + + val sourceElements = JvmPluginsHelper.createDocumentationVariantWithArtifact( + testFixturesSourceSet.sourcesElementsConfigurationName, + testFixtureSourceSetName, + DocsType.SOURCES, + listOf(ProjectDerivedCapability(project, "testFixtures")), + testFixturesSourceSet.sourcesJarTaskName, + testFixturesSourceSet.allSource, + project as ProjectInternal, + ) + + val component = JavaPluginHelper.getJavaComponent(project) as DefaultJvmSoftwareComponent + component.addVariantsFromConfiguration(sourceElements, JavaConfigurationVariantMapping("compile", true)) } else { + val services = project.serviceOf() + val action = Action { + it.javaClass.getMethod("withSourcesJar").invoke(it) + it.javaClass.getMethod("published").invoke(it) + } val method = services.javaClass.getMethod("createJvmVariant", String::class.java, Action::class.java) - method.invoke(services, variant, action) + method.invoke(services, testFixtureSourceSetName, action) } }