0

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: enter image description here

Failure: enter image description here

kriskanya
  • 667
  • 2
  • 6
  • 17
  • I have troubles replicating this. E.g., when I push my Scala Play app to Heroku, I see no such thing as `compilePlatBinaryScala`. My build starts with `remote: -----> Play 2.x app detected remote: -----> Installing JDK 1.8... done remote: -----> Running: sbt compile stage` What about yours? Please post whole build log. – ygor Nov 20 '18 at 19:03
  • Are you using gradle for build? – ygor Nov 20 '18 at 19:15
  • Yes. I've posted the screenshots above. – kriskanya Nov 20 '18 at 19:49

1 Answers1

1

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.

ygor
  • 1,726
  • 1
  • 11
  • 23
  • If I'd like to keep gradle, do simply add a line to `dependencies`? Something like `play 'org.jsoup:jsoup:1.11.3'` (which didn't work btw). – kriskanya Nov 20 '18 at 20:12
  • Hmm, `play "org.jsoup:jsoup':1.11.3"` works for me. Than I run `gradlew.bat compilePlayBinaryScala`. What did not work ? Any error received ? – ygor Nov 20 '18 at 20:53
  • Sorry, should have been more specific. It looks like the build is not failing, but when I visit the url, all I see is a page with `An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command`. Logs don't say anything, just `Release v2 created by user...` – kriskanya Nov 20 '18 at 21:03
  • Yes, I know, you now need to setup your heroku procfile – ygor Nov 20 '18 at 21:07
  • 1
    But that should be a new question. Btw, did my answer solve your compilation problem? – ygor Nov 20 '18 at 21:08