This message was deleted.
# community-support
s
This message was deleted.
t
integration test as in you're using Gradle TestKit? that almost certainly is a classpath issue.
MyTask
and
MyTask_Decorated
(the latter of which gradle creates at build runtime with bytecode magic) are probably getting loaded into different classloaders and can't "see" each other
🤔 1
j
yeah my tests using gradle testkit do not have the error, but projects using my plugin sometimes do
t
oh, you said "I can't seem to reproduce it in an integration test"
projects you control or third parties?
j
projects i control
im currently trying to get a full stacktrace, but it only sometimes happens and haven't had luck getting it to happen on my local yet, just ci server
Copy code
Caused by: java.lang.ClassCastException: Failed to cast object task ':aggregateLibraryMetadataFiles' of type com.grubhub.gradle.grublish.common.AggregateLibraryMetadataTask_Decorated to target type com.grubhub.gradle.grublish.common.AggregateLibraryMetadataTask
        at org.gradle.internal.Cast.cast(Cast.java:41)
        at org.gradle.internal.Transformers$CastingTransformer.transform(Transformers.java:63)
        at com.grubhub.gradle.grublish.common.AggregateLibraryMetadataTask$Companion.apply(AggregateLibraryMetadataTask.kt:67)
        at com.grubhub.garcon.buildplugin.grublish.impl.GrublishLibPlugin.apply(GrublishLibPlugin.kt:44)
        at com.grubhub.garcon.buildplugin.grublish.impl.GrublishLibPlugin.apply(GrublishLibPlugin.kt:15)
here is my real stacktrace
this is a custom task type defined in kotlin
the call to cast is coming from my custom
maybeCreate
function as seen here: https://gradle-community.slack.com/archives/CAD95CR62/p1676424003705409
but that code came from the real one with just the extra tweak of adding the configuration closure
t
can you repro this reliably?
j
kind of. it happens, but not 100% of the time
t
only CI, not locally?
j
unless when it doesnt happen, the project is not resolving to my new version of the plugin.... that might be possible since we use dynamic versions sometimes
we have local repro now
t
I would normally suggest dropping a breakpoint and verifying my idea that you have multiple classloaders in play
j
ah, i dont have int test repro yet, just local in a downstream consumer project of my plugin
t
use the prod code, no need for a test for this purpose
j
but the classloader thing is interesting. i guess i need to learn more about how gradle manages classloaders
ah ok, i guess i need to learn how to hook a debugger up to a build then
t
well if you had a break point in that function, you could just inspect
Thing::class.java.classLoader
and dig into it
j
yeah
ok ill look into that, thanks
t
-Dorg.gradle.debug=true
+ IDEA and
Remote JVM Debug
run configuration
and you can add your plugin to the project as an included build so it's built from source
j
ahh, ok thats the key
when i tried to repro with a buildSrc plugin, it didnt repro