Skip to content

Commit

Permalink
Register javadoc and sources after evaluating project
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp94831 committed Feb 28, 2024
1 parent 7b43112 commit ceec5f9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import io.github.gradlenexus.publishplugin.NexusPublishExtension
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.attributes.DocsType.JAVADOC
import org.gradle.api.logging.Logging
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.publish.PublishingExtension
Expand Down Expand Up @@ -220,10 +222,14 @@ class SonatypePlugin : Plugin<Project> {

// Java and Dokka plugins might not have been applied yet
project.afterEvaluate {
val main: SourceSet = the<JavaPluginExtension>().sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)
tasks.create<Jar>(main.javadocJarTaskName) {
archiveClassifier.set("javadoc")
from(tasks.findByName("javadoc") ?: tasks.findByName("dokka"))
tasks.findByName("dokka")?.apply {
val javadocTask: Task = this
val main: SourceSet =
the<JavaPluginExtension>().sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)
tasks.create<Jar>(main.javadocJarTaskName) {
archiveClassifier.set(JAVADOC)
from(javadocTask)
}
}

configure<JavaPluginExtension> {
Expand Down

0 comments on commit ceec5f9

Please sign in to comment.