Skip to content

Commit

Permalink
Update tested versions (#592)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Niklas Baudy <[email protected]>
  • Loading branch information
gabrielittner and vanniktech authored Jun 22, 2023
1 parent 0e0df29 commit 4c10159
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ fun ProjectSpec.run(fixtures: Path, temp: Path, options: TestOptions): ProjectRe
}

private fun TestOptions.supportsConfigCaching(plugins: List<PluginSpec>): 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 }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand All @@ -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) {
Expand All @@ -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 {
Expand Down
39 changes: 29 additions & 10 deletions plugin/src/main/kotlin/com/vanniktech/maven/publish/Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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<JvmModelingServices>()
val variant = "testFixtures"
val action = Action<JvmVariantBuilder> {
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<JvmPluginServices>()
val action = Action<Any> {
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)
}
}

Expand Down

0 comments on commit 4c10159

Please sign in to comment.