简体   繁体   中英

Flink with Scala IDE and SBT

I'm working on my first Apache Flink wordcount example. My setup is Scala IDE(Eclipse) 4.3.0, Scala 2.10.4, SBT version 0.13.8.

IDE throws error "can't expand macros compiled by previous versions of Scala" for the call env.fromElements

val env = ExecutionEnvironment.getExecutionEnvironment
val text = env.fromElements("first line", "second line")

I able to compile and generate assembly jar with SBT. I'm even able to run/debug the program in IDE. Its just that the error in IDE is annoying and it prevents IDE feature like auto complete, etc. I have a felling its some setting that needs to be tweaked. Can't figure out which one. Any hints?

My build.sbt

import AssemblyKeys._

name := "Flink Test"
version := "0.1.0"
organization := "com.NNN"
scalaVersion := "2.10.4"

javacOptions ++= Seq("-source", "1.7", "-target", "1.7")

libraryDependencies ++= Seq(
  "org.apache.flink" % "flink-scala" % "0.10.1" % "provided",
  "org.apache.flink" % "flink-clients" % "0.10.1" % "provided"
)

resolvers ++= Seq(
  "Akka"                    at "http://akka.io/repository/",
  "Sonatype"                at "https://oss.sonatype.org/"
)

assemblySettings

jarName in assembly := "flink-test.jar"

fork in run := true

assemblyOption in assembly :=  (assemblyOption in assembly).value.copy(includeScala = false)

UPDATE

From the referenced links

Notice that this means that the expansion of white-box macros is not currently possible in the compatibility 2.10 mode. Indeed, macros have known important recent developments between 2.10 and 2.11 which makes type checking compatibility between the two extremely difficult. If you have a significant project that uses 2.10 whitebox macros, you may want to look at 2.10 flavors of the Scala IDE.

and

Since whitebox macros have some incompatible improvements between 2.11 and 2.10, the IDE is not able to expand macros for you in compatibility mode. This probably will remain a long-term limitation of this mode. This is why the -Ymacro-expand:none setting works conjointly with the -Xsource:2.10 setting.

I guess you will have to use an older version of scala IDE or upgrade to scala 2.11. :(


It seems Scala IDE (eclipse) is using a greater version (2.11) to compile your project. Try to change the project's compiler.

In Scala IDE, go to

Project > Propertiers > Scala Compiler

If needed, check Use Project Settings

In Scala Installation, select 2.10 and click Ok .

Maybe you need to clean and full rebuild your project after that.

More info here: http://scala-ide.org/blog/scala-installations.html http://scala-ide.org/blog/Xsource-compatibility.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM