Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit 6abef20

Browse files
authored
Remove dependency on deprecated conventions API (#54)
`Project.convention` and other conventions API methods have been deprecated and will be removed in Gradle 9.0. To make things worse, the `Project.convention.plugins["java"]` does not return `DefaultJavaPluginConvention` anymore, but instead returns a wrapper class that issues deprecation warnings. Since the plugin cannot find the expected class, it stopped working properly (this is probably the cause of #53). This pull requests simply replaces the single use of `Project.convention.plugins[]` (finding the Java test sourceset) with `Project.extensions.findByType`. Fixes: #42, #53
1 parent 742bb18 commit 6abef20

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/main/kotlin/io/kotest/gradle/sourcesets.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.kotest.gradle
22

33
import org.gradle.api.Project
44
import org.gradle.api.file.FileCollection
5+
import org.gradle.api.plugins.JavaPluginExtension
56
import org.gradle.api.plugins.internal.DefaultJavaPluginConvention
67
import org.gradle.api.tasks.SourceSet
78
import org.gradle.internal.extensibility.DefaultConvention
@@ -49,11 +50,7 @@ fun Project.mppTestTargets(): Map<KotlinTargetWithTests<*, *>, FileCollection> {
4950
}
5051
}
5152

52-
fun Project.javaTestSourceSet(): SourceSet? {
53-
return when (val java = convention.plugins["java"]) {
54-
is DefaultJavaPluginConvention -> {
55-
java.sourceSets.findByName("test")
56-
}
57-
else -> null
58-
}
59-
}
53+
fun Project.javaTestSourceSet(): SourceSet? =
54+
extensions.findByType(JavaPluginExtension::class.java)
55+
?.sourceSets
56+
?.findByName("test")

0 commit comments

Comments
 (0)