use squeryl with Play 2 - scala

I am new with Play and Scala and I am trying to import squeryl at build.sbt but without success. I am following the Play for Scala book.
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.squeryl#squeryl;0.9.5-6: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.squeryl:squeryl:0.9.5-6 (/home/felipe/workspace-play/products/build.sbt#L9-20)
[warn] +- products:products_2.11:1.0-SNAPSHOT
sbt.ResolveException: unresolved dependency: org.squeryl#squeryl;0.9.5-6: not found
Here is my build.sbt
name := """products"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
evolutions,
"org.squeryl" % "squeryl" % "0.9.5-6",
// "postgresql" % "postgresql" % "9.1-901-1.jdbc4",
"com.typesafe.play" %% "anorm" % "2.4.0",
"net.sf.barcode4j" % "barcode4j" % "2.0",
"org.scalatestplus.play" %% "scalatestplus-play" % "1.5.1" % Test
)
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases"
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots"
resolvers += "Sonatype releases" at "http://oss.sonatype.org/content/repositories/releases"
resolvers += "webjars" at "http://webjars.github.com/m2"
routesGenerator := InjectedRoutesGenerator

I changed for "org.squeryl" % "squeryl_2.9.0-1" % "0.9.4" and it worked.

Related

Scala play with reactivemongo, not working

I am trying to follow along this tutorial and I can't get reactivemongo to work:
This is my error:
UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.reactivemongo#play2-reactivemongo_2.12;0.11.7.play24: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.reactivemongo:play2-reactivemongo_2.12:0.11.7.play24 (/Users/jwan/Desktop/programming/scala_play/rest-api/build.sbt#L12-20)
This is my built.sbt:
name := """rest-api"""
organization := "com.example"
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.12.4"
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
specs2 % Test,
"org.reactivemongo" %% "play2-reactivemongo" % "0.11.7.play24",
"org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"
)
// Adds additional packages into Twirl
//TwirlKeys.templateImports += "com.example.controllers._"
// Adds additional packages into conf/routes
// play.sbt.routes.RoutesKeys.routesImport += "com.example.binders._"
And this is my application.conf:
# https://www.playframework.com/documentation/latest/Configuration
play.modules.enabled += "play.modules.reactivemongo.ReactiveMongoModule"
mongodb.uri = "mongodb://localhost:27017/getting-started-play-scala"
I can't get sbt run to work. Any ideas?
According to https://mvnrepository.com/artifact/org.reactivemongo/play2-reactivemongo.
Required scala version is 2.11 for reactivemongo 0.11.7.play24.
Try 0.13.0-play26 for scalaVersion := "2.12.4" and play 26.
libraryDependencies += "org.reactivemongo" %% "play2-reactivemongo" % "0.13.0-play26"

why is trouble that Spark issue at sbt in intellij

name := "name"
version := "1.0"
scalaVersion := "2.11.7"
libraryDependencies += "org.apache.spark" %% "spark-core" % "2.0.2"
Log:
[warn] Multiple dependencies with the same organization/name but different versions.
To avoid conflict, pick one version:
[warn] * org.scala-lang:scala-compiler:(2.11.0, 2.11.7)
[warn] * org.scala-lang:scala-library:(2.11.8, 2.11.7)
[warn] * org.scala-lang.modules:scala-parser-combinators_2.11:(1.0.1, 1.0.4)
[warn] * org.scala-lang.modules:scala-xml_2.11:(1.0.2, 1.0.4)
You can exclude the unwanted versions of dependencies by checking dependency tree
or
In dedicated way telling sbt to choose one you want like:
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % "2.11.7",
"org.scala-lang.modules" % "scala-parser-combinators_2.11" % "1.0.4",
"org.scala-lang" % "scala-library" % "2.11.7",
"org.scala-lang.modules" % "scala-xml_2.11" % "1.0.4"
)

How to force Scala to use a different library version?

After adding
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
to build.sbt, and refreshed the project, I got this msg.
SBT project import
[warn] Multiple dependencies with the same organization/name but
different versions. To avoid conflict, pick one version:
[warn] * org.scala-lang.modules:scala-xml_2.11:(1.0.5, 1.0.4)
Changing the above to
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
exclude("org.scala-lang", "scala-reflect")
exclude("org.scala-lang.modules", "scala-xml_2.11")
)
solves the issue. However, instead of excluding scala-xml_2.11 version 1.0.5 from scalatest, I would like to force the scala compiler to use scala-xml_2.11 version 1.0.5 instead of version 1.0.4. (I researched the versions at https://mvnrepository.com.) Thus I tried substituting scalaVersion := "2.11.8" for
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % "2.11.8",
"org.scala-lang.modules" % "scala-xml_2.11" % "1.0.5"
)
This however results in
SBT project import
[warn] Binary version (2.11) for dependency
org.scala-lang#scala-reflect;2.11.8
[warn] in default#myproject$sources_javadoc_2.10;1.0 differs
from Scala binary version in project (2.10).
[warn] Binary version (2.11) for dependency
org.scala-lang#scala-library;2.11.8
[warn] in default#myproject$sources_javadoc_2.10;1.0 differs
from Scala binary version in project (2.10).
[warn] Multiple dependencies with the same organization/name but
different versions. To avoid conflict, pick one version:
[warn] * org.scala-lang:scala-library:(2.11.8, 2.10.4)
[warn] * org.scala-lang:scala-reflect:(2.11.8, 2.10.4)
[warn] [FAILED ]
com.artima.supersafe#supersafe_2.10.4;1.1.0!supersafe_2.10.4.jar(src):
(0ms)
[warn] ==== local: tried
[warn]
/home/user/.ivy2/local/com.artima.supersafe/supersafe_2.10.4/1.1.0/srcs/supersafe_2.10.4-sources.jar
[warn] ==== activator-local: tried [warn] /Development/Activator/activator-dist-1.3.10/repository/com.artima.supersafe/supersafe_2.1...
(show balloon)
What am I supposed to do?
Edit: What else I tried and did not work:
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.5"
)
// ScalaTest
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
[warn] Multiple dependencies with the same organization/name but
different versions. To avoid conflict, pick one version: [warn] *
org.scala-lang.modules:scala-xml_2.11:(1.0.5, 1.0.4)
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml_2.11" % "1.0.5"
)
// ScalaTest
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
Error:Error while importing SBT project:...[info]
Resolving org.scala-sbt#run;0.13.8 ... [info] Resolving
org.scala-sbt#task-system;0.13.8 ... [info] Resolving
org.scala-sbt#tasks;0.13.8 ... [info] Resolving
org.scala-sbt#tracking;0.13.8 ... [info] Resolving
org.scala-sbt#cache;0.13.8 ... [info] Resolving
org.scala-sbt#testing;0.13.8 ... [info] Resolving
org.scala-sbt#test-agent;0.13.8 ... [info] Resolving
org.scala-sbt#test-interface;1.0 ... [info] Resolving
org.scala-sbt#main-settings;0.13.8 ... [info] Resolving
org.scala-sbt#apply-macro;0.13.8 ... [info] Resolving
org.scala-sbt#command;0.13.8 ... [info] Resolving
org.scala-sbt#logic;0.13.8 ... [info] Resolving
org.scala-sbt#precompiled-2_8_2;0.13.8 ... [info] Resolving
org.scala-sbt#precompiled-2_9_2;0.13.8 ... [info] Resolving
org.scala-sbt#precompiled-2_9_3;0.13.8 ... [trace] Stack trace
suppressed: run 'last *:update' for the full output. [trace] Stack
trace suppressed: run 'last :ssExtractDependencies' for the full
output. [error] (:update) sbt.ResolveException: unresolved
dependency: org.scala-lang.modules#scala-xml_2.11_2.11;1.0.5: not
found [error] (*:ssExtractDependencies) sbt.ResolveException:
unresolved dependency:
org.scala-lang.modules#scala-xml_2.11_2.11;1.0.5: not found [error]
Total time: 4 s, completed 01.10.2016 17:46:55
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.5"
)
// ScalaTest
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
exclude("org.scala-lang", "scala-reflect")
exclude("org.scala-lang.modules", "scala-xml")
)
[warn] Multiple dependencies with the same organization/name but
different versions. To avoid conflict, pick one version: [warn] *
org.scala-lang.modules:scala-xml_2.11:(1.0.5, 1.0.4)
My build.sbt
name := "MyProject"
version := "0.1.0"
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.5"
)
// ScalaTest
//libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.0"
//libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
exclude("org.scala-lang", "scala-reflect")
exclude("org.scala-lang.modules", "scala-xml_2.11")
)
The way to exclude specific transitive dependency is this:
Run sbt evicted to figure out which of the project dependencies is pulling in outdated library, let's assume the problematic library is: com.typesafe.slick.
Add the following exclude (the parentheses are important):
("com.typesafe" %% "slick" % "3.1.1").exclude("org.scala-lang.modules", "scala-xml_2.11")
Add this normally as you would be listing dependencies.
This will prevent sbt from including any version of scala-xml that was coming in as a transitive dependency of Slick.
Don't substitute; you need both scalaVersion and libraryDependencies.
Though use
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.5"
)
to avoid bugs when you eventually change scalaVersion.
By removing scalaVersion you get default scalaVersion := "2.10.4" (with your version/settings of SBT, at least) but your libraryDependencies still require 2.11.

akka-spray-websocket template build error

I'm having a little problem with these template from TypeSafe, when I try to import it in IntelliJ I get following message error:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: io.spray#sbt-revolver;0.7.2: not found
[warn] :: com.typesafe.sbt#sbt-aspectj;0.10.1: not found
[warn] :: com.typesafe.sbteclipse#sbteclipse-plugin;2.5.0: not found
[warn] :: com.timushev.sbt#sbt-updates;0.1.7: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] io.spray:sbt-revolver:0.7.2 (sbtVersion=0.13, scalaVersion=2.10)
[warn] com.typesafe.sbt:sbt-aspectj:0.10.1 (sbtVersion=0.13, scalaVersion=2.10)
[warn] com.typesafe.sbteclipse:sbteclipse-plugin:2.5.0 (sbtVersion=0.13, scalaVersion=2.10)
[warn] com.timushev.sbt:sbt-updates:0.1.7 (sbtVersion=0.13, scalaVersion=2.10)
[warn]
[warn] Note: Unresolved dependencies path:
[warn] io.spray:sbt-revolver:0.7.2 (sbtVersion=0.13, scalaVersion=2.10) (C:\Users\jlopesde\akka-spray-websocket\project\plugins.sbt#L1-2)
[warn] +- default:akka-spray-websocket-build:0.1-SNAPSHOT (sbtVersion=0.13, scalaVersion=2.10)
[warn] com.typesafe.sbt:sbt-aspectj:0.10.1 (sbtVersion=0.13, scalaVersion=2.10) (C:\Users\jlopesde\akka-spray-websocket\project\plugins.sbt#L3-4)
[warn] +- default:akka-spray-websocket-build:0.1-SNAPSHOT (sbtVersion=0.13, scalaVersion=2.10)
[warn] com.typesafe.sbteclipse:sbteclipse-plugin:2.5.0 (sbtVersion=0.13, scalaVersion=2.10) (C:\Users\jlopesde\akka-spray-websocket\project\plugins.sbt#L5-6)
[warn] +- default:akka-spray-websocket-build:0.1-SNAPSHOT (sbtVersion=0.13, scalaVersion=2.10)
[warn] com.timushev.sbt:sbt-updates:0.1.7 (sbtVersion=0.13, scalaVersion=2.10) (C:\Users\jlopesde\akka-spray-websocket\project\plugins.sbt#L7-8)
[warn] +- default:akka-spray-websocket-build:0.1-SNAPSHOT (sbtVersion=0.13, scalaVersion=2.10)
sbt.ResolveException: unresolved dependency: io.spray#sbt-revolver;0.7.2: not found
unresolved dependency: com.typesafe.sbt#sbt-aspectj;0.10.1: not found
unresolved dependency: com.typesafe.sbteclipse#sbteclipse-plugin;2.5.0: not found
unresolved dependency: com.timushev.sbt#sbt-updates;0.1.7: not found
[error] (*:update) sbt.ResolveException: unresolved dependency: io.spray#sbt-revolver;0.7.2: not found
[error] unresolved dependency: com.typesafe.sbt#sbt-aspectj;0.10.1: not found
[error] unresolved dependency: com.typesafe.sbteclipse#sbteclipse-plugin;2.5.0: not found
[error] unresolved dependency: com.timushev.sbt#sbt-updates;0.1.7: not found
I know there is a problem on importing it, probably versions of Spray or Scala aren't correct but I don't know how to fix it. Could you provide me some tips for dealing with problems like that?
Thanks
My build.sbt:
organization := "cua.li"
version := "0.4"
scalaVersion := "2.11.5"
libraryDependencies ++= {
val akkaV = "2.3.9"
val sprayV = "1.3.2"
val kamonV = "0.3.5"
Seq(
"com.wandoulabs.akka" %% "spray-websocket" % "0.1.4" withSources() withJavadoc,
"io.spray" %% "spray-json" % "1.3.1" withSources() withJavadoc,
"io.spray" %% "spray-can" % sprayV withSources() withJavadoc,
"io.spray" %% "spray-routing" % sprayV withSources() withJavadoc,
"com.typesafe.akka" %% "akka-actor" % akkaV withSources() withJavadoc,
"com.typesafe.akka" %% "akka-slf4j" % akkaV withSources() withJavadoc,
/*
"org.aspectj" % "aspectjweaver" % "1.8.4" withSources() withJavadoc,
"io.kamon" %% "kamon-core" % kamonV withSources() withJavadoc,
"io.kamon" %% "kamon-spray" % kamonV withSources() withJavadoc,
"io.kamon" %% "kamon-statsd" % kamonV withSources() withJavadoc,
"io.kamon" %% "kamon-log-reporter" % kamonV withSources() withJavadoc,
"io.kamon" %% "kamon-system-metrics" % kamonV withSources() withJavadoc,
"io.kamon" %% "kamon-testkit" % kamonV % "test" withSources() withJavadoc,
// */
"com.typesafe.akka" %% "akka-testkit" % akkaV % "test" withSources() withJavadoc,
"io.spray" %% "spray-testkit" % sprayV % "test" withSources() withJavadoc,
"org.scalatest" %% "scalatest" % "2.2.3" % "test",
"junit" % "junit" % "4.12" % "test",
"org.specs2" %% "specs2" % "2.4.15" % "test",
"ch.qos.logback" % "logback-classic" % "1.1.2"
)
}
scalacOptions ++= Seq("-deprecation", "-encoding", "UTF-8", "-feature", "-target:jvm-1.7", "-unchecked",
"-Ywarn-adapted-args", "-Ywarn-value-discard", "-Xlint")
javacOptions ++= Seq("-Xlint:deprecation", "-Xlint:unchecked", "-source", "1.7", "-target", "1.7", "-g:vars")
doc in Compile <<= target.map(_ / "none")
publishArtifact in (Compile, packageSrc) := false
logBuffered in Test := false
Keys.fork in Test := false
parallelExecution in Test := false
seq(Revolver.settings: _*)
import com.typesafe.sbt.SbtAspectj._
aspectjSettings
fork in run := true
javaOptions <++= AspectjKeys.weaverOptions in Aspectj
Probably missing the repositories to download the dependencies.
Try put this before libraryDependencies:
resolvers ++= Seq(
"Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
"Spray repository" at "http://repo.spray.io/",
"Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases"
)
I've had the same issue but only with sbt-revolver. I've managed to solve it by doing following:
My SBT is set up to use my Artifactory instance in order to retrieve dependencies.
1) In Artifactory I added the repository below to the "Remote Repositories" and made it part of the "remote-repos" virtual repository.
http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases
2) On my ~/.sbt/repositories file, I've made sure my Artifactory repository is configured with the correct URL format (please see below). I've taken the format from SBT's documentation.
artifactory-ivy: http://my.artifactory.com:8081/artifactory/repo/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]

Why does build break with Akka 2.4-SNAPSHOT missing?

I have this in my build.sbt:
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.4-SNAPSHOT"
libraryDependencies += "com.typesafe.akka" %% "akka-slf4j" % "2.4-SNAPSHOT"
When I compile it, it says:
::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.akka#akka-actor_2.10;2.4-SNAPSHOT: not found
[warn] :: com.typesafe.akka#akka-slf4j_2.10;2.4-SNAPSHOT: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
Why is that? Even in here http://doc.akka.io/docs/akka/snapshot/intro/getting-started.html it says it must exist.
In its directory
sbt-version
[info] 0.12.1
In my home user's directory:
$ sbt sbt-version
[info] Set current project to alex (in build file:/Users/alex/)
[info] 0.13.7
Even after this sbt.version=0.12.4, the error remains.
// name := "my_name123"
version := "0.1"
//scalaVersion := "2.10.4"
resolvers += "Akka Snapshot Repository" at "http://repo.akka.io/snapshots/"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
//resolvers += "typesafe-snapshots" at "http://repo.typesafe.com/typesafe/snapshots/"
scalacOptions in ThisBuild ++= Seq("-unchecked", "-deprecation", "-optimise") // , "-feature"
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.4-SNAPSHOT"
libraryDependencies += "com.typesafe.akka" %% "akka-slf4j" % "2.4-SNAPSHOT"
unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "src" / "main" / "scala" )
unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "src" / "main" / "java" )
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.0" % "test"
You must also add the Akka snapshots resolver to your build.sbt:
resolvers += "Akka Snapshot Repository" at "http://repo.akka.io/snapshots/"