Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register javadoc and sources after evaluating project #45

Merged
merged 6 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build-and-publish:
name: Java Gradle
uses: bakdata/ci-templates/.github/workflows/java-gradle-plugin.yaml@1.40.8
uses: bakdata/ci-templates/.github/workflows/java-gradle-plugin.yaml@1.41.0
secrets:
sonar-token: ${{ secrets.SONARCLOUD_TOKEN }}
sonar-organization: ${{ secrets.SONARCLOUD_ORGANIZATION }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
jobs:
java-gradle-release:
name: Java Gradle
uses: bakdata/ci-templates/.github/workflows/java-gradle-release.yaml@1.40.8
uses: bakdata/ci-templates/.github/workflows/java-gradle-release.yaml@1.41.0
with:
release-type: "${{ inputs.release-type }}"

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id("net.researchgate.release") version "3.0.2"
// eat your own dog food - apply the plugins to this plugin project
id("com.bakdata.sonar") version "1.1.17"
id("com.bakdata.sonatype") version "1.1.18"
id("com.bakdata.sonatype") version "1.2.1"
id("org.hildan.github.changelog") version "1.13.1"
id("org.gradle.kotlin.kotlin-dsl") version "2.1.6" apply false
id("com.gradle.plugin-publish") version "1.2.1" apply false
Expand Down
28 changes: 17 additions & 11 deletions sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

package com.bakdata.gradle

import io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository
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.UnknownTaskException
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 All @@ -38,7 +38,7 @@ import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
import org.gradle.api.publish.maven.tasks.GenerateMavenPom
import org.gradle.api.publish.maven.tasks.PublishToMavenLocal
import org.gradle.api.publish.plugins.PublishingPlugin
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.Sign
Expand Down Expand Up @@ -220,16 +220,22 @@ class SonatypePlugin : Plugin<Project> {
apply(plugin = "signing")
apply(plugin = "org.gradle.maven-publish")

tasks.findByName("dokka")?.apply {
tasks.creating(Jar::class) {
archiveClassifier.set("javadoc")
from(this)
// 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)
}
}
}

configure<JavaPluginExtension> {
withSourcesJar()
withJavadocJar()
configure<JavaPluginExtension> {
withSourcesJar()
withJavadocJar()
}
}

configure<PublishingExtension> {
Expand Down
Loading