Skip to content
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 @@ -70,11 +70,11 @@ public abstract class DagpExtension(
}

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

t.doLast {
if (isSnapshot.get()) {
if ((t.inputs.properties[key] as Boolean)) {
t.logger.quiet("Browse files at https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/com/autonomousapps/")
} else {
t.logger.quiet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package com.autonomousapps.convention

import com.autonomousapps.convention.internal.kotlin.KotlinConfigurer
import com.gradle.publish.PublishTask
import com.vanniktech.maven.publish.GradlePublishPlugin
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import org.gradle.api.Plugin
Expand All @@ -28,6 +29,9 @@ public abstract class PluginConventionPlugin : Plugin<Project> {
configureKotlin()
configurePlugins()
configurePublishing()

// TODO(tsr): figure out this CC issue.
// disableConfigurationCache()
}

private fun Project.configureGroovy(versionCatalog: VersionCatalog) {
Expand Down Expand Up @@ -58,4 +62,13 @@ public abstract class PluginConventionPlugin : Plugin<Project> {
configure(GradlePublishPlugin())
}
}

private fun Project.disableConfigurationCache() {
tasks.withType(PublishTask::class.java).configureEach { t ->
t.notCompatibleWithConfigurationCache("cannot serialize Gradle script object references as these are not supported with the configuration cache.")
}
// tasks.withType(org.gradle.api.publish.maven.tasks.AbstractPublishToMaven::class.java) { t ->
// t.notCompatibleWithConfigurationCache("Various problems")
// }
}
}
14 changes: 9 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.gradle.plugin.compatibility.compatibility

// Copyright (c) 2026. Tony Robalik.
// SPDX-License-Identifier: Apache-2.0
import org.gradle.plugin.compatibility.compatibility

plugins {
id("build-logic.plugin")
id("groovy")
Expand All @@ -15,7 +15,7 @@ plugins {
val VERSION: String by project
version = VERSION

val isSnapshot: Boolean = project.version.toString().endsWith("SNAPSHOT")
val isSnapshot: Boolean = version.toString().endsWith("SNAPSHOT")
val isRelease: Boolean = !isSnapshot

dagp {
Expand Down Expand Up @@ -319,10 +319,14 @@ val publishToMavenCentral = tasks.named("publishToMavenCentral") {
}

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

shouldRunAfter(publishToMavenCentral)
configureForRelease()
}

Expand Down
12 changes: 8 additions & 4 deletions testkit/gradle-testkit-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import org.gradle.kotlin.dsl.assign
import org.gradle.plugin.compatibility.compatibility

// Copyright (c) 2026. Tony Robalik.
// SPDX-License-Identifier: Apache-2.0
import org.gradle.plugin.compatibility.compatibility

plugins {
id("build-logic.plugin")
id("com.github.gmazzo.buildconfig")
Expand Down Expand Up @@ -80,8 +79,13 @@ val publishToMavenCentral = tasks.named("publishToMavenCentral") {
}

val publishToPluginPortal = tasks.named("publishPlugins") {
val key = "is-release"
inputs.property(key, isRelease)
// Can't publish snapshots to the portal
onlyIf { isRelease }
onlyIf("only publish releases to the plugin portal") {
inputs.properties[key] as Boolean
}

shouldRunAfter(publishToMavenCentral)

// Note that publishing a release requires a successful smokeTest
Expand Down
Loading