Using SORM with Play Framework 2.3.8 - scala

I am going through the Video introduction to Play Framework and, but I am stuck creating a DB object with SORM because the import fails.
I tried to add the dependencies in plugins.sbt, and relaunched activator, but it seems that activator cannot find the dependencies and I get and I get an unresolved error:
addSbtPlugin("org.sorm-framework" % "sorm" % "0.3.14")
addSbtPlugin("com.h2database" % "h2" % "1.4.181")
I got the versions from the Yvis repository. I also tried other versions with no better luck.

should be add as
libraryDependencies += "org.sorm-framework" % "sorm" % "0.3.16"
in build.sbt,
but not as
addSbtPlugin("org.sorm-framework" % "sorm" % "0.3.14")
in project/plugins.sbt

good answer by jilen; also, it can be a good idea to re-run sbt after changing the build.sbt, e.g. (in project root dir):
$ sbt
....
$ compile
...
$ eclipse
(the last two apply to Eclipse users more - and then restart Eclipse to make sure the changes are picked up (Refresh/Clean may not be enough)).

Related

heroku - dependency issue causing Scala Play build to fail on heroku

I'm a bit of newbie to the Scala and the Play framework (2.6.x). See git push heroku master failure screenshot below.
I'm requiring the jsoup dependency in build.sbt (the first one):
libraryDependencies += "org.jsoup" % "jsoup" % "1.11.3"
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test
And using it in my controller:
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
...
val res = scala.io.Source.fromURL(data.url)("ISO-8859-1").mkString
val s = Jsoup.parse(res).title
In addition I attempted to use it as an unmanaged dependency by adding it to the lib/ folder, though I still get the same Heroku error.
Interestingly, the app works OK and without errors locally. Is there something I'm missing? Thanks.
Edit:
Beginning of build log:
Failure:
My guess is, that you created Play project from a template. Initial template contains both build.sbt but also gradle build (build.gradle, gradlew, gradlew.bat. Locally, you use sbt for compilation. However, Heroku picks up Gradle build.
Problem: You added the dependency only to build.sbt, but not into gradle.build file.
If you do not really need Gradle, than I suggest to delete Gradle build files from your repository and try to push again.
If you want to keep Heroku using Gradle, than you have to maintain both types of build files.
There also probably is a way how to instruct Heroku to use sbt as preferred choice.

Unable to find the correct SBT dependency

Today is my first day with Finch.
I am unable to find the right set of SBT dependencies for finch and finagle.
I have tried all the dependencies as shown in Image 2
You are using Scala 2.12 but your dependencies are for Scala 2.11.
This is the correct way to write what you need:
libraryDependencies += "com.github.finagle" %% "finch-core" % "0.13.0"
Build.scala, % and %% symbols meaning

Adding joda-time as manageable dependency via sbt

I'm having trouble using joda-time in my scala project in scala-ide. I have the following line:
import org.joda.time.DateTime
But it causes the following error: object joda is not a member of package org
That's what I did:
I put these lines in build.sbt:
libraryDependencies += "joda-time" % "joda-time" % "2.9.3"
libraryDependencies += "org.joda" % "joda-convert" % "1.8"
Then I ran reload in my sbt session.
Then I ran update in my sbt session.
So what did I miss?
sbt eclipse fixed the thing.
But it was another issue: scala-ide ceased to find main class when trying to run any module extended from App. Removing src folder and creating it again nailed that bitch down.
try to delete all joda-time jars from your computer, and reload the project again,
it seems that the jar is corrupted.

Where to place downloaded ScalaTest jar so sbt uses it across projects?

I've downloaded the ScalaTest jar and have used it as in the example, but now I would like to start using it with sbt. Where do I place the downloaded jar so I can use it with sbt across multiple projects?
You don't download dependencies like ScalaTest manually. The point of using sbt is to declare your project's dependencies and let sbt download them for you automatically.
Add this line in your build.sbt file:
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.0" % "test"
For more details see official doc on setting this up.

When does a SBT package get downloaded/built?

I want to use http://dispatch.databinder.net/Dispatch.html .
The site indicates I must add this to project/plugins.sbt:
libraryDependencies += "net.databinder.dispatch" %% "core" % "0.9.1"
which I did. I then restarted the play console and compiled.
Importing doesnt work:
import dispatch._
Guess I have been silly, but then I never used a build system when using Java.
How must I trigger the process that downloads/builds the package? Where are the jars (or equivalent) stored; can I reuse them? When is the package available for use by the Play application?
It doesn't say you should add it to project/plugins.sbt. That is the wrong place. It says to add to the build.sbt file, on the root of your project. Being a Play project, project/Build.scala might be more appropriate -- I don't know if it will pick up settings from build.sbt or not.
To add the dependency in your Build.scala:
val appDependencies = Seq(
"net.databinder.dispatch" %% "core" % "0.9.1"
)
You probably need to run sbt update.
From the sbt Command Line Reference:
update Resolves and retrieves external dependencies as described in library dependencies.