Skip to content

Commit

Permalink
Try using Provider.map instead of Provider.get to resolve `org.gr…
Browse files Browse the repository at this point in the history
…adle.api.internal.provider.MissingValueException` in projects in the Dokka convention plugins
  • Loading branch information
ShreckYe committed Nov 7, 2024
1 parent bd03cb8 commit d49964b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ plugins {
id("com.huanshankeji.dokka.dokka-convention")
}

val extension = extensions.create<GithubDokkaConventionExtension>("githubDokkaConvention")

interface GithubDokkaConventionExtension {
val repositoryName: Property<String>
val commitOrTag: Property<String>
}

dokkaConvention {
val repositoryUrl = githubRepositoryUrl(extension.repositoryName.getOrElse(defaultRepositoryName()))
val commitOrTag = extension.commitOrTag.getOrElse("v${version}")
sourceLinkRemoteUrlRoot.set("$repositoryUrl/blob/$commitOrTag")
extensions.create<GithubDokkaConventionExtension>("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")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down

0 comments on commit d49964b

Please sign in to comment.