GradleSettings class cast exception

I'm trying to update the Gradle GUI plugin to work with Idea 11 EAP and I'm getting an odd exception. Simply calling this line within my plugin:

GradleSettings.getInstance( project )

throws this exception:

java.lang.ClassCastException: org.jetbrains.plugins.gradle.config.GradleSettings cannot be cast to org.jetbrains.plugins.gradle.config.GradleSettings
    at org.jetbrains.plugins.gradle.config.GradleSettings.getInstance(GradleSettings.java:49)
    ...

The important part:

org.jetbrains.plugins.gradle.config.GradleSettings cannot be cast to

org.jetbrains.plugins.gradle.config.GradleSettings

Offhand, it sounds like a ClassLoader issue since it's saying it can't cast a class to itself. Where I'm calling it is using Idea's PluginClassLoader and both my calling class and the GradleSettings class have the same classloader instance.

The line in question (in Idea's plugin source) is calling this:


  48   public static GradleSettings getInstance(@NotNull Project project) {
  49     return ServiceManager.getService(project, GradleSettings.class);
  50   }

ServiceManager is not using same classloader instance (or class; it's Idea's URLClassLoader).

FYI: I'm actually trying to gradle's home directory and calling GradleLibraryManager.INSTANCE.getGradleHome() calls GradleSettings which throws the exception.

Any thoughts?

4 comments

Hello,

GradleSettings class is moved to the 'gradle' plugin now. Please add dependency to it at your 'plugin.xml', i.e. add the following tag '<depends>org.jetbrains.plugins.gradle</depends>'

Denis

0

Thank you for the response, but unfortunately, I noticed it had been moved and had updated my dependencies as you specifed before my original post. I also removed my previous dependency on the groovy plugin (where GradleSettings used to be). Have the class loaders been changed with respect to interdependent plugins?

0

Hello mhunsicker,

Please make sure that you've added the gradle plugin jar to the classpath
of your IDEA SDK and not as a dependency to your module.

Thank you for the response, but unfortunately, I noticed it had been
moved and had updated my dependencies as you specifed before my
original post. I also removed my previous dependency on the groovy
plugin (where GradleSettings used to be). Have the class loaders been
changed with respect to interdependent plugins?


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Bam! That was it. I should have thought of that. Thanks!

0

Please sign in to leave a comment.