Play Framework 2.4 @routes.WebJarAssets.at Compilation Error in IntelliJ IDEA 14.1.3

1.4k views Asked by At

I'm trying to use WebJars with Play Framework 2.4.0, in Intellij IDEA 14.1.3.

I have SBT 1.7.0 plugin and Scala 1.5.2 plugin (with project Scala version 2.11.6).

My application works well when I run it from the terminal ($ activator run or $ sbt run) but I have compilation error and no auto-completion in IntelliJ IDEA on my templates (cf. below), on the #at() method of @routes.WebJarAssets.at(..) (and not on the @routes.Assets.at) :

enter image description here

There is my route conf file :

# Map static resources from the /public folder to the /assets URL path
GET    /assets/*file     controllers.Assets.at(path="/public", file)

# WebJars integration into Play Framework : http://www.webjars.org/documentation
GET    /webjars/*file    controllers.WebJarAssets.at(file)

For information, I tried to reimport project from SBT built-in builder after deleting my .idea folder but that did not work.

Any solution ?

1

There are 1 answers

1
Alexander B On BEST ANSWER

As far as I can see IDEA 14.1.3 Scala/Play plug-in doesn't support the InjectedRoutesGenerator that is the default routesGenerator starting with Play 2.4.

webjars-play's 2.4.0-1 WebJarAssets controller implements this injection mechanism.

See a similar bug report at JetBrains that probably has the same cause.

You could use the regular Assets controller instead until the bug is fixed. WebJars are automatically extracted into a lib folder relative to your public assets for convenience (see play's documentation for webjar assets)

<link rel="stylesheet" media="screen" href="@routes.Assets.versioned("lib/bootstrap/css/bootstrap-theme.css")">

Eventually another workaround would be to fall back to static router by deactivating InjectedRoutesGenerator in build.sbt (untested). This would however require quite some refactoring of your application to implement static methods in controllers again.