I'm wondering if you could recommend a tutorial or template for Play Java, that is up-to-date for Play 2.3.x, that demonstrates how to use 1) CoffeeScript, LESS, RJS, GZIP, Digest, JSHint, Uglify, 2) using Hibernate, JPA & PostGres, 3) Webjars and finally 4) Java 8.
Some specific things I find confusing:
1) The SBT Plugins such as sbt-rjs (https://github.com/sbt/sbt-rjs#sbt-rjs), say I need this configuration line:
lazy val root = (project in file(".")).enablePlugins(SbtWeb)
Each example app/template I've seen though has:
lazy val root = (project in file(".")).enablePlugins(PlayJava)
So should it instead be?:
lazy val root = (project in file(".")).enablePlugins(PlayJava, SbtWeb)
2) How the Pipeline configuration works. In https://www.playframework.com/documentation/2.3.x/Assets I found the following line:
pipelineStages := Seq(rjs, digest, gzip)
How would Less, CoffeeScript, JSHint, Uglify etc work within the pipeline? Do they not need to be added to the Pipeline?
3) What is the Build.scala file? I've found some Java 2.3 tutorials which reference it such as here: https://github.com/jamesward/play2torial/blob/master/JAVA.md#update-the-app-on-heroku
When I create a new Play Java App using Activator there isn't a Build.scala file in the root or project directory. I only have build.sbt in the root directory and plugins.sbt in the /project directory.
Along those same lines should I be doing something like this:
val appDependencies = Seq(
"org.webjars" % "webjars-play" % "2.0",
"org.webjars" % "bootstrap" % "2.1.1"
)
Or do Webjars now go directly into libraryDependencies like:
libraryDependencies ++= Seq(
"org.webjars" %% "webjars-play" % "2.3.0-2",
"org.webjars" % "bootstrap" % "3.1.1-2"
)
4) SBT Plugins vs WebJars? For RequireJS for example, its unclear if I should be using it as a WebJar or SBT Plugin. In the Play Documentation for Assets here https://www.playframework.com/documentation/2.3.x/Assets it says to use RequireJS as a WebJar (under the WebJars section). Here is a specific line:
For example if you declared a dependency on RequireJs then you can reference it from a view using a line like:
<script data-main="@routes.Assets.at("javascripts/main.js")" type="text/javascript" src="@routes.Assets.at("lib/requirejs/require.js")"></script>
But 4 pages later in the Public Assets documentation for "Using RequireJS" (https://www.playframework.com/documentation/2.3.x/RequireJS-support) it says to use RJS as an SBT Plugin that also has a corresponding Pipeline configuration.
Which is the recommended way?
5) Is the following line necessary within build.sbt:
scalaVersion := "2.11.1"
Within the default Play 2.3.x templates, the "play-java" template (https://github.com/playframework/playframework/blob/2.3.x/templates/play-java/build.sbt) includes that line, whereas "play-java-intro" template (https://github.com/playframework/playframework/blob/2.3.x/templates/play-java-intro/build.sbt) doesn't have the "scalaVersion" line.
6) Would you recommend including the following lines (using Java 8) in the build.sbt if I also want to use JavaJpa & hibernate? I read somewhere that Java 8 wasn't working yet with Hibernate.
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint")
initialize := {
val _ = initialize.value
if (sys.props("java.specification.version") != "1.8")
sys.error("Java 8 is required for this project.")
}
Thanks and sorry for the long list of questions!
When to use .scala files:
In .scala files, you can write any Scala code, including top-level classes and objects. Also, there are no restrictions on blank lines, since they are standard .scala files.
The recommended approach is to define most configuration in .sbt files, using .scala files for task implementations or to share values, such as keys, across .sbt files.