Getting Twirl Compiler To Work With IDEA 14.0.1 ?

I'm using Typesafe's sbt-twirl plugin, like this in my plugins.sbt:

addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.0.3")

I've set only the sourceDirectories in (Compile, TwirlKeys.compileTemplates) context.

I've also added the plugin to my project with:


No love.

This compiles my templates just fine with sbt. But making the project with IDEA fails to compile the templates. Compiling Scala files is fine.

Currently this is causing me to start up an sbt instance in a Terminal window everytime I have to work with Twirl, use that to compile them, and then go back to IDEA for everything else.

So, what's the magic incantation to get this to work?

Comment actions Permalink

I've hit this too, using Twirl with Akka-Http outside Play. It is slightly simpler than that:

1. Run "sbt twirlCompileTemplates"

2. IntelliJ "Make Project"

but picking up changes automatically would be nice, even if we have to configure the sbt action somewhere in IntelliJ ourselves.

Comment actions Permalink

Twirl compiler is supported only in Play 2.0 projects (in IDEA Ultimate). And this support just refer to SBT. So if you have templates in your project and you need to recompile them, you need to run "sbt compile" from command line. In the future we will support sbt compile for SBT projects as alternative "Make" action, it will fix your problems. Or we will probably support Twirl compiler.

Best regards,
Alexander Podkhalyuzin.

Comment actions Permalink

Hi Alexander,

Thanks for the information. As I noted in my bug report on this topic, using "sbt compile" is definitely a work around, but it has the side effect of making both compilation systems start over, which takes time in a large project. For example:

  1. Do a complete build in Intellij "Make"
  2. Change one template file
  3. Run "sbt compile" - usually only compiles the one file, but sometimes recompiles everything
  4. Now do an Intellij "Make" - usually does nothing, but sometimes recompiles everything

When steps 3 and 4 both recompile everything, it adds minutes to my cycle time. This is an unacceptable delay which is why I filed the bug. IDEA needs to support the Twirl Compiler out of the box like it does many other template processors.




Please sign in to leave a comment.