You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by ja...@apache.org on 2026/05/01 16:20:40 UTC

(grails-static-website) 01/01: Drop per-render-task log-cleanup finalizer to satisfy configuration cache (refs #354)

This is an automated email from the ASF dual-hosted git repository.

jamesfredley pushed a commit to branch hotfix-publish-cc-violation
in repository https://gitbox.apache.org/repos/asf/grails-static-website.git

commit 10fdcad24aac695e87b2872c93baba8ef8b34b9a
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Fri May 1 12:20:33 2026 -0400

    Drop per-render-task log-cleanup finalizer to satisfy configuration cache (refs #354)
    
    The finalizer accessed renderTask.extensions and renderTask.logging at execution
    time, which Gradle's configuration cache disallows when a task reaches across
    into another task. The wireLogCapture's doFirst block adds a StandardOutputListener
    that captures asciidoctor output. Removing the listener was the only purpose of
    the finalizer; under --no-daemon (publish.yml) the JVM exits at build end and
    reclaims the listener anyway, so dropping the cleanup is harmless.
    
    Fixes the publishMainSite failure on PR #458 cutover deploy.
    
    Assisted-by: claude-code:claude-4.6-opus
---
 .../gradle/tasks/AsciidoctorWarningGateTask.groovy | 36 ++++++----------------
 .../tasks/AsciidoctorWarningGateTaskSpec.groovy    |  3 +-
 2 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/buildSrc/src/main/groovy/website/gradle/tasks/AsciidoctorWarningGateTask.groovy b/buildSrc/src/main/groovy/website/gradle/tasks/AsciidoctorWarningGateTask.groovy
index 17be5aca302..405d1be1ba9 100644
--- a/buildSrc/src/main/groovy/website/gradle/tasks/AsciidoctorWarningGateTask.groovy
+++ b/buildSrc/src/main/groovy/website/gradle/tasks/AsciidoctorWarningGateTask.groovy
@@ -23,10 +23,8 @@ import groovy.transform.CompileStatic
 import org.gradle.api.DefaultTask
 import org.gradle.api.GradleException
 import org.gradle.api.Project
-import org.gradle.api.Task
 import org.gradle.api.file.DirectoryProperty
 import org.gradle.api.file.RegularFileProperty
-import org.gradle.api.plugins.ExtraPropertiesExtension
 import org.gradle.api.provider.Property
 import org.gradle.api.provider.ListProperty
 import org.gradle.api.tasks.Input
@@ -143,7 +141,15 @@ class AsciidoctorWarningGateTask extends DefaultTask {
     }
 
     private static void wireLogCapture(Project project) {
-        project.tasks.withType(PublishGuideTask).all { PublishGuideTask renderTask ->
+        // The listener is added in doFirst on each PublishGuide task. We deliberately
+        // do NOT register a finalizer cleanup task: removing the listener would
+        // require the cleanup task to access the renderTask's extensions/logging at
+        // execution time, which Gradle's configuration cache disallows when the
+        // cleanup is wired across tasks. Leaving the listener attached for the
+        // remainder of the JVM lifetime is harmless: each `gradle` invocation runs
+        // in a single-use Daemon (see publish.yml: --no-daemon) so the listener is
+        // GC'd when the process exits, never crossing build boundaries.
+        project.tasks.withType(PublishGuideTask).configureEach { PublishGuideTask renderTask ->
             File logsRoot = project.layout.buildDirectory.dir('logs').get().asFile
             File logFile = new File(logsRoot, "asciidoctor-${renderTask.name}.log")
 
@@ -157,31 +163,7 @@ class AsciidoctorWarningGateTask extends DefaultTask {
 
                 renderTask.logging.addStandardOutputListener(writeListener)
                 renderTask.logging.addStandardErrorListener(writeListener)
-
-                ExtraPropertiesExtension extraProperties = renderTask.extensions.extraProperties
-                extraProperties.set('logFile', logFile)
-                extraProperties.set('logListener', writeListener)
-            }
-
-            String cleanupTaskName = "cleanup-${renderTask.name}-logs"
-            if (project.tasks.findByName(cleanupTaskName) == null) {
-                project.tasks.register(cleanupTaskName) { Task cleanupTask ->
-                    cleanupTask.notCompatibleWithConfigurationCache('Removes StandardOutputListener instances from PublishGuide tasks.')
-                    cleanupTask.doLast {
-                        try {
-                            ExtraPropertiesExtension extraProperties = renderTask.extensions.extraProperties
-                            if (extraProperties.has('logListener')) {
-                                StandardOutputListener writeListener = extraProperties.get('logListener') as StandardOutputListener
-                                renderTask.logging.removeStandardOutputListener(writeListener)
-                                renderTask.logging.removeStandardErrorListener(writeListener)
-                            }
-                        } catch (Exception e) {
-                            project.logger.warn("Listener cleanup failed for ${renderTask.name}: ${e.message}")
-                        }
-                    }
-                }
             }
-            renderTask.finalizedBy(cleanupTaskName)
         }
     }
 
diff --git a/buildSrc/src/test/groovy/website/gradle/tasks/AsciidoctorWarningGateTaskSpec.groovy b/buildSrc/src/test/groovy/website/gradle/tasks/AsciidoctorWarningGateTaskSpec.groovy
index 7b9b60eabd9..0b7d9f91e83 100644
--- a/buildSrc/src/test/groovy/website/gradle/tasks/AsciidoctorWarningGateTaskSpec.groovy
+++ b/buildSrc/src/test/groovy/website/gradle/tasks/AsciidoctorWarningGateTaskSpec.groovy
@@ -30,7 +30,7 @@ class AsciidoctorWarningGateTaskSpec extends Specification {
     @TempDir
     File tempDir
 
-    def 'captures a clean log as VERIFIED and wires cleanup finalizer'() {
+    def 'captures a clean log as VERIFIED'() {
         given:
         def project = ProjectBuilder.builder().withProjectDir(tempDir).build()
         String renderTaskName = registerRenderTask(project, 'demo-guide', '1')
@@ -46,7 +46,6 @@ class AsciidoctorWarningGateTaskSpec extends Specification {
         then:
         gateTask.group == AsciidoctorWarningGateTask.GROUP
         gateTask.reportFile.get().asFile.text.contains('demo-guide,1,VERIFIED,0')
-        project.tasks.findByName("cleanup-${renderTaskName}-logs") != null
     }
 
     def 'writes only the header when no logs directory exists'() {