aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-plugin
diff options
context:
space:
mode:
Diffstat (limited to 'runners/gradle-plugin')
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinCompilationUtils.kt34
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt6
2 files changed, 27 insertions, 13 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinCompilationUtils.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinCompilationUtils.kt
index fdb4642c..1d06e608 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinCompilationUtils.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/kotlin/kotlinCompilationUtils.kt
@@ -10,26 +10,36 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
internal typealias KotlinCompilation =
org.jetbrains.kotlin.gradle.plugin.KotlinCompilation<KotlinCommonOptions>
+internal fun Project.compilationsOf(sourceSet: KotlinSourceSet): List<KotlinCompilation> {
+ //KT-45412 Make sure .kotlinSourceSets and .allKotlinSourceSets include the default source set
+ return allCompilationsOf(sourceSet).filter { compilation ->
+ sourceSet in compilation.kotlinSourceSets || sourceSet == compilation.defaultSourceSet
+ }
+}
+
internal fun Project.allCompilationsOf(
sourceSet: KotlinSourceSet
): List<KotlinCompilation> {
return when (val kotlin = kotlin) {
- is KotlinMultiplatformExtension -> kotlin.allCompilationsOf(sourceSet)
- is KotlinSingleTargetExtension -> kotlin.allCompilationsOf(sourceSet)
+ is KotlinMultiplatformExtension -> allCompilationsOf(kotlin, sourceSet)
+ is KotlinSingleTargetExtension<*> -> allCompilationsOf(kotlin, sourceSet)
else -> emptyList()
}
}
-internal fun Project.compilationsOf(sourceSet: KotlinSourceSet): List<KotlinCompilation> {
- //KT-45412 Make sure .kotlinSourceSets and .allKotlinSourceSets include the default source set
- return allCompilationsOf(sourceSet).filter { compilation -> sourceSet in compilation.kotlinSourceSets || sourceSet == compilation.defaultSourceSet }
-}
-
-private fun KotlinMultiplatformExtension.allCompilationsOf(sourceSet: KotlinSourceSet): List<KotlinCompilation> {
- val allCompilations = targets.flatMap { target -> target.compilations }
- return allCompilations.filter { compilation -> sourceSet in compilation.allKotlinSourceSets || sourceSet == compilation.defaultSourceSet }
+private fun allCompilationsOf(
+ kotlin: KotlinMultiplatformExtension,
+ sourceSet: KotlinSourceSet
+): List<KotlinCompilation> {
+ val allCompilations = kotlin.targets.flatMap { target -> target.compilations }
+ return allCompilations.filter { compilation ->
+ sourceSet in compilation.allKotlinSourceSets || sourceSet == compilation.defaultSourceSet
+ }
}
-private fun KotlinSingleTargetExtension.allCompilationsOf(sourceSet: KotlinSourceSet): List<KotlinCompilation> {
- return target.compilations.filter { compilation -> sourceSet in compilation.allKotlinSourceSets }
+private fun allCompilationsOf(
+ kotlin: KotlinSingleTargetExtension<*>,
+ sourceSet: KotlinSourceSet
+): List<KotlinCompilation> {
+ return kotlin.target.compilations.filter { compilation -> sourceSet in compilation.allKotlinSourceSets }
}
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt
index 770d1af3..9babeefd 100644
--- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt
@@ -113,7 +113,7 @@ class GradleDokkaSourceSetBuilderTest {
sourceSet.dependsOn(sourceSet.DokkaSourceSetID("s3"))
sourceSet.dependsOn(GradleDokkaSourceSetBuilder("s4", project))
sourceSet.dependsOn(GradleDokkaSourceSetBuilder("s5", project).build())
- sourceSet.dependsOn(DefaultKotlinSourceSet(project, "s6"))
+ sourceSet.dependsOn(createDefaultKotlinSourceSet("s6"))
sourceSet.dependsOn(DefaultAndroidSourceSet("s7", project, false))
assertEquals(
@@ -123,6 +123,10 @@ class GradleDokkaSourceSetBuilderTest {
)
}
+ private fun createDefaultKotlinSourceSet(displayName: String): DefaultKotlinSourceSet {
+ return project.objects.newInstance(DefaultKotlinSourceSet::class.java, project, displayName)
+ }
+
@Test
fun samples() {
val sourceSet = GradleDokkaSourceSetBuilder("", project)