Search code examples
javagradleintellij-ideajettydropwizard

Why does Gradle resolve a package with wrong version number?


I am building a web application and I am using Dropwizard 1.3.0, which has a dependency on jetty-io 9.4.8. This dependency has conflicts with another package (dropwizard-websocket-jee7-bundle 2.0.0), because it seem to fetch the wrong version number.

I looked into tha package, and found the method that has been renamed in 9.4.x - AbstractWebSocketConnection.java from 9.3.x - AbstractWebSocketConnection.java. The issue is that even though in Gradle the dependency tree shows I fetched 9.4.8 (the new one which I need), I still get the older, 9.3.x java file which causes the conflicts. I tried to Invalidate Caches / Restart and rebuild the whole project, but I seem to get the outdated file all the time.

What are the possible solutions for this?


Solution

  • If your bad class are imported by a transitive dependency, try to exclude explicit the transitive dependency. For example if your required library is 'my.group:requiredLibrary:2.0.0' and there are another version in 'my.group:someDependency:0.1.5' you can do like this:

    dependencies{
      compile 'my.group:requiredLibrary:2.0.0'
      compile ('my.group:someDependency:0.1.5'){
          exclude group: 'my.group'  module:'requiredLibrary'
      }
    }