Skip to content

Commit

Permalink
Handle missing artifacts in javadoc task
Browse files Browse the repository at this point in the history
  • Loading branch information
pantherdd committed Sep 15, 2023
1 parent 5c1cff0 commit 194d331
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,14 @@ tasks.javadoc {
.withArtifacts(JvmLibrary::class, JavadocArtifact::class)
.execute()
compileJavadocs.resolvedComponents.mapNotNull { component ->
val javadocArtifact = component.getArtifacts(JavadocArtifact::class).single() as ResolvedArtifactResult
val javadocJarTree = zipTree(javadocArtifact.file)
val javadocDescriptor = descriptorFileNames.mapNotNull { fileName ->
javadocJarTree.matching { include(fileName) }.singleOrNull()
}.firstOrNull()
val javadocArtifact =
component.getArtifacts(JavadocArtifact::class).singleOrNull() as ResolvedArtifactResult?
val javadocDescriptor = javadocArtifact?.let { artifact ->
val javadocJarTree = zipTree(artifact.file)
descriptorFileNames.firstNotNullOfOrNull { fileName ->
javadocJarTree.matching { include(fileName) }.singleOrNull()
}
}
javadocDescriptor?.let { file ->
val id = component.id as ModuleComponentIdentifier
OfflineLink(file.parentFile, uri("https://javadoc.io/doc/${id.group}/${id.module}/${id.version}/"))
Expand Down

0 comments on commit 194d331

Please sign in to comment.