Play Framework + Intellij: Super slow compilation times - scala

Is there a way to fix the horrible slow compile times of Play and Scala.
It compiles constantly hudrends of java classes.
Has anyone faced this and solved it?
Thanks

If you run your application with sbt-run, or run as play application in paid version of intellij, instead of running NettyServer or ProdServerStart, then play will use multiple class loaders to only recompile modified files instead of all classes.

I removed completely the enhancer plugin, and the compilation times are now normal.
IMO this is a huge issue of the play framework.
I got the idea from this post, however I did not simply disable the plugin and I did not create any getters and setters. I only commented out the plugin locally. When the app is deployed the plugin is there generating the setters and getters.

Related

Scala ClassNotFoundException Random Constant

I have quite a few mixed scala and java projects. They will run just fine up to some seemingly random time when they don't.
Compile goes fine, with zero errors or warnings, yet on run I get the infamous
ClassNotFoundException
In this current project I have only Scala files, and I deleted all of them and left it at a simple Test object with main method.
YET IT STILL SAYS ClassNotFoundException
I have scoured the net, and tried everything I have found.
Has anyone had this experience, and moreover, are there any suggestions?
Are you trying to run a run configuration for a class that have been deleted? If you're using Intellij and pressing Shift-F10 it will happily try to run a configuration even though the class does not exist anymore.
My other related question actually provides more insight and provides a solution to this problem.
Running Objects in Play 2.0 Framework
Hope it helps when everyone is using Scala in a few years...

Play Framework How to Compile Views for Distribution

I have common views that I want to share across multiple Play Framework 2.2.1 applications. I'm thinking packaging them up into a single library and publishing them to our Maven repo is the way to go, but something isn't working correctly during the compile phase.
My project has a single file My/Namespace/myView.scala.html. After compiling my package jar has a file named exactly as my view. My/Namespace/MyView.scala.html I was expecting to see some class files.
The play framework seems to do something very similar https://github.com/playframework/playframework/blob/master/framework/src/play/src/main/scala/views/helper/twitterBootstrap/twitterBootstrapFieldConstructor.scala.html and looking at their Maven package this seems to compile into a twitterBootstrapFieldConstructor class (along with all the meta classes scala generates):
I'm guessing i'm missing something in my SBT configuration that makes it compile scala.html files...but i'm just not seeing it.
Anyone have some insight into what i should be doing?
It appears the best option at this time is to make use of the Twirl library https://github.com/spray/twirl which is the template engine wrapped up into a similar but distinct API.
sbt .13 support is in a testing phase see https://github.com/spray/twirl/issues/15#issuecomment-32272389 as it appears there's going to be some reconciliation of this project & play's templating libraries (one using the other)

Play Framework 2 recompiles all instead of one file

Play Framework has a splendid auto-compile feature which I like very much. But our project contains like 1300 java files and anytime I change one of them and refresh the page in dev mode Play recompiles all of them instead of just one file. Should it be this way? Or is there a way to force play compile only really new files?
Try the latest version of Play: 2.1.1-RC1
https://groups.google.com/d/msg/play-framework/E_yLjyIpDMY/KUJCbMlLV2AJ
They state "Fixed some compilation problems on Windows". And it works in my case. Now it recompiles exactly one class instead of 10-20 previously.

Problems with GWT 2.4

I compiled the version in svn tagged as gwt2.4rc. Now there are a
couple of more libraries than I had the last time. Are the any
instructions on which library is needed for what? I tried it with only
the standard libraries (servlet, servlet-deps, user) but I get the
following error when a requestfactory call is made:
java.lang.NoSuchMethodError:
com.google.gwt.core.client.impl.WeakMapping.setWeak(Ljava/lang/
Object;Ljava/lang/String;Ljava/lang/Object;)
I tried declaring the requestfactory-client and requestfactory-server
jars as dependencies, but i doesn't help. I am using maven to manage
my dependencies.
I would go back to 2.4 beta, but I need the drag&drop features that
were introduced later.
Does anybody has an idea what could be wrong? or any hints how i can
dig deeper into this? I spend a lot of time trying to figure this out
but without any success :(
Do I need to provide more information?
Regards,
arne
Are you sure you deployed the 2.4-rc1 gwt-servlet.jar in your war/WEB-INF/lib ? Also, make sure you override the SDK for the gwt-maven-plugin: http://mojo.codehaus.org/gwt-maven-plugin/user-guide/using-different-gwt-sdk-version.html
That being said:
when using Maven, you shouldn't use gwt-servlet-deps but instead reference org.json:json and javax.validation:validation-api
requestfactory-server can be used instead of gwt-servlet if you only use RequestFactory on the server-side (no GWT-RPC, no SafeHtml, no RegExp, etc.); requestfactory-client is to be used for Java clients (such as Android), not the case here.

How to get Scala imports working in IntelliJ IDEA with the Play framework?

I'm using the Scala plugin for IDEA and normally, it works (almost) perfectly.
However, it seems to have problem with the import statements for the Play framework: I often get the error "Cannot resolve symbol x". Now that doesn't stop the program from working, but it makes autocompletion completely useless.
Example: import org.scalatest.junit._
I already added /opt/play/framework/src and /opt/play/framework/play-1.2.2RC2.jar to classes and sources of my project. (using "Project Structure")
Any ideas on how to solve this? Or is this simply a bug?
(I am using Scala 2.9.0.1, IDEA 10.5 and Scala Plugin 0.4.1084)
Try to add tmp/generated to your sources as well. Eclipse also has this issue, since the Play Framework generate the source files from the templates. See Errors in Eclipse for Scala project generated by Play Framework.