Can't expand macros compiled by previous versions of Scala (scala 2.11.4, sbt 0.13.7, JDK 8)

别来无恙 提交于 2020-01-02 10:06:10

问题


I'm converting a project to Scala 2.11.4 and sbt 0.13.7. I got a lot of errors, some of them are:

can't expand macros compiled by previous versions of Scala
[error]     preloadDevice <<= preloadDeviceTask

for this code:

lazy val settings: Seq[Setting[_]] = inConfig(Android) (Seq(
    // Preload Scala on the device/emulator
    preloadDevice <<= preloadDeviceTask,
    preloadEmulator <<= InputTask(
      (sdkPath)(AndroidProject.installedAvds(_)))(preloadEmulatorTask),

    // Uninstall previously preloaded Scala
    unloadDevice <<= unloadDeviceTask,
    unloadEmulator <<= InputTask(
      (sdkPath)(AndroidProject.installedAvds(_)))(unloadEmulatorTask)
  ))

How do I fix it?

UPDATE:

JDK 8


回答1:


From here: Why doesn't the Def.inputTask macro work in Scala 2.11.1?

In your build.sbt file, make sure you scalaVersion := "2.10.4" instead of something like scalaVersion := "2.11.x"

If you use JDK 8, there is not too much options as Sbt 0.13.x compiled against Scala 2.10.x:

  • use JDK7 for sbt only (by setting specific JAVA_HOME for sbt in your run-script) - your project will still be compiled against JDK8
  • try JDK8 + Scala-2.10 for sbt (it may work but no guarantees of course)
  • build sbt 0.13 against JDK8 by yourself


来源:https://stackoverflow.com/questions/27888182/cant-expand-macros-compiled-by-previous-versions-of-scala-scala-2-11-4-sbt-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!