[2.3-scala] Build.scala multi-project with PlayScala

526 views
Skip to first unread message

Grant Gavares

unread,
May 6, 2014, 4:27:56 PM5/6/14
to play-fr...@googlegroups.com
Due to the complexity of our multi-project build, our team has ditched build.sbt in favor of Build.scala. I can't seem to get the PlayScala plugin to take effect on the root level project and I'm hoping someone here can shed some light on the issue.

project/plugins.sbt


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

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

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3-M1")




project/Build.scala

import sbt._
import Keys._
import play.Play
import play.PlayScala.autoImport._
import PlayKeys._

object BuildSettings {
  val buildOrg = "com.playi"
  val buildVersion = "0.1-SNAPSHOT"
  val buildScalaVersion = "2.10.3"

  // Basic settings for the project that are shared between
  // the submodules
  val buildSettings = Defaults.defaultSettings ++ Seq(
    organization := buildOrg,
    version      := buildVersion,
    scalaVersion := buildScalaVersion,
    shellPrompt  := ShellPrompt.buildShellPrompt
  ) 
}

...
...

object MyBuild extends Build {
  import BuildSettings._

  // Define the api module as a project
  lazy val api = Project(
    "api", 
    file("api"), 
    settings = buildSettings ++ Seq(libraryDependencies ++= apiDeps)
  )

  // Define the service module as a project which depends on 
  // the api module
  lazy val service = {

    val mainSettings = Seq(
      resolvers := publicResolvers ++ ... //omitted 
      libraryDependencies ++= serviceDeps
    ) 

    val pkgSettings = packagerSettings ++ packageArchetype.java_server ++ deploymentSettings ++ Seq(
      publish      <<= publish.dependsOn(publish in Universal),
      publishLocal <<= publishLocal.dependsOn(publishLocal in Universal),
      // only include tgz artifacts
      packagedArtifacts in Universal ~= { 
        _.filter { 
          case (artifact, file) => 
            System.out.println(artifact.`type`)
            artifact.`type`.contains("tgz")
        }
      }
    )


    Project (
      id = "service", 
      base = file("."), 
      aggregate = Seq(api),
      dependencies = Seq(api)
    )
    .addPlugins( play.PlayScala )
    .settings( (mainSettings ++ Play.defaultSettings ++ pkgSettings ++ buildSettings ):_* )
  }
}


Notice that I have to include Play.defaultSettings in my project settings even though I've added addPlugins(play.PlayScala). Without that, the source directories for the project are incorrect. Even with these two added, I still seem to be missing anything related to the sbt-native-packager which, as I understand it, should be included by default in play projects. 

All the Play! specific code in the Build.scala file was arrived at by following the instructions in the migration guid here

My question, what am I missing in my configuration that is preventing some of the play tasks, settings and configuration from being pulled in?

Christopher Hunt

unread,
May 6, 2014, 9:25:12 PM5/6/14
to play-fr...@googlegroups.com
We're probably moving the target on you a little, making things a little harder unfortunately. One thing that happened was that sbt 0.13.5-RC1 came out and that was API incompatible with the M2 version we were using in Play. I don't know if that is part of your issue.

We're also close to releasing Play 2.3-RC1 which has brought everything into line regarding sbt, sbt-web and a few other things.

For samples on how to configure build.sbt or build.scala then may be these tests will help:

Grant Gavares

unread,
May 6, 2014, 11:54:01 PM5/6/14
to play-fr...@googlegroups.com
Thanks Chistopher, the tests did help a bit. I upgraded to sbt 0.13.5-RC1 and changed "addPlugins" to "enablePlugins" and that moved me forward a bit I think. The only problem that I've identified at this point is that zip and tgz archives generated by the universal:packageBin/packageZipTarball do not seem to contain any start scripts. This very well might just be a problem in my Build.scala file.

Grant Gavares

unread,
May 7, 2014, 1:12:30 PM5/7/14
to play-fr...@googlegroups.com
I can't seem to figure out what magic I need to have the start scripts included in my .deb/tgz/zip artifacts.  Using build.sbt and sbt version 0.13.5-RC1 behaves as expected but as I move to Build.scala, generated archives no longer contain start scripts for my project. Searching my project directory, I can't seem to find the start scripts on the filesystem either so it appears that the scripts are never being generated. 

At this point, I'm more convinced now that this isn't an obvious problem in my Build.scala. One thing that might be helpful would be to inspect the build file that is generated from build.sbt. Does one exist on disk or is build.sbt translation performed in memory only?

What else could be causing the build system to skip creation of the start scripts?

Raymond Tay

unread,
May 7, 2014, 9:56:52 PM5/7/14
to play-fr...@googlegroups.com
Hi Grant,

sbt-native-packager isn't quite ready for the swanky `autoPlugins` stuff and based on the ticket i filed earlier, the guys are going to get a crack at it pretty soon → https://github.com/sbt/sbt-native-packager/issues/243

Grant Gavares

unread,
May 7, 2014, 10:18:53 PM5/7/14
to play-fr...@googlegroups.com
Mystery solved! Thanks again.


--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/lnEcyiPewn0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages