scalaslickplay-slick

scala: Running a play-slick sample results in import error


Absolute Scala beginner here. I installed scala 2.12.1 in macOS X.

I am trying to set up the sample computer-database Play-Slick sample from here

Once I cd into computer-database, I ran sbt run, and it results into this error:

error: not found: value PlayKeys "PlayKeys.playOmnidoc := false"

These are the default contents of build.sbt at the root of the folder:

name := "computer-database-sample"
PlayKeys.playOmnidoc := false

I tried adding the following lines to build.sbt to explicitly import play-slick, before the PlayKeys call:

libraryDependencies ++= Seq(
    "com.typesafe.slick" %% "slick" % "2.0.0",
    "com.typesafe.play" %% "play-slick" % "0.6.0.1",
    "com.typesafe.slick" %% "slick-extensions" % "3.1.0"
)

But I am still getting the same error.

Am I missing anything? Is this how a scala project should be set up?


Solution

  • Stop any modifications you are doing, revert them (you need to have clean version from repo).

    Do the following (not the quickest root, but the one that would allow you to explore other, side things as you go):

    1) Go to repo root directory.

    2) Type: sbt - I it doesn't work, install sbt first

    3) After successful point 2 you should see something along these lines:

    [pdolega@maracuja play-slick]$ sbt
    [info] Loading project definition from /home/pdolega/projects/slick/play-slick/project
    [info] Compiling 1 Scala source to /home/pdolega/projects/slick/play-slick/project/target/scala-2.10/sbt-0.13/classes...
    Missing bintray credentials /home/pdolega/.bintray/.credentials. Some bintray features depend on this.
    Missing bintray credentials /home/pdolega/.bintray/.credentials. Some bintray features depend on this.
    Missing bintray credentials /home/pdolega/.bintray/.credentials. Some bintray features depend on this.
    Missing bintray credentials /home/pdolega/.bintray/.credentials. Some bintray features depend on this.
    Missing bintray credentials /home/pdolega/.bintray/.credentials. Some bintray features depend on this.
    Missing bintray credentials /home/pdolega/.bintray/.credentials. Some bintray features depend on this.
    [info] Set current project to play-slick-root (in build file:/home/pdolega/projects/slick/play-slick/)
    

    >

    4) Type: projects. You will see all the sbt subprojects:

    > projects
    [info] In file:/home/pdolega/projects/slick/play-slick/
    [info]     basic-sample
    [info]     computer-database-sample
    [info]     docs
    [info]     iteratee-sample
    [info]     play-slick
    [info]     play-slick-evolutions
    [info]   * play-slick-root
    [info]     samples
    > 
    

    4) Type project computer-database-sample <- this will make your desired subproject active.

    > project computer-database-sample
    [info] Set current project to computer-database-sample (in build file:/home/pdolega/projects/slick/play-slick/)
    [computer-database-sample] $
    

    5) Now you may for install do test which will run compilation and all the tests after that. Or you may type run to start this sample Play application.

    [computer-database-sample] $ run
    [warn] Credentials file /home/pdolega/.bintray/.credentials does not exist
    
    --- (Running the application, auto-reloading is enabled) ---
    
    [info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
    
    (Server started, use Ctrl+D to stop and go back to the console...)