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

Start script generated with startScriptForJarSettings uses class files, not jar file #41

Open
alexbergeron opened this issue Aug 7, 2013 · 2 comments

Comments

@alexbergeron
Copy link

Tried to modify a project definition to use a jar instead of classes for staging, found this. Reproducible with versions between 0.6.0 and 0.9.0 using sbt 0.12.4.

project/Project.scala

import sbt._
import Keys._
import com.typesafe.sbt.SbtStartScript.startScriptForJarSettings

object JarStartScriptBuild extends Build {
  val defaultSettings = Defaults.defaultSettings ++ startScriptForJarSettings ++ Seq(
    organization := "fake.org", 
    version := "0.1-SNAPSHOT", 
    scalaVersion := "2.10.2"
  )

  lazy val root = Project("jar-start-script", file(".")).settings(defaultSettings: _*)
}

For testing purposes, I've only written a single Hello World. This is the start script generated after running sbt stage (target/start, using version 0.9.0)

#!/bin/bash
PROJECT_DIR=$(cd "${BASH_SOURCE[0]%/*}" && pwd -P)/..

MAINCLASS=Test


exec java $JAVA_OPTS -cp "$PROJECT_DIR/target/scala-2.10/classes:/home/alex/.sbt/boot/scala-2.10.2/lib/scala-library.jar" "$MAINCLASS" "$@"
alexbergeron pushed a commit to alexbergeron/sbt-start-script that referenced this issue Aug 7, 2013
Explicitly replace class files by generated jar file in classpath for Jar settings
@havocp
Copy link
Contributor

havocp commented Aug 13, 2013

Hi, sorry for ignoring this; I need to invest some time because honestly I don't a) remember why I added both ForClasses and ForJar, or b) know when/why they became broken, and as a result c) don't know what they should actually do (like should it use a jar for every project in the build?). Anyway I haven't had a day to spend on it. If you or someone else has time to dig in a bit more and sort of figure out what's going on, that may be helpful. Or even just let me know why in your particular case you need to use the jar! ;-) Thanks for the PR and sorry I'm AWOL for a bit.

@alexbergeron
Copy link
Author

No problems, I took the time to "fix" it (see my pull request, I don't have any experience in writing sbt plugin, so I'm pretty sure I'm doing something wrong somewhere), so we could go on for now.

To explain why I'm trying to use jars here: We have a server application on a cluster of dozens of machines. Our current build process pull the latest code from the git repo, compiles the code, uses the sbt-start-script to generate a script, then restart the servers one by one waiting for each of them to be up before moving to the next.

We recently had some weird issue in our code base. After some investigation, I realized that it was occurring while we were compiling the code, but fixed itself after a restart. What we realized was that our servers were still not warm enough and had code that was not loaded yet, tried to find the class file (that was deleted), and failed without knowing how to recover. After some tests, we realized that running a jar (and not classes) was fixing that issue. I found this issue during theses tests.

Thanks for the answer! I hope that I've clarified the situation for you.

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

Successfully merging a pull request may close this issue.

2 participants