autonomousapps / autonomousapps/dependency-analysis-gradle-plugin

Task findDeclarations is not cacheable due to input based on object references

Open
#1,490 2 comments 0 reactions 0 assignees View on GitHub
bug performance
Dominant language
Kotlin
Stars
2.2k
Forks
158
Avg merge
16h 25m
Merged PRs (30d)
46

Description

**Plugin version**
2.19.0

**Gradle version**
8.7

**JDK version**
Eclipse Temurin OpenJDK Runtime Environment 21.0.4+7-LTS

** Describe the bug **
Remote and local Gradle build cache misses occur for the findDeclarations task from the @autonomousapps/dependency-analysis-gradle-plugin, even when inputs, outputs, and code are unchanged. This prevents cache hits between CI and local, and between builds on different machines. The issue is traced to the use of object references (e.g., ModuleInfo@5f9863a7) in the task’s @Input properties, resulting in non-deterministic cache keys.

** To Reproduce **

Apply the com.autonomousapps.dependency-analysis plugin with a custom dependencyAnalysis configuration.
Run a build for a subproject (e.g., ./gradlew findDeclarations).
Remove the build directory and run the build again.
Observe that the task uses the local cache only if the Gradle daemon remains alive and creates objects in the same order.
Remove the local build cache directory (~/.gradle/caches/build-cache-1/) and rerun the build.
Observe that the task both misses local and remote cache, and only stores the result locally.
Inspect the cache key inputs using a build scan or by printing declarationContainer.mapping; you will see object references with memory addresses that differ between builds.
Expected behavior
For identical project state and code, the findDeclarations task should produce the same cache key every time, resulting in consistent remote and local cache hits across machines and build environments.

Additional context

The input property declarationContainer.mapping contains object references (e.g., ModuleInfo@5f9863a7), whose hash codes or memory addresses differ between JVM executions.
This results in different cache keys for each build, making cache hits impossible across JVMs, machines, or CI systems.
Fixing this requires ensuring that all @Input/@Nested properties for the task use stable, serializable, value-based data (e.g., strings, numbers, lists/sets/maps with deterministic ordering and values), not object references.
Build scan comparison between builds with no code changes shows different values for declarationContainer.mapping input.

Contributor guide

Open the contributing guide

Research direction

Start with the findDeclarations task and inspect how declarationContainer.mapping is exposed as an input. Compare its values across repeated builds using a build scan or the reported input output. Done means identical project state produces stable, value-based cache inputs and consistent local and remote cache hits across JVMs and machines.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.