Skip to content

8.0 (fix): use running AbstractCompile destinationDirectory in PruneGeneratedFactories - #17331

Open
codeconsole wants to merge 1 commit into
apache:8.0.xfrom
codeconsole:fix-prune-factories-forwarded-compile
Open

codeconsole wants to merge 1 commit into
apache:8.0.xfrom
codeconsole:fix-prune-factories-forwarded-compile

Conversation

@codeconsole

Copy link
Copy Markdown
Contributor

Fixes #17330

Summary

In #17318, PruneGeneratedFactories.execute preferred the captured destinationDirectory provider over task.destinationDirectory, so forwarding the action from compileGroovy to another AbstractCompile task with a different destination directory pruned the source task's destination instead of the running task's destination.

Changes

  • Updated PruneGeneratedFactories.execute(Task) to read ((AbstractCompile) task).destinationDirectory whenever task instanceof AbstractCompile, falling back to the captured destinationDirectory provider only for non-AbstractCompile wrapper tasks (matching the pattern used in 9.0 (fix): capture indy Provider in VerifyNativeImageIndy instead of casting Task #17319).
  • Added regression tests in PruneGeneratedFactoriesSpec covering forwarding to another GroovyCompile with a different destination (verifying the running task's file is pruned and the source task's file is untouched) and executing the two-argument constructor against a non-AbstractCompile task.

Verification

  • Ran ./gradlew :grails-gradle-plugins:codeStyle :grails-gradle-plugins:test in grails-gradle; all style checks and tests passed.

@testlens-app

testlens-app Bot commented Dec 4, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: b69cba3
▶️ Tests: 113448 executed
⚪️ Checks: 95/95 completed


Learn more about TestLens at testlens.app/docs.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes. Forwarding the action to another compile task now prunes that task's destination. An explicit destination that differs from the running task is ignored.

File classesDirectory = destinationDirectory != null
? destinationDirectory.get().asFile
: ((AbstractCompile) task).destinationDirectory.get().asFile
Provider<Directory> targetDirectory = task instanceof AbstractCompile

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Construct the action with a destination that is not the destination of the AbstractCompile task that runs it. The action now uses the running task's directory. Stale registrations stay in the directory that was supplied, and the running task's file can be pruned instead. Use the supplied directory when it has a value.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Forwarding the factories prune to another compile task prunes the source task's destination

2 participants