From 334619d42d3c26379429ea8cdab13b28c87c159e Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Tue, 11 Aug 2020 14:10:37 +0200 Subject: Refine and test `GradleSourceLinkBuilder` and SourceLinkDefinition API --- .../dokka/gradle/GradleSourceLinkBuilder.kt | 16 +++++----- .../gradle/GradleDokkaSourceSetBuilderTest.kt | 36 +++++++++++----------- 2 files changed, 27 insertions(+), 25 deletions(-) (limited to 'runners/gradle-plugin') diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt index 54700fe9..89ecb5e7 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleSourceLinkBuilder.kt @@ -7,27 +7,29 @@ import org.gradle.api.tasks.Internal import org.gradle.api.tasks.Optional import org.jetbrains.dokka.DokkaConfigurationBuilder import org.jetbrains.dokka.SourceLinkDefinitionImpl +import java.io.File class GradleSourceLinkBuilder( @Transient @get:Internal internal val project: Project ) : DokkaConfigurationBuilder { + @Input - val path: Property = project.objects.safeProperty() - .safeConvention("") + val localDirectory: Property = project.objects.safeProperty() @Input - val url: Property = project.objects.safeProperty() + val remoteUrl: Property = project.objects.safeProperty() .safeConvention("") @Optional @Input - val lineSuffix: Property = project.objects.safeProperty() + val remoteLineSuffix: Property = project.objects.safeProperty() + .safeConvention("#L") override fun build(): SourceLinkDefinitionImpl { return SourceLinkDefinitionImpl( - path = path.getSafe(), - url = url.getSafe(), - lineSuffix = lineSuffix.getSafe() + localDirectory = localDirectory.getSafe()?.absolutePath ?: project.projectDir.absolutePath, + remoteUrl = remoteUrl.getSafe(), + remoteLineSuffix = remoteLineSuffix.getSafe() ) } } 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 26d02fe0..4ab644e7 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 @@ -219,39 +219,39 @@ class GradleDokkaSourceSetBuilderTest { sourceSet.sourceLinks.add( GradleSourceLinkBuilder(project).apply { - this.lineSuffix by "ls1" - this.path by "p1" - this.url by "u1" + this.remoteLineSuffix by "ls1" + this.localDirectory by project.file("p1") + this.remoteUrl by "u1" }) sourceSet.sourceLink { - it.lineSuffix by "ls2" - it.path by "p2" - it.url by "u2" + it.remoteLineSuffix by "ls2" + it.localDirectory by project.file("p2") + it.remoteUrl by "u2" } sourceSet.sourceLink(project.closureOf { - this.lineSuffix by "ls3" - this.path by "p3" - this.url by "u3" + this.remoteLineSuffix by "ls3" + this.localDirectory by project.file("p3") + this.remoteUrl by "u3" }) assertEquals( setOf( SourceLinkDefinitionImpl( - lineSuffix = "ls1", - path = "p1", - url = "u1" + remoteLineSuffix = "ls1", + localDirectory = project.file("p1").absolutePath, + remoteUrl = "u1" ), SourceLinkDefinitionImpl( - lineSuffix = "ls2", - path = "p2", - url = "u2" + remoteLineSuffix = "ls2", + localDirectory = project.file("p2").absolutePath, + remoteUrl = "u2" ), SourceLinkDefinitionImpl( - lineSuffix = "ls3", - path = "p3", - url = "u3" + remoteLineSuffix = "ls3", + localDirectory = project.file("p3").absolutePath, + remoteUrl = "u3" ) ), sourceSet.build().sourceLinks, -- cgit