Play Framework 2 recompiles all instead of one file - scala

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.

Related

Play Framework + Intellij: Super slow compilation times

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.

Use import in jsx file play framework

I am using Play Framework 2.5 and ReactJS and I would like to be able to use importin my .jsx files but it seems like I am not allowed to do it because it throws an error in the javascript console saying that import is not recognized.
I added the sbt-reactjs to my build.sbt and I see that ReactJS compiles files each time they are changed, however I still have this importerror.
It can be really problematic as my application will grow because the components will become bigger and for example I would like to divide my navbar and to have Nav.jsand NavItem.js and I want to be able to call any component I have created in any *.js file of my application.
I have heard about babel that could transpile my code in pure javascript code but I would like to have more information about it, more precisely, can it works with Play (ie. will the files be transpiled during the assets command ?).
So my question is: Can I use the import with only the libs I have installed or do I have to add something else to my build.sbt ?
Thank you for your time
Well, from searching on the net, there seems there are lot of ways of doing it. I also ran into same problem. The best example I found was to use webpack for building the jsx files. The following git repo has all u need.
https://github.com/nouhoum/play-react-webpack

How do you use play framework as a library, in a scala project

Use Play Framework as a component got a server up, but configuring the file system paths for routes file, views, etc, give or take having to take care of a thread pool for the embedded play server is a different story. Basing on the aforementioned, I started a template for including play as a library, but it remains unclear how to wire the paths, hopefully in an IDE-import friendly way too, so that Play can be nicely used in an existing non-play project, as a library.
How do you configure the file system paths for the routes file and views?
What else should be handled for being as robust as running as the framework?
Anything special for bundling the project for deploy with Play now included?
Motivation: Adding Play to a project, in the current state of affairs, means wrapping the project definition and structure around Play, and losing full compilation in sbt (because only run completes the compilation when using the play sbt plugin). As future Spray support is vague and Akka http is beta-ish, using Play as a library seems to plug a hole.
Somehow this didn't pop up in google, until someone suggested the link on gitter: https://www.playframework.com/documentation/2.5.x/ScalaEmbeddingPlay
Note that an application.conf file containing the required crypto secret can simply sit under src/main/resources in this embedded mode (up until you want to override it for production as per the documentation about it). This is quite enough for a REST server.
However now back to the docs, in case you want more than REST:
This can be used in conjunction with the Twirl template compiler and Play routes compiler
So for Play view templates (which are twirl templates really), refer to the repo I mention in the question body, in which #JonasAnso kindly enabled exactly that.

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)

how to debug GWT 2.4 in sigel with eclipse?

Exists some way to do hot redeploy when developing with gwt 2.4 in eclipse so i can make some change in the view like the text of a label and then press refresh or something like that and the modification appear? that problem is because the project i'm running takes at least 50 minutes to compile and wait 50 minutes just for one text of a label for example is hard...
Well ok, you're question is somewhat vague, but here's some points that hopefuly will help:
Yep, GWT compilation is slow. If you have a big GWT project, it might take good minutes for it to compile. This is sort of a known issue. What you can do to solve this is split your project into multiple GWT libraries and just compile the library you're currently working with.
Regarding hot deploy: your gwt project has two types of code: client code and server side code. The client side code (which is translated to Javascript by the GWT compiler) is hot-deployable. If you follow the instructions here:
https://developers.google.com/web-toolkit/gettingstarted
you'll have a "magic button" that lets you hot deploy your project into any of the more popular browsers. This means that you can modify your client-side code, refresh your browser and it's updated.
For the server-side code that doesn't work. AFAIK, you need to re-compile your project for those modification to be taken into account.
Have you tried GWT Designer?
Read more : https://developers.google.com/web-toolkit/tools/gwtdesigner/