Friday, October 11, 2013

Play2 build files

Play2 build files


Play2 2.2 documentation suggested that one should convert "./project/build.scala" to "./build.sbt".

http://www.playframework.com/documentation/2.2.x/SBTSubProjects

"The following example uses a build.scala file to declare a play.Project. This approach was the way Play applications were defined prior to version 2.2. The approach is retained in order to support backward compatibility. We recommend that you convert to the build.sbt based approach or, if using a build.scala, you use sbt's Project type and project macro."

You most propably want to read thru docs - I did, and felt bit dizzed...

.sbt build file

http://www.scala-sbt.org/0.12.2/docs/Getting-Started/Basic-Def.html

.scala build file

http://www.scala-sbt.org/0.12.2/docs/Getting-Started/Full-Def.html

Easy stuff? Found example, and followed it. Try same.

http://mikeslinn.blogspot.de/2013/09/sample-play-22x-buildsbt.html

build.scala


Build.scala is basically build.sbt expressed with scala. So, if you understand what kind of object model build file forms you have straightforward task here.

import sbt._
import Keys._
import play.Project._

object ApplicationBuild extends Build {

  val appName = "resource_delivery_admin"
  val appVersion = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    "postgresql" % "postgresql" % "9.1-901.jdbc4",
    javaCore,
    javaJdbc,
    javaEbean  

  )

  val main = play.Project(appName, appVersion, appDependencies).settings(
    resolvers += "JBoss repository" at "http://repository.jboss.org/nexus/content/groups/public-jboss/"
    
  )

}

build.sbt


What comes out is this. Simple? That was how I did it. And cleaned and compiled.

import sbt._
import Keys._
import play.Project._

play.Project.playJavaSettings

name         := "your-project"

version      := "1.0-SNAPSHOT"

libraryDependencies ++= Seq (
    "postgresql" % "postgresql" % "9.1-901.jdbc4",
    javaCore,
    javaJdbc,
    javaEbean  
  )


Resolver for JBoss repository was eventually used, but as I wanted to cut down lines to make this easier to you to read I took Smooks dependencies off.

Further steps


Just try to get it right and enjoy.

http://www.scala-sbt.org/release/docs/Getting-Started/Summary.html

There's whole lot concepts you want to understand, but take your time. SBT will be later defined to be acronym without meaning like Soap, which isn't anymore thought to be "simple".

No comments: