Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sclasen opened this issue Feb 2, 2012 · 8 comments
Open

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

sclasen opened this issue Feb 2, 2012 · 8 comments

Comments

@sclasen
Copy link
Contributor

sclasen commented Feb 2, 2012

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("")

()

}

@havocp
Copy link
Contributor

havocp commented Feb 3, 2012

This will probably turn out to be a dumb question, but why does this save space? Doesn't it make another copy and thus use more space? Or would you modify things to avoid including .ivy2 in the slug and then we're saving the extra .xml and other non-jar files? How will Heroku know whether to include .ivy2 in the slug?

@sclasen
Copy link
Contributor Author

sclasen commented Feb 5, 2012

Yeah so making it an optional thing would be good so folks could choose to not use .ivy2...since buildpacks are now open source, and user visible it is simple to fork the existing scala buildpack and drop .ivy2 from the slug to reduce size.

Sent from my iPhone

On Feb 3, 2012, at 5:51 AM, Havoc [email protected] wrote:

This will probably turn out to be a dumb question, but why does this save space? Doesn't it make another copy and thus use more space? Or would you modify things to avoid including .ivy2 in the slug and then we're saving the extra .xml and other non-jar files? How will Heroku know whether to include .ivy2 in the slug?


Reply to this email directly or view it on GitHub:
https://github.com/typesafehub/xsbt-start-script-plugin/issues/11#issuecomment-3796897

@imikushin
Copy link

+1 play stage task is nice: you just grab target/start and staged dir, archive it and you are good to go!

@nelsonjchen
Copy link

This might be fixed for Heroku by now. I think I saw something about ivy's cache being dropped in my deploy. Is this feature still in request?

@havocp
Copy link
Contributor

havocp commented Sep 21, 2012

So I guess the feature here would be that if some setting is present (like stageJars := true or something) we copy jars into staged/ and then make that the classpath? Maybe at that point Play could just use this plugin?

It sounds fine to me, I haven't had a chance to code it up though.

@stig
Copy link

stig commented Aug 5, 2013

This is not fixed in heroku yet, to my knowledge, but it is arguably where it should be fixed.

@havocp
Copy link
Contributor

havocp commented Aug 5, 2013

fwiw all Heroku's knowledge of sbt is in https://github.com/heroku/heroku-buildpack-scala if anyone wants to hack on that. You can also use a custom version for your own app.

@stig
Copy link

stig commented Aug 5, 2013

We already have a fork of the scala build pack to get around the problem that every so often the .ivy2 cache gets too big and slug deployment fails. But our hack just blows away the .ivy2 cache at the start of the build and as such makes the build slower to the extent that it sometimes times out... So we haven't submitted a pull request. Here's our fork, if people are interested anyway: https://github.com/net-a-porter-mobile/heroku-buildpack-scala

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants