SBT:从0.13.8更新到1.x.x时,“值映射不是(sbt.TaskKey [sbt.Tests.Output],sbt.TaskKey [sbt.Tests.Output]]的成员”

时间:2019-06-24 21:24:43

标签: scala sbt

我在sbt-mult-jvm插件下面,该插件可以在sbt版本0.13.18上正常工作。

    import com.typesafe.sbt.SbtMultiJvm
    import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys.MultiJvm

    lazy val rootProject = (project in file("."))
    .settings(executeTests in IntegrationTest <<= (executeTests in Test, executeTests in MultiJvm) map {
    case (testResults, multiNodeResults)  =>
        val overall =
        if (testResults.overall.id < multiNodeResults.overall.id)
            multiNodeResults.overall
        else
            testResults.overall
        Tests.Output(overall,
        testResults.events ++ multiNodeResults.events,
        testResults.summaries ++ multiNodeResults.summaries)
    }).
    configs(IntegrationTest, MultiJvm)

但是当我使用迁移documentation on custom claims

将sbt版本更新为1.x.x时
    import com.typesafe.sbt.SbtMultiJvm
    import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys.MultiJvm

    lazy val rootProject = (project in file("."))
    .settings(executeTests in IntegrationTest := (( executeTests in Test, executeTests in MultiJvm).value) map {
    case (testResults, multiNodeResults)  =>
        val overall =
        if (testResults.overall.id < multiNodeResults.overall.id)
            multiNodeResults.overall
        else
            testResults.overall
        Tests.Output(overall,
        testResults.events ++ multiNodeResults.events,
        testResults.summaries ++ multiNodeResults.summaries)
    }).
    configs(IntegrationTest, MultiJvm)

我遇到了错误。

    [info] Done updating.
    [warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
    /Users/rajkumar.natarajan/Documents/Coding/misc/akka-zk-cluster-seed/build.sbt:87: error: `<<=` operator is removed. Use `key := { x.value }` or `key ~= (old => { newValue })`.
    See http://www.scala-sbt.org/1.x/docs/Migrating-from-sbt-013x.html
    settings(compile in MultiJvm <<= (compile in MultiJvm) triggeredBy (compile in IntegrationTest)).
                                ^
    /Users/rajkumar.natarajan/Documents/Coding/misc/akka-zk-cluster-seed/build.sbt:88: error: value map is not a member of (sbt.TaskKey[sbt.Tests.Output], sbt.TaskKey[sbt.Tests.Output])
    settings(executeTests in IntegrationTest <<= (executeTests in Test, executeTests in MultiJvm) map {
                                                                                                    ^
    /Users/rajkumar.natarajan/Documents/Coding/misc/akka-zk-cluster-seed/build.sbt:91: error: value overall is not a member of Any
            if (testResults.overall.id < multiNodeResults.overall.id)
                            ^
    /Users/rajkumar.natarajan/Documents/Coding/misc/akka-zk-cluster-seed/build.sbt:91: error: value overall is not a member of Any
            if (testResults.overall.id < multiNodeResults.overall.id)
                                                        ^
    /Users/rajkumar.natarajan/Documents/Coding/misc/akka-zk-cluster-seed/build.sbt:92: error: value overall is not a member of Any
            multiNodeResults.overall
                            ^
    /Users/rajkumar.natarajan/Documents/Coding/misc/akka-zk-cluster-seed/build.sbt:94: error: value overall is not a member of Any
            testResults.overall
                        ^
    /Users/rajkumar.natarajan/Documents/Coding/misc/akka-zk-cluster-seed/build.sbt:96: error: value events is not a member of Any
            testResults.events ++ multiNodeResults.events,
                        ^
    /Users/rajkumar.natarajan/Documents/Coding/misc/akka-zk-cluster-seed/build.sbt:96: error: value events is not a member of Any
            testResults.events ++ multiNodeResults.events,
                                                ^
    /Users/rajkumar.natarajan/Documents/Coding/misc/akka-zk-cluster-seed/build.sbt:97: error: value summaries is not a member of Any
            testResults.summaries ++ multiNodeResults.summaries)
                        ^
    /Users/rajkumar.natarajan/Documents/Coding/misc/akka-zk-cluster-seed/build.sbt:97: error: value summaries is not a member of Any
            testResults.summaries ++ multiNodeResults.summaries)
                                                    ^
    [error] sbt.compiler.EvalException: Type error in expression
    [error] sbt.compiler.EvalException: Type error in expression

如何解决此错误?

1 个答案:

答案 0 :(得分:0)

答案在您提供的link中;特别是“针对TaskKey的元组扩展(应用和映射)”已删除。

替代方法是使用.value,从而无需使用地图。

您的项目应该看起来像这样(未经测试):

import com.typesafe.sbt.SbtMultiJvm
import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys.MultiJvm

lazy val rootProject = (project in file("."))
  .settings(executeTests in IntegrationTest := {
      val testResults = (executeTests in Test).value
      val multiNodeResults = (executeTests in MultiJvm).value
      val overall = if (testResults.overall.id < multiNodeResults.overall.id)
          multiNodeResults.overall
        else
          testResults.overall
      Tests.Output(overall,
      testResults.events ++ multiNodeResults.events,
      testResults.summaries ++ multiNodeResults.summaries)
    })
  .configs(IntegrationTest, MultiJvm)