gradle icon indicating copy to clipboard operation
gradle copied to clipboard

Classloader mismatch when restoring a build service reference

Open mlopatkin opened this issue 10 months ago • 1 comments

Current Behavior

Using a build service that is also an OperationCompletionListener as a parameter to the FlowAction sometimes fails with an exception in a CC miss build:

GradleException: Could not load the value of field `__buildAnalyticsService__` of `BuildEndAction$Parameters_Decorated` bean found in class `BuildEndAction`.
  
    Caused by: java.lang.IllegalArgumentException: Cannot set the value of a property of type GradleBuildAnalyticsListener loaded with VisitableURLClassLoader(ClassLoaderScopeIdentifier.Id{coreAndPlugins:settings[:]:groovy-dsl:/Users/b/Development/apps/android/settings.gradle:SettingsScript(local)}) using a provider of type GradleBuildAnalyticsListener loaded with ScriptClassLoader(groovy-script-/Users/b/Development/apps/android/settings.gradle-loader).

Expected Behavior

BuildService should be properly injected into the action.

Context (optional)

No response

Self-contained Reproducer Project

N/A

Gradle version

8.12.1

Build scan URL (optional)

No response

Your Environment (optional)

No response

mlopatkin avatar Mar 06 '25 12:03 mlopatkin

We're having this a bunch recently. One example here: https://github.com/apollographql/apollo-kotlin/actions/runs/15589064153/job/43903051251

Setting kotlin.internal.collectFUSMetrics=false workarounds the issue but it's not 100% clear if it's a KGP thing or a Gradle thing.

martinbonnin avatar Jun 11 '25 15:06 martinbonnin

We also facing this in our internal source code. Whats even worse, it seems the whole build gets invalidated afterwards. No build cache is picked up. Super frustrating developer experience...

StefMa avatar Jul 08 '25 11:07 StefMa