3

我正在尝试导入org.scalatra:scalatra-atmosphere:2.2.0-RC3Scala 2.10 项目。问题是这个包依赖于两个非 Scala 版本的包com.typesafe.akka:akka-actor:2.0.4com.typesafe.akka:akka-testkit:2.0.4org.scala-lang:scala-library:2.9.2并且org.scalatra:scalatra-json:2.2.0-RC3应该可以正常工作,因为它们会更新到最新版本)。据我所知,Akka 依赖项在 Maven Central 上不存在,所以我们有损坏的包。

我想org.scalatra:scalatra-atmosphere:2.2.0-RC3通过用实际存在的 Scala 版本包替换非 Scala 版本包来手动覆盖 的依赖项:

configurations.all {
    resolutionStrategy {
        eachDependency { details ->
            if (details.requested.group == 'com.typesafe.akka') {
                details.requested.name += "_$scalaVersion"
                details.useVersion '2.1.0'
            }
        }
    }
}

不幸的是,从 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

是否有解决此问题的合法方法?

4

1 回答 1

4

1.4 仅支持版本更改,1.5 将包含对更改依赖项的其他属性的支持。

我认为您的选择是排除特定依赖项并将其手动添加回来的变体。示例可以在文档中找到

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' 
}
于 2013-01-29T09:17:24.610 回答