Question

Gradle reports a dependency conflict while I thought that I can resolve conflicts by forcing a particular version. Can someone please shed a light on this and how to force a particular version in any case?

This is the basic build script. It should work out of the box.

apply plugin: 'java'

ext {
    version_spring          = "4.0.4.RELEASE"
    version_jbehave         = "3.9.2"
}

repositories {
    mavenCentral()
}

configurations.all {
   resolutionStrategy {
      failOnVersionConflict()      ;; (1)
         //
         // The idea is to force a particular version of Spring
         //
         force "org:springframework:spring-core:${version_spring}"
         force "org.springframework:spring-test:${version_spring}"
   }
}

dependencies {
   // Transitivily depending on org.springframework:spring-test:3.1.1.RELEASE
   // Conflict is not resolved according to Gradle (see below) 
   compile "org.jbehave:jbehave-spring:${version_jbehave}"  
}

Essentially I'm calling just "gradle dependencies". However, I'm throwing in various options to ensure that I'm not tricked by any cache.

$ gradle --no-daemon --cache rebuild --recompile-scripts \\
    --refresh-dependencies --rerun-tasks dependencies 
:dependencies
[..]
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dependencies'.
> Could not resolve all dependencies for configuration ':compile'.
   > A conflict was found between the following modules:
      - org.springframework:spring-core:3.1.1.RELEASE
      - org.springframework:spring-core:4.0.4.RELEASE

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug 
        option to get more log output.
[..]

I'm using the latest version of Gradle:

$ gradle -v

------------------------------------------------------------
Gradle 1.12
------------------------------------------------------------

Build time:   2014-04-29 09:24:31 UTC
Build number: none
Revision:     a831fa866d46cbee94e61a09af15f9dd95987421

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy:          2.2.0
JVM:          1.8.0 (Oracle Corporation 25.0-b70)
OS:           Mac OS X 10.8.5 x86_64
Was it helpful?

Solution

There is a typo in the build script - org:springframework should be org.springframework. Fixing the typo should solve the problem.

OTHER TIPS

Have you tried again with Java 1.8.0_05 rather than using that old beta? Just curious.

Also, what do you get when you try to use Spring 3.2.8 instead of that 4.0.4 version?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top