Skip to content

Commit c3650fa

Browse files
chore: publishing doesn't trip over configuration cache.
Can only test it during publication.
1 parent 90d3422 commit c3650fa

4 files changed

Lines changed: 33 additions & 12 deletions

File tree

build-logic/convention/src/main/kotlin/com/autonomousapps/convention/DagpExtension.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ public abstract class DagpExtension(
7070
}
7171

7272
project.tasks.named("publishToMavenCentral") { t ->
73-
t.notCompatibleWithConfigurationCache("Cannot serialize object of type DefaultProject")
74-
t.inputs.property("is-snapshot", isSnapshot)
73+
val key = "is-snapshot"
74+
t.inputs.property(key, isSnapshot)
7575

7676
t.doLast {
77-
if (isSnapshot.get()) {
77+
if ((t.inputs.properties[key] as Boolean)) {
7878
t.logger.quiet("Browse files at https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/com/autonomousapps/")
7979
} else {
8080
t.logger.quiet(

build-logic/convention/src/main/kotlin/com/autonomousapps/convention/PluginConventionPlugin.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package com.autonomousapps.convention
44

55
import com.autonomousapps.convention.internal.kotlin.KotlinConfigurer
6+
import com.gradle.publish.PublishTask
67
import com.vanniktech.maven.publish.GradlePublishPlugin
78
import com.vanniktech.maven.publish.MavenPublishBaseExtension
89
import 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
}

build.gradle.kts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import org.gradle.plugin.compatibility.compatibility
2-
31
// Copyright (c) 2026. Tony Robalik.
42
// SPDX-License-Identifier: Apache-2.0
3+
import org.gradle.plugin.compatibility.compatibility
4+
55
plugins {
66
id("build-logic.plugin")
77
id("groovy")
@@ -15,7 +15,7 @@ plugins {
1515
val VERSION: String by project
1616
version = VERSION
1717

18-
val isSnapshot: Boolean = project.version.toString().endsWith("SNAPSHOT")
18+
val isSnapshot: Boolean = version.toString().endsWith("SNAPSHOT")
1919
val isRelease: Boolean = !isSnapshot
2020

2121
dagp {
@@ -319,10 +319,14 @@ val publishToMavenCentral = tasks.named("publishToMavenCentral") {
319319
}
320320

321321
val publishToPluginPortal = tasks.named("publishPlugins") {
322+
val key = "is-release"
323+
inputs.property(key, isRelease)
322324
// Can't publish snapshots to the portal
323-
onlyIf("only publish releases to the plugin portal") { isRelease }
324-
shouldRunAfter(publishToMavenCentral)
325+
onlyIf("only publish releases to the plugin portal") {
326+
inputs.properties[key] as Boolean
327+
}
325328

329+
shouldRunAfter(publishToMavenCentral)
326330
configureForRelease()
327331
}
328332

testkit/gradle-testkit-plugin/build.gradle.kts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import org.gradle.kotlin.dsl.assign
2-
import org.gradle.plugin.compatibility.compatibility
3-
41
// Copyright (c) 2026. Tony Robalik.
52
// SPDX-License-Identifier: Apache-2.0
3+
import org.gradle.plugin.compatibility.compatibility
4+
65
plugins {
76
id("build-logic.plugin")
87
id("com.github.gmazzo.buildconfig")
@@ -80,8 +79,13 @@ val publishToMavenCentral = tasks.named("publishToMavenCentral") {
8079
}
8180

8281
val publishToPluginPortal = tasks.named("publishPlugins") {
82+
val key = "is-release"
83+
inputs.property(key, isRelease)
8384
// Can't publish snapshots to the portal
84-
onlyIf { isRelease }
85+
onlyIf("only publish releases to the plugin portal") {
86+
inputs.properties[key] as Boolean
87+
}
88+
8589
shouldRunAfter(publishToMavenCentral)
8690

8791
// Note that publishing a release requires a successful smokeTest

0 commit comments

Comments
 (0)