Skip to content

Commit

Permalink
Listen for Java and Dokka plugin setup
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp94831 committed Feb 28, 2024
1 parent 8905e8d commit 5a81264
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ 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.JavaPlugin
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
Expand Down Expand Up @@ -220,18 +221,16 @@ class SonatypePlugin : Plugin<Project> {
apply(plugin = "signing")
apply(plugin = "org.gradle.maven-publish")

// Java and Dokka plugins might not have been applied yet
project.afterEvaluate {
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)
}
project.tasks.matching { it.name == "dokka" }.all {
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)
}
}

project.plugins.matching { it is JavaPlugin }.all {
configure<JavaPluginExtension> {
withSourcesJar()
withJavadocJar()
Expand Down

0 comments on commit 5a81264

Please sign in to comment.