Skip to content

Declare classpath as @Classpath input using ConfigurableFileCollection#439

Closed
timtebeek wants to merge 5 commits into
mainfrom
tim/fix-gradle-plugin-387
Closed

Declare classpath as @Classpath input using ConfigurableFileCollection#439
timtebeek wants to merge 5 commits into
mainfrom
tim/fix-gradle-plugin-387

Conversation

@timtebeek

@timtebeek timtebeek commented Apr 12, 2026

Copy link
Copy Markdown
Member

Summary

The rewrite tasks accessed classpaths without declaring them as Gradle task inputs, so Gradle could not infer task dependencies. This caused "File does not exist" errors when other plugins (e.g. extra-java-module-info) produced jars that needed to be built first.

  • Replace Provider<Set<File>> resolvedDependencies with a ConfigurableFileCollection annotated with @Classpath, wired via .from(detachedConf) using a Callable for lazy creation. This gives Gradle full provenance of the rewrite recipe jars.
  • Add a separate projectClasspath @Classpath input, wired from each source set's compile and runtime classpaths. This lets Gradle infer that dependent project jars (e.g. test-support.jar) must be built before rewrite tasks run.

Test plan

  • ./gradlew :plugin:test — all tests pass
  • End-to-end validation on three projects: single-module, multi-module, and custom rewrite configuration dependency

…leCollection

Fixes #387. The rewrite task classpath was not declared as a Gradle task
input, causing Gradle to lack dependency provenance information. Replace
Provider<Set<File>> with an abstract ConfigurableFileCollection annotated
with @classpath, and wire it via .from(detachedConf) so Gradle can track
the full dependency graph.
Managed properties (abstract getters) require Gradle 5.1+, so older
versions fail with "Cannot create a proxy class for abstract class".
Initialize the ConfigurableFileCollection via getProject().files() in
the constructor instead, keeping @classpath semantics while supporting
the full Gradle version matrix.
Add a separate projectClasspath @classpath input to rewrite tasks, wired
from each source set's compile and runtime classpaths. This lets Gradle
infer that dependent project jars (e.g. test-support.jar) must be built
before rewrite tasks run, fixing the "File does not exist" error when
plugins like extra-java-module-info perform early dependency resolution.
@timtebeek timtebeek marked this pull request as ready for review April 12, 2026 12:50
…spath

- Cache the Callable<Configuration> so createDetachedConfiguration runs
  at most once instead of once per task
- Replace duplicate rewriteRun/rewriteDryRun configure blocks with a loop
- Remove compileClasspath from projectClasspath since runtimeClasspath
  is a superset
- Restore java.io.File import instead of using fully qualified reference
@shanman190

Copy link
Copy Markdown
Collaborator

There's a much deeper problem here in that we implicitly depend on numerous pieces of information on the project (ex: all configurations to generate the GradleProject marker).

So we'll not be properly modeling those and still be missing relationships. This is what led me to create an overarching issue to address these and many more aspects that we haven't yet been able to address.

@timtebeek

Copy link
Copy Markdown
Member Author

Thanks yes was aware of that issue, but wasn't sure if we could incrementally work our way there with steps like these; you'll know best if we could, so let me know if this should be refined or closed.

@timtebeek

Copy link
Copy Markdown
Member Author

Closing as it's not clear what the next step would be; that said we have more freedom to restructure the plugin now that the CLI no longer depends on it. We might even choose to drop support for the oldest of Gradle versions.

@timtebeek timtebeek closed this Jul 1, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

classPath not declared as required input

2 participants