Skip to content

Comments

Fix Configuration Cache compatibility (#108)#109

Merged
jiakuan merged 4 commits intomainfrom
feature/108-configuration-cache-compatibility
Oct 12, 2025
Merged

Fix Configuration Cache compatibility (#108)#109
jiakuan merged 4 commits intomainfrom
feature/108-configuration-cache-compatibility

Conversation

@jiakuan
Copy link
Owner

@jiakuan jiakuan commented Oct 12, 2025

Summary

Fixes #108 by adding full Gradle Configuration Cache compatibility to the GWT Gradle plugin. The plugin previously failed with Configuration Cache enabled due to accessing getProject() during task execution time, which violates Gradle's Configuration Cache requirements.

Problem

When Configuration Cache was enabled (-Dorg.gradle.configuration-cache=true), Gradle reported incompatibilities:

  • Tasks were calling getProject() during execution time (in exec() methods)
  • Task arguments and classpath were being configured at execution time instead of configuration time
  • This prevented the Configuration Cache from being properly stored and reused

Solution

  • Moved configuration to configuration phase: Created configureArgs() and configureCompileArgs() methods that are called during task configuration rather than execution
  • Eliminated execution-time getProject() calls: Changed getProject().getLogger() to getLogger() and moved all project access to configuration phase
  • Added gwtDevRuntimeClasspath field: Stores the GWT dev runtime classpath as a ConfigurableFileCollection that is populated during configuration
  • Updated all config classes: Modified GwtCompileConfig, GwtDevModeConfig, and GwtSuperDevConfig to set up classpath and call configureArgs() during configuration
  • Fixed task dependencies: Added explicit processResources dependency to GwtCompileTask

Changes Made

  • AbstractBaseTask: Refactored exec() method to separate configuration-time setup from execution-time logic
  • GwtCompileTask: Moved argument configuration to configureCompileArgs() method
  • Configuration classes: All three config classes now properly set up classpath and arguments during configuration phase

Impact

  • Plugin now fully supports Gradle Configuration Cache
  • Build performance improves with Configuration Cache enabled due to faster configuration reuse
  • No breaking changes to plugin API or usage

Fixes #108 by eliminating getProject() calls during task execution time
and moving all configuration logic to the configuration phase.

Key changes:
- Moved args/jvmArgs configuration from exec() to new configureArgs() methods
- Changed getProject().getLogger() to getLogger() in task execution
- Added gwtDevRuntimeClasspath field to store classpath during configuration
- Updated all config classes to call configureArgs() during configuration phase
- Added processResources task dependency to GwtCompileTask

The plugin now works correctly with Gradle Configuration Cache enabled.
@jiakuan jiakuan requested a review from Copilot October 12, 2025 08:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes Gradle Configuration Cache compatibility issues by refactoring GWT plugin tasks to separate configuration-time and execution-time logic, ensuring compliance with Gradle's Configuration Cache requirements.

  • Moved all task configuration from execution phase to configuration phase to eliminate Configuration Cache violations
  • Added dedicated configureArgs() methods to separate argument setup from task execution
  • Introduced gwtDevRuntimeClasspath field to store classpath configuration during configuration phase

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
AbstractBaseTask.java Refactored to separate argument configuration from execution, added gwtDevRuntimeClasspath field
GwtCompileTask.java Added configureCompileArgs() method and fixed logger access for Configuration Cache compatibility
GwtCompileConfig.java Modified to configure classpath and arguments during configuration phase
GwtDevModeConfig.java Modified to configure classpath and arguments during configuration phase
GwtSuperDevConfig.java Modified to configure classpath and arguments during configuration phase

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Reduces code duplication by extracting the repeated classpath configuration
logic into a shared configureClasspath() method in AbstractBaseTask.

This eliminates 33 lines of duplicated code across three config classes
and improves maintainability.
@jiakuan jiakuan requested a review from Copilot October 12, 2025 09:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

…roject()

Improves code clarity by passing the project instance that's already
available in the execute() method, rather than calling task.getProject()
again. This also makes the code more consistent across all config classes.
@jiakuan jiakuan requested a review from Copilot October 12, 2025 09:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- Rename allMainSourcePaths to mainSourcePaths for clarity
- Add Project import and use simple type name instead of FQN
- Improves code readability and consistency
@jiakuan jiakuan requested a review from Copilot October 12, 2025 09:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@jiakuan jiakuan merged commit 184a895 into main Oct 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compatibility with Configuration Cache

1 participant