[2.0] Play and sbt-buildinfo

454 views
Skip to first unread message

Drew Kutcharian

unread,
Apr 16, 2012, 3:54:43 PM4/16/12
to play-fr...@googlegroups.com
Hey Guys,

Has anyone tried integrating Play with sbt-buildinfo? I would like to be able to get the version of my Play app programmatically at runtime.



Thanks,

Drew

Drew Kutcharian

unread,
Apr 18, 2012, 3:29:24 AM4/18/12
to play-fr...@googlegroups.com
No body?


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Eugene Yokota

unread,
May 16, 2012, 6:28:32 PM5/16/12
to play-fr...@googlegroups.com
Hi Drew,

From what I can tell, Play! is just preconfigured sbt 0.11.2 that uses Build.scala for definitions.
You can find out more about sbt by reading https://github.com/harrah/xsbt/wiki/Getting-Started-Welcome.

Here's how to integrate sbt-buildinfo. Here's my project/plugins.sbt:

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository 
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.0.1")

resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.1.1")

Here's project/Build.scala:

import sbt._
import Keys._
import PlayProject._
import sbtbuildinfo.Plugin._

object ApplicationBuild extends Build {

    val appName         = "play-sbt-buildinfo-sample"
    val appVersion      = "1.0-SNAPSHOT"

    val appDependencies = Seq(
      // Add your project dependencies here,
    )

    val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA,
      settings = Defaults.defaultSettings ++ buildInfoSettings
    ).settings(
      sourceGenerators in Compile <+= buildInfo,
      buildInfoKeys := Seq[Scoped](name, version, scalaVersion, sbtVersion),
      buildInfoPackage := "hello"
    )

}

Now Play/sbt would automatically generate Buildinfo.scala under target/scala-2.9.1.

To use this, here's index.scala.html:

@(message: String)

@("Welcome to %s %s" format (hello.BuildInfo.name, hello.BuildInfo.version))

-eugene


On Wednesday, April 18, 2012 3:29:24 AM UTC-4, Drew Kutcharian wrote:
No body?


On Apr 16, 2012, at 12:54 PM, Drew Kutcharian <dr...@venarc.com> wrote:

Hey Guys,

Has anyone tried integrating Play with sbt-buildinfo? I would like to be able to get the version of my Play app programmatically at runtime.



Thanks,

Drew

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-framework@googlegroups.com.
To unsubscribe from this group, send email to play-framework+unsubscribe@googlegroups.com.

Eugene Yokota

unread,
May 16, 2012, 6:39:59 PM5/16/12
to play-fr...@googlegroups.com
For some reason my earlier message didn't go through, so let me try a link to gist this time.


-eugene

On Wednesday, April 18, 2012 3:29:24 AM UTC-4, Drew Kutcharian wrote:
No body?


On Apr 16, 2012, at 12:54 PM, Drew Kutcharian <dr...@venarc.com> wrote:

Hey Guys,

Has anyone tried integrating Play with sbt-buildinfo? I would like to be able to get the version of my Play app programmatically at runtime.



Thanks,

Drew

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-framework@googlegroups.com.
To unsubscribe from this group, send email to play-framework+unsubscribe@googlegroups.com.

Drew Kutcharian

unread,
May 17, 2012, 2:40:57 PM5/17/12
to play-fr...@googlegroups.com
Thanks Eugene. I tested this and it works great!


To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/ls9tI4BBdgMJ.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages