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

inject BuildEventsListenerRegistry #831

Merged
merged 2 commits into from
Sep 19, 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.vanniktech.maven.publish.sonatype.DropSonatypeRepositoryTask.Companio
import com.vanniktech.maven.publish.sonatype.ReleaseSonatypeRepositoryTask.Companion.registerReleaseRepository
import com.vanniktech.maven.publish.sonatype.SonatypeRepositoryBuildService.Companion.registerSonatypeRepositoryBuildService
import com.vanniktech.maven.publish.tasks.WorkaroundSignatureType
import javax.inject.Inject
import org.gradle.api.Action
import org.gradle.api.Incubating
import org.gradle.api.Project
Expand All @@ -14,15 +15,17 @@ import org.gradle.api.publish.maven.MavenPom
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.build.event.BuildEventsListenerRegistry
import org.gradle.external.javadoc.StandardJavadocDocletOptions
import org.gradle.plugins.signing.Sign
import org.gradle.plugins.signing.SigningPlugin
import org.gradle.plugins.signing.type.pgp.ArmoredSignatureType
import org.gradle.util.GradleVersion
import org.jetbrains.dokka.gradle.DokkaTask

abstract class MavenPublishBaseExtension(
abstract class MavenPublishBaseExtension @Inject constructor(
private val project: Project,
private val buildEventsListenerRegistry: BuildEventsListenerRegistry,
) {
private val sonatypeHost: Property<SonatypeHost> = project.objects.property(SonatypeHost::class.java)
private val signing: Property<Boolean> = project.objects.property(Boolean::class.java)
Expand All @@ -31,7 +34,7 @@ abstract class MavenPublishBaseExtension(
internal val version: Property<String> = project.objects.property(String::class.java)
.convention(project.provider { project.version.toString() })
private val pomFromProperties: Property<Boolean> = project.objects.property(Boolean::class.java)
internal val platform: Property<Platform> = project.objects.property(Platform::class.java)
private val platform: Property<Platform> = project.objects.property(Platform::class.java)

/**
* Sets up Maven Central publishing through Sonatype OSSRH by configuring the target repository. Gradle will then
Expand Down Expand Up @@ -65,6 +68,7 @@ abstract class MavenPublishBaseExtension(
automaticRelease = automaticRelease,
// TODO: stop accessing rootProject https://github.com/gradle/gradle/pull/26635
rootBuildDirectory = project.rootProject.layout.buildDirectory,
buildEventsListenerRegistry = buildEventsListenerRegistry,
)

val configCacheEnabled = project.configurationCache()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.gradle.api.provider.Provider
import org.gradle.api.services.BuildService
import org.gradle.api.services.BuildServiceParameters
import org.gradle.build.event.BuildEventsListenerRegistry
import org.gradle.configurationcache.extensions.serviceOf
import org.gradle.tooling.events.FailureResult
import org.gradle.tooling.events.FinishEvent
import org.gradle.tooling.events.OperationCompletionListener
Expand Down Expand Up @@ -324,6 +323,7 @@ internal abstract class SonatypeRepositoryBuildService :
repositoryPassword: Provider<String>,
automaticRelease: Boolean,
rootBuildDirectory: Provider<Directory>,
buildEventsListenerRegistry: BuildEventsListenerRegistry,
): Provider<SonatypeRepositoryBuildService> {
val okhttpTimeout = project.providers.gradleProperty("SONATYPE_CONNECT_TIMEOUT_SECONDS")
.map { it.toLong() }
Expand All @@ -343,7 +343,7 @@ internal abstract class SonatypeRepositoryBuildService :
it.parameters.closeTimeoutSeconds.set(closeTimeout)
it.parameters.rootBuildDirectory.set(rootBuildDirectory)
}
project.serviceOf<BuildEventsListenerRegistry>().onTaskCompletion(service)
buildEventsListenerRegistry.onTaskCompletion(service)
return service
}
}
Expand Down