fix: add --configure-on-demand to all Gradle commands#2065
Open
mashraf-222 wants to merge 1 commit intomainfrom
Open
fix: add --configure-on-demand to all Gradle commands#2065mashraf-222 wants to merge 1 commit intomainfrom
mashraf-222 wants to merge 1 commit intomainfrom
Conversation
Gradle evaluates all project configurations during the configuration phase, even when only one module is targeted. Multi-module projects with diverse toolchain requirements (e.g., OpenRewrite's rewrite-gradle needs JDK 8) fail when an unrelated module's toolchain isn't available. Adds --configure-on-demand to all 8 Gradle command construction sites so Gradle only configures projects needed for the requested task. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Gradle multi-module projects with diverse toolchain requirements fail during the configuration phase. Gradle evaluates ALL project configurations even when only one module is targeted (e.g.,
:rewrite-core:test). If an unrelated module requires an unavailable toolchain (e.g.,rewrite-gradleneeds JDK 8), the entire build fails.Discovered during OpenRewrite E2E optimization:
rewrite-gradlemodule's JDK 8 toolchain requirement blocked optimization ofrewrite-core.Root Cause
GradleStrategyconstructs Gradle commands without--configure-on-demand. This means all 31+ modules in a project like OpenRewrite get configured, including those not related to the target task.Fix
Added
--configure-on-demandto all 8 Gradle command construction sites inGradleStrategy:install_multi_module_deps()compile_tests()(both module and non-module paths)compile_source_only()(both paths)_get_classpath_uncached()run_tests_via_build_tool()get_test_run_command()--configure-on-demandtells Gradle to only configure projects needed for the requested task. Available since Gradle 1.4, widely used in large projects. Harmless for single-module projects.Test Coverage
6 new tests in
test_gradle_strategy.pyverify--configure-on-demandis present in all command construction paths.Testing