Visitar URL original
Depend on the task generating precompiled script plugin sources by Develop-KIM · Pull Request #38509 · gradle/gradle · GitHub
Skip to content

Depend on the task generating precompiled script plugin sources - #38509

Merged
eskatos merged 1 commit into
gradle:masterfrom
Develop-KIM:fix/37135-precompiled-groovy-generated-sources
Jul 16, 2026
Merged

eskatos merged 1 commit into
gradle:masterfrom
Develop-KIM:fix/37135-precompiled-groovy-generated-sources

Conversation

@Develop-KIM

Copy link
Copy Markdown
Contributor

Fixes #37135

This supersedes #38486, which got closed by accident. The only change from that PR is that the coding-agent attribution has been dropped from the commit message per @ghale's request (the Signed-off-by is kept). The code is identical.

Context

When a groovy-gradle-plugin project generates its .gradle script plugins with a task and registers that task's output as a Groovy source directory:

sourceSets.main.groovy.srcDir(tasks.named('expandTemplates'))

a subsequent build fails execution-time validation:

Task ':extractPluginRequests' uses this output of task ':expandTemplates'
without declaring an explicit or implicit dependency.

ExtractPluginRequestsTask and CompileGroovyScriptPluginsTask received the script plugin files as an eagerly resolved Set<File>, which discards the build dependencies of the source directories, so the tasks gained no dependency on the task producing the scripts.

File discovery still uses the source set's full file tree, but the tasks' getScriptFiles() inputs now carry the Groovy source's build dependencies via builtBy, so they run after the generating task. The dependency is taken from the Groovy source alone to avoid a cycle with the generated plugin-adapter sources added to the Java source set.

Verified locally: on master the added integration test fails with the exact reported validation error on the second run; with the fix the full PrecompiledGroovyPluginsIntegrationTest class passes (44 tests). :plugin-development checkstyle and codenarc also pass.

Implementation was done with AI assistance (disclosed here, since attributions are kept out of the commit message per project policy); I have reviewed and understand every line.

Contributor Checklist

  • Review Contribution Guidelines.
  • Make sure that all commits are signed off to indicate that you agree to the terms of Developer Certificate of Origin.
  • Make sure all contributed code can be distributed under the terms of the Apache License 2.0.
  • Check "Allow edit from maintainers" option in pull request so that additional changes can be pushed by Gradle team.
  • Provide integration tests (under <subproject>/src/integTest) to verify changes from a user perspective.
  • Provide unit tests (under <subproject>/src/test) to verify logic. (Behavior is task-dependency wiring, verified via the integration test.)
  • Update User Guide, DSL Reference, and Javadoc for public-facing changes. (No public-facing API change.)
  • Ensure that tests pass locally: ./gradlew :plugin-development:embeddedIntegTest --tests "*PrecompiledGroovyPluginsIntegrationTest".

ExtractPluginRequestsTask and CompileGroovyScriptPluginsTask received the
script plugin files as an eagerly resolved Set<File>, which discards the
build dependencies of the source directories. When the .gradle scripts are
produced by a task registered as a Groovy srcDir, those tasks gained no
dependency on the generating task and failed execution-time validation on
a subsequent build:

    Task ':extractPluginRequests' uses this output of task ':expandTemplates'
    without declaring an explicit or implicit dependency.

File discovery still uses the source set's full file tree, but the tasks'
getScriptFiles() inputs now carry the Groovy source's build dependencies via
builtBy, so they run after the task that generates the scripts. The
dependency is taken from the Groovy source alone to avoid a cycle with the
generated plugin-adapter sources added to the Java source set.

Fixes gradle#37135

Signed-off-by: Develop-KIM <kimdonghwan913@gmail.com>
@Develop-KIM
Develop-KIM requested a review from a team as a code owner July 14, 2026 01:12
@Develop-KIM
Develop-KIM requested a review from jbartok July 14, 2026 01:12
@bot-gradle bot-gradle added from:contributor PR by an external contributor to-triage labels Jul 14, 2026
@lkasso lkasso added in:plugin-development regular and convention plugins 👋 team-triage Issues that need to be triaged by a specific team @cortex Issues/PRs to add to Cortex team's Project Board and removed to-triage labels Jul 14, 2026
@eskatos eskatos self-assigned this Jul 16, 2026
@eskatos eskatos removed the 👋 team-triage Issues that need to be triaged by a specific team label Jul 16, 2026
@eskatos

eskatos commented Jul 16, 2026

Copy link
Copy Markdown
Member

@bot-gradle test this

@bot-gradle

This comment has been minimized.

@eskatos eskatos added this to the 9.8.0 RC1 milestone Jul 16, 2026

@eskatos eskatos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@bot-gradle

Copy link
Copy Markdown
Collaborator

The following builds have failed:

🔎 2 failure groups (0 build, 2 test)

Test failure · 7 occurrences · scan

org.gradle.tooling.BuildException: Could not fetch model of type 'CppProject' using connection to Gradle installation 'C:\tcagent1\work\f63322e10dd6b396\platforms\native\distributions-native\build\bin distribution'.

org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'lib'.
org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController$BuildActionExecutionException: A problem occurred configuring root project 'lib'.…
Test failure · 2 occurrences · scan
org.gradle.tooling.BuildActionFailureException: The supplied build action failed with an exception.
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'.
org.gradle.internal.nativeintegration.NativeIntegrationUnavailableException: Service 'WindowsRegistry' is not available (os=Windows 10 10.0 amd64, enabled=false).

@eskatos
eskatos added this pull request to the merge queue Jul 16, 2026
Merged via the queue into gradle:master with commit fde651e Jul 16, 2026
30 of 34 checks passed
@eskatos

eskatos commented Jul 16, 2026

Copy link
Copy Markdown
Member

Thanks, @Develop-KIM !
This will be in Gradle 9.8.

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

Labels

@cortex Issues/PRs to add to Cortex team's Project Board from:contributor PR by an external contributor in:groovy-dsl in:plugin-development regular and convention plugins in:precompiled-script-plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ExtractPluginRequestsTask does not depend on tasks of generated source set

5 participants