How do I get Intellij IDEA 12.0 to work with Play Framework 2.1.0 app and Scala 2.10.0?
Asked Answered
A

3

12

So I've been trying to get IDEA 12.0 to work with Play 2.1.0 and Scala 2.10.0. I've just about given up because it's not working for me the way I want it to. Here is a copy of my build.properties, Build.scala, and plugins.sbt. I followed the approach on the playframework site to execute idea with-sources=yes in the play console. I've also tried adding sbt-idea plugin version 1.3.0-SNAPSHOT as seen in plugins.sbt, but nothing seems to work if I want to reference a new view template I just created or a new route. The only way I can work in IDEA is if I have a console open and run sbt compile, go back to IDEA, and it will refresh itself and recognize the new view templates or routes.

plugins.sbt

logLevel := Level.Warn

scalaVersion := "2.10.0"

// The Typesafe repository 
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// Sonatype snapshots to get sbt-idea 1.3.0-SNAPSHOT
//resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1.0")
//addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.3.0-SNAPSHOT")

build.properties

sbt.version=0.12.2

Build.scala

import sbt._
import Keys._
import play.Project._

object ApplicationBuild extends Build {

  val appName         = "admin-application"
  val appVersion      = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    // Add your project dependencies here,
    jdbc,
    anorm
  )

  val main = play.Project(appName, appVersion, appDependencies).settings(
    // Add your own project settings here      
  )
}
Alcantar answered 3/3, 2013 at 3:0 Comment(4)
That's how I work. What's the big deal? Idea can't compile .scala.html files. You also can try to have Play running with "~run", which will compile files as soon as they are written. Not sure Idea will detect these new files right away.Yuriyuria
Yah it's not entirely a huge deal at the moment. I suppose the plugin will be updated soon enough and make this step unnecessary. Thanks for the inputAlcantar
What version of the plugins are you using? They are having some massive problems with the plugins right now. Check this out: #17330477Portuna
if my answer solved you question, please mark as resolved, thanks.Marutani
M
14

If you use IDEA Community edition, there is a SBT Console plugin (see http://plugins.jetbrains.com/plugin?pluginId=5007) that allows you to compile / run your Play project directly in the editor. That's the way I work every day and it is fine (I use the ~run command and then don't care anymore).

You may also add a remote debugger in IDEA that listens to you local server (it it is run with debug mode on) and use it as usual.

If you use IDEA Ultimate edition, JetBrains released a Play Framework plugin that seems to work fine (but I haven't tested it yet). Have a look at these tutorials:

Hope this helps.

Marutani answered 8/3, 2013 at 7:47 Comment(0)
S
0

I think this is how it work currently. As suggested by @pedrofurla, you can keep ~run running on sbt/play console. Sadly, IMO there is no other way IntelliJ can compile your scala views automatically.

Steal answered 3/3, 2013 at 14:55 Comment(0)
V
0

Just add to project/plugins.sbt the following and re-run play idea

   // FIX SBT IDEA  PLAY 2.1  
   resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"  

  // Use the Play sbt plugin for Play projects  
   addSbtPlugin("play" % "sbt-plugin" % "2.1.0")
Verbosity answered 17/3, 2013 at 15:8 Comment(1)
With the latest version of Playframework this «trick» is no longer needed. playframework.com/documentation/2.2.x/Migration22Expository

© 2022 - 2024 — McMap. All rights reserved.