Gradle: overriding a dependency with a different name
I am trying to import org.scalatra:scalatra-atmosphere:2.2.0-RC3
into a Scala 2.10 project. The problem is that this package depends on two non-w61> versions of packages com.typesafe.akka:akka-actor:2.0.4
and com.typesafe.akka:akka-testkit:2.0.4
( org.scala-lang:scala-library:2.9.2
and org.scalatra:scalatra-json:2.2.0-RC3
should work fine as they will be new). As far as I can tell, Akka dependencies do not exist on Maven Central, so we broke the packages.
I would like to override dependencies org.scalatra:scalatra-atmosphere:2.2.0-RC3
manually, replacing non-w61> -version packages with Scala -versioned packages that actually exist:
configurations.all {
resolutionStrategy {
eachDependency { details ->
if (details.requested.group == 'com.typesafe.akka') {
details.requested.name += "_$scalaVersion"
details.useVersion '2.1.0'
}
}
}
}
Unfortunately this method is explicitly forbidden as of Gradle 1.4:
What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> new ModuleRevisionId MUST have the same ModuleId as original one. original = com.typesafe.akka#akka-actor new = com.typesafe.akka#akka-actor_2.10
Is there a legal way to get around this problem?
source to share
Only version changes are supported in 1.4, 1.5 should contain support for changing other dependency attributes.
I think your options are variations to exclude a specific dependency and add it back manually. Examples can be found in the docs
dependencies {
compile("org.scalatra:scalatra-atmosphere:2.2.0-RC3) {
exclude group: 'com.typesafe.akka', module: 'akka-actor'
exclude group: 'com.typesafe.akka', module: 'akka-testkit'
}
// assuming you have this available in a repository your build is configured to resolve against
compile 'com.typesafe.akka:akka-actor:2.0.4-MY.LOCAL.VERSION'
}
source to share