Is ehcache transitive dependency resolution broken in mavenCentral()?


(Joe McCall) #1

I’m trying to add the following dependency to my project (using mavenCentral()):

compile 'net.sf.ehcache:ehcache:2.7.0'

But when I run gradle build I get the following output:

What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not resolve net.sf.ehcache:ehcache:2.7.0.
  Required by:
      myproject:0.1
   > Could not find net.sf.ehcache:ehcache-root:2.7.0.
   > Could not find net.sf.ehcache:ehcache-root:2.7.0.
   > Could not find net.sf.ehcache:ehcache-root:2.7.0.
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  BUILD FAILED

Can anyone else confirm this? 99% of the time dependencies in mavenCentral() “just work” for me, so this is really weird.


(Peter Niederwieser) #2

The ‘ehcache-2.7.0’ POM declares ‘ehcache-root’ as its parent, and according to http://search.maven.org, the latter is not in Maven Central. So yes, the latest ‘ehcache’ POM seems broken. Earlier versions referenced ‘ehcache-parent’, which is available from Central.


(Joe McCall) #3

I created 2 simple projects, one maven and the other gradle. Maven resolves the dependency, while gradle does not. Here is the code: https://gist.github.com/joemccall86/5154507


(Peter Niederwieser) #4

Maybe Maven ignores the missing parent POM, maybe due to the ‘relativePath’ element. Still doesn’t look right to me. Usually, Gradle makes it easy to work around such problems, but in the case of a missing parent POM I’m not 100% sure. A good first attempt is ‘‘net.sf.ehcache:ehcache:2.7.0@jar’’ and specifying any transitive dependencies manually.


(Joe McCall) #5

Cool. If you dont mind, could you point me in the right direction?


(Peter Niederwieser) #6

See my updated comment above.


(Joe McCall) #7

I think I got it.

compile('net.sf.ehcache:ehcache:2.7.0') { exclude module: 'ehcache-root' }

(Peter Niederwieser) #8

If that works for parent POMs, it’s a good solution. You can also exclude ‘ehcache-root’ globally: ‘configurations.all*.exclude module: “ehcache-root”’.