I just figured this out and wanted to share in case anyone encounters the same issue as my Googling for a solution wasn't very successful.
One of the benefits of moving to sbt in Play 2 (in my opinion) is being able to do 'play dist' or 'sbt dist' and get a nice zip file of your play app in a completely standalone form.
As others have noted this makes it easy enough to then scp to a server, unzip and run.
We are doing that, but wanted to store prebuilt versions in a Repository so we could easily move between integration/production versions without doing a rebuild, or roll back to older versions if there was an issue. So using Artifactory, Nexus or another Maven Repository for this seems like a good idea as sbt already knows how to publish to them.
The only problem was that by default sbt only wants to upload the .jar of the play app without its dependencies.
To be fair the sbt docs do describe how to change this, but its not immediately obvious how to adapt it to Play, so let me share the solution.
In our Build.scala file we have the following lines now:
lazy val publishSettings = Seq(
// disable publishing the usual jars
publishArtifact in Compile := false,
// don't use the compiled jar, use the dist output
artifact in (Compile, dist) ~= { (art: Artifact) => art.copy(`type` = "zip", extension = "zip") },
// disable using the Scala version in output paths and artifacts
// (this is optional, but it makes for a cleaner name in the repository)
crossPaths := false,
// publish to Artefactory/Nexus
organization := "com.your-org-name-here",
publishMavenStyle := true,
publishTo <<= version { (v: String) =>
if (v.trim.endsWith("SNAPSHOT"))
Some("snapshots" at repo + "libs-snapshot-local")
else
Some("releases" at repo + "libs-release-local")
}
) ++ addArtifact(artifact in (Compile, dist), dist)
val main = PlayProject(appName, appVersion, appDependencies,
mainLang = SCALA,
settings = Defaults.defaultSettings ++ publishSettings)
The fiddly line to work out was artifact in (Compile, dist) ~= { (art: Artifact) => art.copy(`type` = "zip", extension = "zip") } which creates the needed Artifact from the 'dist' task as a zip file (otherwise it is published as a jar file)
Hopefully that will help anyone else trying to do this in the future ;)
Cheers,
Mark