diff --git a/huanshankeji-team-gradle-plugins/src/main/kotlin/com/huanshankeji/team/dokka/github-dokka-convention.gradle.kts b/huanshankeji-team-gradle-plugins/src/main/kotlin/com/huanshankeji/team/dokka/github-dokka-convention.gradle.kts index 4c050ef..33a7b7c 100644 --- a/huanshankeji-team-gradle-plugins/src/main/kotlin/com/huanshankeji/team/dokka/github-dokka-convention.gradle.kts +++ b/huanshankeji-team-gradle-plugins/src/main/kotlin/com/huanshankeji/team/dokka/github-dokka-convention.gradle.kts @@ -7,15 +7,21 @@ plugins { id("com.huanshankeji.dokka.dokka-convention") } -val extension = extensions.create("githubDokkaConvention") - interface GithubDokkaConventionExtension { val repositoryName: Property val commitOrTag: Property } -dokkaConvention { - val repositoryUrl = githubRepositoryUrl(extension.repositoryName.getOrElse(defaultRepositoryName())) - val commitOrTag = extension.commitOrTag.getOrElse("v${version}") - sourceLinkRemoteUrlRoot.set("$repositoryUrl/blob/$commitOrTag") +extensions.create("githubDokkaConvention").apply { + repositoryName.convention(defaultRepositoryName()) + commitOrTag.convention("v${version}") + + dokkaConvention { + repositoryName.map { repositoryName -> + val repositoryUrl = githubRepositoryUrl(repositoryName) + commitOrTag.map { commitOrTag -> + sourceLinkRemoteUrlRoot.set("$repositoryUrl/blob/$commitOrTag") + } + } + } } diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/dokka/dokka-convention.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/dokka/dokka-convention.gradle.kts index 453a129..e98697e 100644 --- a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/dokka/dokka-convention.gradle.kts +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/dokka/dokka-convention.gradle.kts @@ -14,7 +14,7 @@ dokka { dokkaSourceSets.all { sourceLink { val projectRelativePath = projectDir.relativeTo(rootProject.projectDir) - remoteUrl("${extension.sourceLinkRemoteUrlRoot.get()}/$projectRelativePath") + extension.sourceLinkRemoteUrlRoot.map { remoteUrl("$it/$projectRelativePath") } remoteLineSuffix.set("#L") } }