The Hibernate build has been stuck at m2/m3 for many reasons. Recently I decided to get it moved up to m7. But I am running into class loader isolation problems in many of our plugins. As far as I can tell based on forums.gradle.org/gradle/topics/gradle_runtime_classpath et al, starting in m5 there was a change in how classes for plugins get loaded.
This has led to lots of ClassCastExceptions for me in plugins that use libraries that Gradle also uses under the covers. I only know most of this because Adam helped me with one such issue: https://github.com/sebersole/gradle-upload-auth-plugin/pull/2 That change was specifically dealing with access to Maven jars. The “solution” was to use reflection to access that Maven stuff I needed. It works, but obviously that is a PITA if you need to do that each and every time your plugin uses a jar or library that Maven also uses, but does not expose.
Take for example, dom4j. The plugin mentioned above is also using dom4j and now I get the same types of errors pertaining to that library: Nested exception:
java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
So what is the solution?