Make GenerateJavaTask.schemaPaths lazy instead of @Input List<Any> (fixes #952) - #956
Open
harshit6392 wants to merge 1 commit into
Open
Make GenerateJavaTask.schemaPaths lazy instead of @Input List<Any> (fixes #952)#956harshit6392 wants to merge 1 commit into
harshit6392 wants to merge 1 commit into
Conversation
harshit6392
requested review from
asibross,
iparadiso,
iuliiasobolevska,
jjacobs44,
kilink,
kzwang,
paulbakker and
srinivasankavitha
as code owners
September 11, 2026 08:20
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.
Fixes #952
What changed
GenerateJavaTask.schemaPathswas a plainvar schemaPaths = mutableListOf<Any>(...)annotated@InputFiles. This PR changes it to a properConfigurableFileCollection, mirroring howdgsCodegenClasspathis already declared in the same class:schemaPathsis now aval schemaPaths: ConfigurableFileCollection, annotated with@get:InputFilesand@get:PathSensitive(PathSensitivity.RELATIVE).setSchemaPathsoverloads are added — acceptingIterable<Any>,Provider<out Iterable<Any>>,and
FileCollection— all delegating toschemaPaths.setFrom(...).generate()now resolvesschemaPaths.fileslazily at task-execution time instead of eagerlymapping the old
List<Any>viaPaths.get(it.toString()).Why
Provider(e.g. a schema location resolved from an external dependency/configuration) had to beresolved at configuration time — exactly what Gradle's lazy configuration model is meant to avoid.
List<Any>of raw strings doesn't give Gradle propercontent-based snapshotting.
ConfigurableFileCollection+@PathSensitive(RELATIVE)bringsschemaPathsin line with howdgsCodegenClasspathis already handled, so Gradle can correctlydetermine task avoidance.
List<Any>, passing something like aSet<File>as a single list elementsilently stringified into
[/path/to/schema.graphqls](brackets included), only surfacing as adownstream compilation failure. A
FileCollection-backed property can't be misused this way.Backward compatibility
Existing build scripts using
schemaPaths = ["${projectDir}/src/main/resources/schema"]continue towork unchanged — in Groovy,
schemaPaths = [...]resolves to a call tosetSchemaPaths(Iterable<Any>),one of the added overloads. No existing
build.gradlefiles in this repo's test fixtures neededchanges.
In addition to the existing string-list form,
schemaPathscan now also be set to aFileCollectionor a
Provider<Iterable<Any>>, e.g.:Testing
CodegenGradlePluginTest,CodegenGradlePluginSpringBootSmokeTest,CodegenGradlePluginEntitySmokeTest) continue to exercise the string-listschemaPaths = [...]formused across all test-project fixtures.