I have installed Flink, Scala and sbt
Flink Version: 1.9.1
Scala Version: 2.10.6
Sbt Version: 1.3.7
I made relevant changes in build.sbt.
Compile command is failing
Here is the relevant information.
Any information is greatly appreciated
**Versions Information
[osboxes#osboxes local]$ scala -version
Scala code runner version 2.10.6 -- Copyright 2002-2013, LAMP/EPFL
[osboxes#osboxes local]$ flink --version
Version: 1.9.1, Commit ID: 4d56de8
[osboxes#osboxes readcsvfile]$ sbt -version
sbt version in this project: 1.3.7
sbt script version: 1.3.7
** build.sbt changes
val flinkVersion = "1.9.1"
val flinkDependencies = Seq(
"org.apache.flink" %% "flink-scala" % flinkVersion % "provided",
"org.apache.flink" %% "flink-streaming-scala" % flinkVersion % "provided")
** Compile Errors
sbt:readCsvfile> compile
[info] Updating
[info] Resolved dependencies
[warn]
[warn] Note: Unresolved dependencies path:
[error] stack trace is suppressed; run last update for the full output
[error] (update) sbt.librarymanagement.ResolveException: Error downloading org.apache.flink:flink-streaming-scala_2.13:1.9.1
[error] Not found
[error] Not found
[error] not found: /home/osboxes/.ivy2/local/org.apache.flink/flink-streaming-scala_2.13/1.9.1/ivys/ivy.xml
[error] not found: https://repo1.maven.org/maven2/org/apache/flink/flink-streaming-scala_2.13/1.9.1/flink-streaming-scala_2.13-1.9.1.pom
[error] Error downloading org.apache.flink:flink-scala_2.13:1.9.1
[error] Not found
[error] Not found
[error] not found: /home/osboxes/.ivy2/local/org.apache.flink/flink-scala_2.13/1.9.1/ivys/ivy.xml
[error] not found: https://repo1.maven.org/maven2/org/apache/flink/flink-scala_2.13/1.9.1/flink-scala_2.13-1.9.1.pom
[error] Total time: 4 s, completed Jan 30, 2020 3:59:12 PM
sbt:readCsvfile>
Few points I want to mention here regarding the SBT dependencies issues are:
Please add scalaVersion := "2.12.11" in build.sbt file like this, which includes the Scala version in your SBT dependencies automatically due to this%%.
name := "flink-streaming-demo"
scalaVersion := "2.12.11"
val flinkVersion = "1.10.0"
libraryDependencies += "org.apache.flink" %% "flink-scala" % flinkVersion % "provided"
libraryDependencies += "org.apache.flink" %% "flink-streaming-scala" % flinkVersion % "provided"
If you want Scala version specific SBT dependencies then use % like this:
libraryDependencies += "org.apache.flink" % "flink-scala_2.12" % flinkVersion % "provided"
libraryDependencies += "org.apache.flink" % "flink-streaming-scala_2.12" % flinkVersion % "provided"
In worst case if all these does not work then simply delete or rename these existing .sbt and .ivy2 hidden folder in your system home directory, where your all dependecies and plugins get sotred after downloading from maven central and then refresh/build the SBT project.
SBT dependency format
libraryDependencies += groupID % artifactID % revision % configuration
Meaning of % and %%
%: A method used to construct an Ivy Module ID from the strings you supply.
%%: When used after the groupID, it automatically adds your project’s Scala version (such as _2.12) to the end of the artifact name.
NOTE: To get more details click here.
summing up the comments since perhaps it is a bit hard to know what you should do
In general, if you get an "Unresolved dependencies" error, look at mvnrepository.com, search for your artifact:
https://mvnrepository.com/artifact/org.apache.flink/flink-scala
This tells you (second column) which Scala versions are supported by it. In this case, the library is available for 2.11.x and 2.12.x.
Thus, you have to use a Scala version compatible with that in your build, in build.sbt:
ThisBuild / scalaVersion := "2.12.10"
Related
I am new to the Scala env and trying to build a test project using play with 'scalikejdbc' for SQL integration. Here is my build.sbt following the documents at http://scalikejdbc.org/documentation/playframework-support.html
name := """run"""
organization := "com.example"
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.13.10"
libraryDependencies ++= Seq(
guice,
"org.scalatestplus.play" %% "scalatestplus-play" % "5.0.0" % Test,
"com.h2database" % "h2" % "1.4.200", // your jdbc driver here
"org.scalikejdbc" %% "scalikejdbc" % "4.0.0",
"org.scalikejdbc" %% "scalikejdbc-config" % "4.0.0",
"org.scalikejdbc" %% "scalikejdbc-play-initializer" % "2.8.0-scalikejdbc-3.5",
"com.typesafe.play" %% "play-ws" % "2.3.1"
)
dependencyOverrides += "org.fluentlenium" % "fluentlenium-core" % "0.10.3"
// Adds additional packages into Twirl
//TwirlKeys.templateImports += "com.example.controllers._"
// Adds additional packages into conf/routes
// play.sbt.routes.RoutesKeys.routesImport += "com.example.binders._"
I have also aded the below on plugins.sbt
resolvers += Resolver.url("SBT Plugins", url("https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)
However while trying to update the application before running i am getting the below issue
[error] (update) found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[error]
[error] * org.scala-lang.modules:scala-parser-combinators_2.13:2.1.0 (early-semver) is selected over {1.1.2}
[error] +- org.scalikejdbc:scalikejdbc-core_2.13:4.0.0 (depends on 2.1.0)
[error] +- com.typesafe.play:play_2.13:2.8.18 (depends on 1.1.2)
[error] +- com.typesafe:ssl-config-core_2.13:0.4.3 (depends on 1.1.2)
[error]
following are relevant versions :
sbt script version: 1.8.0
play version :2.8.18
Scala code runner version 3.2.1 but using as scalaVersion := "2.13.10" in sbt.
version conflict(s) in library dependencies; some are suspected to be binary incompatible
This means that you have at least two dependencies that are needing a 3rd one but they need 2 different versions which are supposed to be incompatible.
As only one can be included and used for your code, SBT is telling you: "I am going to pick one version but there are risks that this version won't work as you might have code that rely on the other version and this might be incompatible".
You have 2 options:
force a version (for scala-parser-combinators) with dependencyOverrides for instance if you know that actually there's no incompatibility, or at least on the way you use the libraries
upgrade or downgrade the libraries (scalikejdbc or play) so that all libraries depend on the same version of the conflicting one (scala-parser-combinators).
In this case, I would downgrade scalikejdbc because there's no newer play version (as of today)
I'm trying to use log4j2 in scala.
Below is my build.sbt
name := "trial"
version := "0.1"
scalaVersion := "2.13.1"
libraryDependencies += "org.apache.logging.log4j" %% "log4j-api" % "2.12.1"
libraryDependencies += "org.apache.logging.log4j" %% "log4j-core" % "2.12.1"
libraryDependencies += "org.apache.logging.log4j" %% "log4j-api-scala" % "2.12.1"
How to resolve these errors:
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading org.apache.logging.log4j:log4j-api_2.13:2.12.1
sbt.librarymanagement.ResolveException: Error downloading org.apache.logging.log4j:log4j-api_2.13:2.12.1
not found: /Users/username/.ivy2/local/org.apache.logging.log4j/log4j-api_2.13/2.12.1/ivys/ivy.xml
Note :
There is no directory /Users/username/.ivy2/local/
but I can see there is /Users/username/.ivy2/cache/
and plugins log4j-api,core,api-scala are present in cache.
The IDE i'm using is IntelliJ IDEA.
There are multiple problems
You are using Scala 2.13 however the latest build of log4j-api-scala is for Scala 2.12.
The latest version of log4j-api-scala is 11.0 not 2.12.1
log4j-api and log4j-core are Java libraries so we should use single % instead of double%%
I'm taking the coursera scala course. I downloaded the sample project, but I can not compile it. Giving me error when I run the console command.
build.sbt:
name := course.value + "-" + assignment.value
scalaVersion := "2.12.4"
scalacOptions ++= Seq("-deprecation")
// grading libraries
libraryDependencies += "junit" % "junit" % "4.10" % Test
// for funsets
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4"
resolvers += "Artima Maven Repository" at "http://repo.artima.com/releases"
// include the common dir
commonSourcePackages += "common"
courseId := "bRPXgjY9EeW6RApRXdjJPw"
Error:
> console
[info] Updating root
[info] Resolved root dependencies
[trace] Stack trace suppressed: run last *:coursierResolution for the full output.
[error] (*:coursierResolution) coursier.ResolutionException: Encountered 1 error(s) in dependency resolution:
[error] org.scalatest:scalatest_2.12:2.2.4:
[error] not found:
[error] /Users/joaonobre/.ivy2/local/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[error] /Users/joaonobre/.sbt/preloaded/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[error] /Users/joaonobre/.sbt/preloaded/org/scalatest/scalatest_2.12/2.2.4/scalatest_2.12-2.2.4.pom
[error] https://repo1.maven.org/maven2/org/scalatest/scalatest_2.12/2.2.4/scalatest_2.12-2.2.4.pom
[error] http://repo.artima.com/releases/org/scalatest/scalatest_2.12/2.2.4/scalatest_2.12-2.2.4.pom
[error] Total time: 1 s, completed Dec 22, 2017 4:16:17 PM
scala -version
Scala code runner version 2.12.4 -- Copyright 2002-2017, LAMP/EPFL and Lightbend, Inc.
Any idea how to fix it?
Thanks.
As suggested by #laughedelic, Scala 2.12 does not have scalatest-2.2.4. As a result, sbt cannot find the related scalatest pom file. You can pick any of the versions mentioned here.
For instance, try changing scalaTestDependency version to 3.0.5 in the CommonBuild.scala file
lazy val scalaTestDependency = "org.scalatest" %% "scalatest" % "3.0.5"
Here is the course link (Practice Programming Assignment of Week1)
I am trying the add the mockito dependency in the SBT build file, But it gives below unresolved dependency exception.
I am not sure if its the issue with Scala and Mockito version.
scalaVersion := "2.11.8"
libraryDependencies ++= Seq("org.scalatest" % "scalatest_2.11" % "2.2.2" % "test",
"org.mockito" % "mockito-all" % "1.9.5" % "test")
Exception :
trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output.
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: org.mockito#mockito-all;1.9.5: not found
[error] (*:update) sbt.ResolveException: unresolved dependency: org.mockito#mockito-all;1.9.5: not found
[error] Total time: 23 s, completed Oct 12, 2017 3:13:16 PM
I have tried with different mockito version 1.8.5 as well. But no luck.
Thanks in advance.
I strongly advise not to use mockito-all with sbt, but use mockito-core instead. SBT is smart build system and it will figure out all dependencies for mockito-core, details. Here how your dependencies might look:
libraryDependencies ++= Seq (
"org.scalatest" %% "scalatest" % "3.0.1" % "test",
"org.mockito" % "mockito-core" % "2.8.47" % "test"
)
The Mockito documentation advises to not use mockito-core as a dependency, but to use mockito-scala which will pull what's needed. You could use the %% notation which automatically pulls the version appropriate for the Scala version you are using. It's also worth looking on Maven to see which is the latest mockito-scala version for the Scala version you are using.
So the build.sbt for Mockito used with Scala with today's latest version would be:
libraryDependencies ++= Seq (
"org.mockito" %% "mockito-scala" % "1.15.0" % "test"
)
I am trying to create a REST service using Spray Servlet, but does not compile.
Below you can find my build.sbt:
name := "someservice"
version := "0.0.1"
scalaVersion := "2.10.0"
resolvers += "spray repo" at "http://repo.spray.io"
libraryDependencies += "io.spray" % "spray-servlet" % "1.0-M3"
libraryDependencies ++= Seq(
"io.spray" % "spray-servlet" % "1.0-M3",
"io.spray" % "spray-util" % "1.0-M3",
"io.spray" % "spray-http" % "1.1-M7",
"com.typesafe.akka" %% "akka-actor" % "2.1.0",
"org.specs2" %% "specs2" % "1.13" % "test",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" artifacts Artifact("javax.servlet", "jar", "jar")
)
There error I get com 'sbt update compile' is:
[error] bad symbolic reference. A signature in package.class refers to term Either
[error] in package scala which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling
[error] package.class.
[error] bad symbolic reference. A signature in package.class refers to type Future
[error] in package akka.dispatch which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when
[error] compiling package.class.
[error] two errors found
[error]
(compile:compile) Compilation failed
Do I have to add the scala library to the sbt build file as well or am I missing something else?
tld;dr: try replacing 1.0-M3 with 1.1-M7
It looks like the Spray artifacts you're using were compiled against Scala 2.9.2, which is not binary compatible with Scala 2.10. Usually, Scala artifacts contain the Scala binary version in the artifact name, precisely because major Scala versions are not binary compatible.
Later spray-util milestones were compiled against Scala 2.10.0-RC5 (based on the pom), which technically should work.
Solved by using all the same spray versions (1.1-M7) and upgrading to Scala 2.10.1