Declare classpath as @Classpath input using ConfigurableFileCollection#439
Declare classpath as @Classpath input using ConfigurableFileCollection#439timtebeek wants to merge 5 commits into
Conversation
…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.
…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
|
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 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. |
|
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. |
|
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. |
Summary
classPathnot declared as required input #387.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.Provider<Set<File>> resolvedDependencieswith aConfigurableFileCollectionannotated with@Classpath, wired via.from(detachedConf)using aCallablefor lazy creation. This gives Gradle full provenance of the rewrite recipe jars.projectClasspath@Classpathinput, 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 passrewriteconfiguration dependency