Skip to content

Add the option of copying jars instead of using .ivy repo #11

@sclasen

Description

@sclasen

This will help keep sizes down on Heroku, etc. Play 2 has a stage task that does the copying so you can grab the code from there...

val playStage = TaskKeyUnit
val playStageTask = (baseDirectory, playPackageEverything, dependencyClasspath in Runtime, target, streams) map { (root, packaged, dependencies, target, s) =>

import sbt.NameFilter._

val staged = target / "staged"

IO.delete(staged)
IO.createDirectory(staged)

val libs = dependencies.filter(_.data.ext == "jar").map(_.data) ++ packaged

libs.foreach { jar =>
  IO.copyFile(jar, new File(staged, jar.getName))
}

val start = target / "start"
IO.write(start,
  """|#! /usr/bin/env sh
     |
     |java "$@" -cp "`dirname $0`/staged/*" play.core.server.NettyServer `dirname $0`/..
     |""".stripMargin)

"chmod a+x %s".format(start.getAbsolutePath) !

s.log.info("")
s.log.info("Your application is ready to be run in place: target/start")
s.log.info("")

()

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions