File tree Expand file tree Collapse file tree
build-logic/convention/src/main/kotlin/com/autonomousapps/convention
testkit/gradle-testkit-plugin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,11 +70,13 @@ public abstract class DagpExtension(
7070 }
7171
7272 project.tasks.named(" publishToMavenCentral" ) { t ->
73+ val key = " is-snapshot"
7374 t.notCompatibleWithConfigurationCache(" Cannot serialize object of type DefaultProject" )
74- t.inputs.property(" is-snapshot " , isSnapshot)
75+ t.inputs.property(key , isSnapshot)
7576
7677 t.doLast {
77- if (isSnapshot.get()) {
78+ @Suppress(" UNCHECKED_CAST" )
79+ if ((t.inputs.properties[key] as Provider <Boolean >).get()) {
7880 t.logger.quiet(" Browse files at https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/com/autonomousapps/" )
7981 } else {
8082 t.logger.quiet(
Original file line number Diff line number Diff line change 33package com.autonomousapps.convention
44
55import com.autonomousapps.convention.internal.kotlin.KotlinConfigurer
6+ import com.gradle.publish.PublishTask
67import com.vanniktech.maven.publish.GradlePublishPlugin
78import com.vanniktech.maven.publish.MavenPublishBaseExtension
89import org.gradle.api.Plugin
@@ -28,6 +29,9 @@ public abstract class PluginConventionPlugin : Plugin<Project> {
2829 configureKotlin()
2930 configurePlugins()
3031 configurePublishing()
32+
33+ // TODO(tsr): figure out this CC issue.
34+ // disableConfigurationCache()
3135 }
3236
3337 private fun Project.configureGroovy (versionCatalog : VersionCatalog ) {
@@ -58,4 +62,13 @@ public abstract class PluginConventionPlugin : Plugin<Project> {
5862 configure(GradlePublishPlugin ())
5963 }
6064 }
65+
66+ private fun Project.disableConfigurationCache () {
67+ tasks.withType(PublishTask ::class .java).configureEach { t ->
68+ t.notCompatibleWithConfigurationCache(" cannot serialize Gradle script object references as these are not supported with the configuration cache." )
69+ }
70+ // tasks.withType(org.gradle.api.publish.maven.tasks.AbstractPublishToMaven::class.java) { t ->
71+ // t.notCompatibleWithConfigurationCache("Various problems")
72+ // }
73+ }
6174}
Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ version = VERSION
1818val isSnapshot: Boolean = project.version.toString().endsWith(" SNAPSHOT" )
1919val isRelease: Boolean = ! isSnapshot
2020
21+ class IsReleaseSpec (private val isRelease : Boolean ) : Spec<Task> {
22+ override fun isSatisfiedBy (element : Task ): Boolean {
23+ return isRelease
24+ }
25+ }
26+
2127dagp {
2228 version(version)
2329 pom {
@@ -319,8 +325,9 @@ val publishToMavenCentral = tasks.named("publishToMavenCentral") {
319325}
320326
321327val publishToPluginPortal = tasks.named(" publishPlugins" ) {
328+ val spec = IsReleaseSpec (isRelease)
322329 // Can't publish snapshots to the portal
323- onlyIf(" only publish releases to the plugin portal" ) { isRelease }
330+ onlyIf(" only publish releases to the plugin portal" , spec)
324331 shouldRunAfter(publishToMavenCentral)
325332
326333 configureForRelease()
Original file line number Diff line number Diff line change 11import org.gradle.kotlin.dsl.assign
22import org.gradle.plugin.compatibility.compatibility
3+ import org.jetbrains.kotlin.gradle.plugin.extraProperties
34
45// Copyright (c) 2026. Tony Robalik.
56// SPDX-License-Identifier: Apache-2.0
@@ -12,6 +13,12 @@ version = "0.19-SNAPSHOT"
1213val isSnapshot: Boolean = version.toString().endsWith(" SNAPSHOT" )
1314val isRelease: Boolean = ! isSnapshot
1415
16+ class IsReleaseSpec (private val isRelease : Boolean ) : Spec<Task> {
17+ override fun isSatisfiedBy (element : Task ): Boolean {
18+ return isRelease
19+ }
20+ }
21+
1522dagp {
1623 version(version)
1724 pom {
@@ -80,8 +87,9 @@ val publishToMavenCentral = tasks.named("publishToMavenCentral") {
8087}
8188
8289val publishToPluginPortal = tasks.named(" publishPlugins" ) {
90+ val spec = IsReleaseSpec (isRelease)
8391 // Can't publish snapshots to the portal
84- onlyIf { isRelease }
92+ onlyIf( " Is not a snapshot " , spec)
8593 shouldRunAfter(publishToMavenCentral)
8694
8795 // Note that publishing a release requires a successful smokeTest
You can’t perform that action at this time.
0 commit comments