How Can Play and Jrebel Work Together? - scala

Play recompiles files for you automatically after changes have been made and the browser refreshed. This makes Jrebel unnecessary for Play.
Our flagship product JRebel lets you change your application code and
just hit refresh in your browser and you’ll see the changes instantly.
Play! framework offers something similar. I have not read enough
source code but it seems that with custom extra metadata (see your
app’s tmp/bytecode/DEV), a stateless model and the custom runner (play
run) they will give you the power of changing code on the fly. If they
don’t support the change they will restart your app automatically for
you.
http://zeroturnaround.com/rebellabs/my-top-5-play-framework-features/
However, if you include a library in the Play project that you are making chages to then Jrebel can come in handy so those changes are auto-compiled.
Should Jrebel be included in the Play project or in the library? What would be the simplest workflow?

Easiest way to include JRebel in any project is to follow quickstart guide http://zeroturnaround.com/software/jrebel/quickstart/eclipse/
Most importantly there are 3 parts.
Download JRebel and activate license
Generate rebel.xml config file into library .jar files
Run the play process with jrebel.jar javaagent
After that JRebel will monitor changes in folders defined in rebel.xml and it will reload changes to the .jar library that you are developing.

Related

Is there any way of configuring Oracle ATG to load java class changes dynamically?

I am interested in setting up a development environment for ATG in which changes on class will take effect immediately after the build is done, without restarting server and building again the ear file.
I have searched in the product documentation but the only thing I saw you can configure to load dynamically would be the configuration files section.
Is there any other way of configuring the environment for better productivity?
Use JRebel. That will do dynamic re-loading for java classes, property files and other deployable assets. Great for productivity.
If your purpose is to debug and most of time is getting wasted packing and unpacking the ear, you can always use remote debugging with JBoss and Eclipse, but for major changes like adding a method wont be working in that case. One solution to this is use Java DCEVM which will dynamically update code in the JVM. Its a simple jdk just point your Java_home to this jdk and in debug mode you can add code to you class see changes. Use the below link for more information about DCEVM
https://github.com/dcevm/dcevm

eclipse: rebuild a project and all libraries

I'm creating a Java project which includes a few libraries written by myself. However these libraries are not finished and sometimes require some edits. Because I'm working by myself, I find this more efficient than finishing all libraries perfectly before using them in my project.
My question is: is it possible to automatically rebuild a modified library when building the project which uses it?
Subquestion: what is the optimal configuration for my purposes? Should I export libraries as jar and copy them into the final project or should I configure buildpaths of my project to retrieve them in their respective folders?
Subsubquestion: is it correct to use .jar libraries in the same way that one uses dynamic libraries in c++?
If you have Eclipse set to "build automatically", it'll take care of rebuilding the library projects whenever you make changes, as you go along. You should set your client program to depend on either the Eclipse projects (if doing everything inside Eclipse) or the Maven artifacts (if using m2e). I strongly prefer using Maven for all my Java builds, but it might be overkill for something small. Whatever you do, don't manually export and reimport the libraries.
All libraries in Java are dynamic, and a C++ .so or .dll is the basic equivalent.

Playframework Plugin non-functional in IntelliJ IDEA 12

I have just downloaded and installed IntelliJ IDEA 12 (Ultimate Edition), under Ubuntu, with high hopes that I could cash-in on IJ's tight integration with Scala and the Play Framework.
I have a fully functional install of Play at /home/ryan/play-2.0.4 and from searching around, it seems that all one has to do is perform a play idea on a play project at the command-line and simply open the project in IntelliJ.
However, if I do this: I can't even verify that the Playframework plug-in is even active/functioning. There is no syntax highlighting in Play config files or templates, absolutely no Playframework options in the pull-down menu. If I right-click the project, choose "Add Framework support ..." and "Play" is not even on the list, I can't just create a new "Play" project from scratch in the IDE either (not sure if that is even supported).
If I click File -> Settings -> Play Configuration, I have the Home and Working directory set to: /home/ryan/play-2.0.4. I should note that I am using Play under Eclipse with no issues (except there isn't any Play integration with Eclipse --- hence the reason why I am giving this a try in IJ). If I didn't know any better: I'd declare IJ 12's Play support as a miserable failure, but given all the postings suggesting that play 2.0 integration with IJ 12 is "very easy" - perhaps there is something I am missing?
Most probably you need to download and/or install Play 2.0 Support plugin + dependencies (most probably you will need to find it in Browse repositories section, it is not the same plugin as bundled Playframework support!)
I can ensure you that I'm just sitting and playing with Play 2.0 in Idea 12 with new support, and it works quite nice.
Go to Settings > Plugins section and check if you have newest version of mentioned plugin and if isn't blocked by some error (ie. missing dependency), try to resolve all missing dependencies, restart the IDE, and compile (or run) your applications at least once.
I didn't test it to the end yet, but I can see large progress in the support especially in templates and controllers. routes file allow easily navigate to the target actions, but as I can see there is no syntax highlighting in conf file.
There is even possible now to run and debug Play application from the menu.
In general if you'll enable the Play plugin you will see it for sure :)
You don't have to install additional plugins. You only have to run your application once, and afterwards IntelliJ highlights everything etc.
Look here: http://devnet.jetbrains.net/message/5473435?tstart=0#5473435

Sharing source/libraries between sbt and Scala play framework

I have two related apps I am developing in Scala. One is a server-side processing engine built using SBT and running headlessly doing some number crunching (on a cron job). The other is a web site written in Scala and running on the play framework.
I have code that I would like to be able to share between the two, but as each of them (SBT and Play) has their own ideas about directory structure and how to build things it's pretty unclear to me how I should do this. I'd hate to copy and paste the .scala files - but I'm also not keen on using sym links and having them both build from the same files.
If it were possible, I would accept getting the Play scripts to run SBT to build libraries as required. If it were the only way then I would also be OK with using SBT to build jars for Play and then copying them into place. But I'm often developing both simultaneously (they are parts of a bigger app) and it would all work much more smoothly if they updated together. Is this even possible, or if there's another simpler technique I'm missing?
Thanks, Alex
The only easy way is to build JARs with SBT and make Play use them.
On how to copy, you have 2 options:
You manually build and copy them over to the libs folder in Play (you can script that to make it less annoying)
You use a custom repository for your JARs (ala Nexus repository) and use Play dependencies.yml to point to that repo and update. With this you would also need to run play sync --deps often and to tweak the versions, so I'm not sure if it makes too much sense during dev (it makes more sense once the JARs are complete though)

Efficient dev cycle with Maven, Tomcat/Glassfish, Archetype?

So far i've been using tomcat and glassfish to develop a testing webapp, without maven. And the usual development-till-deploy cycle is simple :
develop in eclipse ide, with a WebContent folder, which is the root webapp folder that has the WEB-INF, web.xml, WEB-INF/lib, n all. The compiled classes location in eclipse is set to WEB-INF/classes.
after coding, i could just click on the reload button in glassfish admin console for that specific webapp. In tomcat, i believe it's reload also in the tomcat manager.
i could access the web application in the browser
Now if i would like to create a new webapp, that'll make use of latest stuffs of jsf, spring, jpa, hibernate, postgresql :
what recommendation of archetype should i use in the creation of the project ?
can i still use my previous steps of development? because i think it's very easy without having to repackage everything into a war file, or copying it into the tomcat's webapp folder everytime i want to test. Saving the files in eclipse, hit on the reload in the admin console / tomcat manager, and i could instantly test the updated webapp.
Or what do you usually do in the webapp development cycle ? Please share your experiences, =)
Thank you !
Development Cycle with Maven and Friends
Use Maven to drive your code-build-test-deploy-release cycle.
Start with Maven Archetype that suits closest to your web-app. This will create the whole folder structure for you and will add Jar depencies.
Use an embeded light-weight server like Jetty, this will be very fast on dev machine without sucking resources and is highly configurable. Plus, you can set it to auto-reload changes.
Most of Maven project are supposed to be test-driven. Of which Maven takes care of using it's surefire plug-in. So, every build will have a test phase.
You can define multiple profile for various environments (test, dev, prod, Win, Unix..). These profile will alter the behaviour of the project to be compatible with the environment.
Use Cargo, again a Maven plugin to deploy your builds on test or production server, which can be Glassfish, Tomcat, Jetty or any oter webserver.
Use Liquibase with or without Maven :) to manage your database changes the same way you manage your code change.
I came from almost similar project as yours in my previous company. Development with Maven makes things so smooth and the change is appreciable.
A little Google search shows that someone has worked on archetypes for JSF and JPA with Spring
Edit#1 -- added more details
Feasibility and Ease of Use
Maven is born out of neccessity to simplify the dev process for large and distributed code.
Maven is very well integrated with Eclipse -- so it's painless.
Jetty keeps monitoring source folders, so your changes gets deployed almost immediately.
You can customize the build to skip tests, to not build dependecies. When you just edit a UI component, Jetty will silently copy it to "target" folder.
If you're worried about copying and redeploying. You must read THIS to see how efficiently things are done, keeping in mind that you don't have to compile-test-deploy everytime you change a JSP or HTML.
That said, I would like to mention that Maven might be a challanging learning. This is an object oriented way of development cycle, to say. Most of us, who are used to build script, can find a bit tedious/verbose initially.
Resources
I would suggest to go through the following resources
Maven Book - Maven basics
Automated Deployment with Maven - going the whole nine yards If you can, literally follow this pattern.
Maven 2 Effective Implementation -- this book really helped us a lot.
for the q2 :
You can still run/debug app with tomcat from within the IDE (eclipse) even if you change the directory structure. (like the maven dir structure instead of eclipse's dynamic web dir structure)
Project properties - >
project facets - >
Dynamic Web Module ->
Click the appearing "further configuration available"
and set your content dir and context root.
You dont have to package everytime you want to run/debug it.
Another option is using Jetty
And I am sure there are more options others will tell as well.