From 863073d57a812872a97c8900ef82230fd1bf331b Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 14 Feb 2011 10:10:07 -0800 Subject: [PATCH 001/483] Initial Import for sbt-template (autogenerated by sbt-setup). --- .gitignore | 5 +++++ README | 1 + project/build.properties | 8 ++++++++ project/build/SbtTemplateProject.scala | 18 ++++++++++++++++++ src/main/scala/Main.scala | 7 +++++++ src/test/scala/TemplateSpec.scala | 11 +++++++++++ 6 files changed, 50 insertions(+) create mode 100644 .gitignore create mode 100644 README create mode 100644 project/build.properties create mode 100644 project/build/SbtTemplateProject.scala create mode 100644 src/main/scala/Main.scala create mode 100644 src/test/scala/TemplateSpec.scala diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..f72e594c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +target +/project/boot +lib_managed +src_managed +/ext diff --git a/README b/README new file mode 100644 index 000000000..2d6b127b5 --- /dev/null +++ b/README @@ -0,0 +1 @@ +This is a skeleton project for sbt. \ No newline at end of file diff --git a/project/build.properties b/project/build.properties new file mode 100644 index 000000000..1a58d1b82 --- /dev/null +++ b/project/build.properties @@ -0,0 +1,8 @@ +#Project properties +#Generated by sbt-setup +project.organization=improving +project.name=sbt-template +sbt.version=0.7.4 +project.version=0.1 +build.scala.versions=2.8.1 +project.initialize=false diff --git a/project/build/SbtTemplateProject.scala b/project/build/SbtTemplateProject.scala new file mode 100644 index 000000000..365a5c87b --- /dev/null +++ b/project/build/SbtTemplateProject.scala @@ -0,0 +1,18 @@ +import sbt._ + +class SbtTemplateProject(info: ProjectInfo) extends DefaultProject(info) { + val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" + val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" + val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" + + // local use + override def localScala = System.getenv("scala.local") match { + case null => super.localScala + case path => + log.info("Found scala.local: " + path) + List(defineScala("2.9.0-local", new java.io.File(path))) + } + + val scalacheck = "org.scala-tools.testing" %% "scalacheck" % "1.8" % "test" withSources() + val specs = "org.scala-tools.testing" %% "specs" % "1.6.7" % "test" withSources() +} diff --git a/src/main/scala/Main.scala b/src/main/scala/Main.scala new file mode 100644 index 000000000..104a22d9f --- /dev/null +++ b/src/main/scala/Main.scala @@ -0,0 +1,7 @@ +package template + +object Main { + def main(args: Array[String]): Unit = { + // Your code here + } +} diff --git a/src/test/scala/TemplateSpec.scala b/src/test/scala/TemplateSpec.scala new file mode 100644 index 000000000..a68dc1c44 --- /dev/null +++ b/src/test/scala/TemplateSpec.scala @@ -0,0 +1,11 @@ +package template + +import org.specs._ + +class SendSpec extends Specification { + "A template project" should { + "not violate universal realities" >> { + 1 mustEqual 1 + } + } +} From 479f9e51412160818d2414108ff16ad1e22eb06b Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 14 Feb 2011 10:57:45 -0800 Subject: [PATCH 002/483] Added sbt-setup script. Now generates specs test template too. --- bin/sbt-setup | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 bin/sbt-setup diff --git a/bin/sbt-setup b/bin/sbt-setup new file mode 100755 index 000000000..9a8f5e577 --- /dev/null +++ b/bin/sbt-setup @@ -0,0 +1,100 @@ +#!/bin/bash +# + +PROJECT="$1" + +ORGANIZATION="improving" +SCALA_VERSION="2.8.1" +SCALACHECK_VERSION="1.8" +SPECS_VERSION="1.6.7" +SBT_VERSION="0.7.5.RC0" + +if [ -z "$PROJECT" ]; then + echo "Usage: $0 " + exit 1 +fi + +DIR=$(echo ${PROJECT} | tr '[A-Z]' '[a-z]') +PROJECT_CLASS=$(echo $PROJECT | sed -e 's/[^a-zA-Z_]//g;')Project + +mkdir $DIR +cd $DIR +echo "Creating sbt project ${PROJECT} in ${PWD}" +echo "" + +cat > .gitignore < project/build/${PROJECT_CLASS}.scala < super.localScala + case path => + log.info("Found scala.local: " + path) + List(defineScala("2.9.0-local", new java.io.File(path))) + } + + val scalacheck = "org.scala-tools.testing" %% "scalacheck" % "$SCALACHECK_VERSION" % "test" withSources() + val specs = "org.scala-tools.testing" %% "specs" % "$SPECS_VERSION" % "test" withSources() +} +EOF + +cat > project/build.properties < src/main/scala/Main.scala < src/test/scala/TemplateSpec.scala <> { + 1 mustEqual 1 + } + } +} +EOF + +git init +git add . +git commit -m "Initial Import for ${PROJECT} (autogenerated by sbt-setup)." +sbt update + +echo "" +echo "Ready to roll in $PWD" \ No newline at end of file From dc7b0285cc0370109f2f6408510ad9c8aa6f618c Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 14 Feb 2011 11:32:38 -0800 Subject: [PATCH 003/483] Made the default package "template" rather than improving, and read it from the ORGANIZATION env variable if set. --- bin/sbt-setup | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/sbt-setup b/bin/sbt-setup index 9a8f5e577..f86037929 100755 --- a/bin/sbt-setup +++ b/bin/sbt-setup @@ -3,7 +3,8 @@ PROJECT="$1" -ORGANIZATION="improving" +DEFAULT_PACKAGE="template" +PACKAGE=${ORGANIZATION:-$DEFAULT_PACKAGE} SCALA_VERSION="2.8.1" SCALACHECK_VERSION="1.8" SPECS_VERSION="1.6.7" @@ -55,7 +56,7 @@ EOF cat > project/build.properties < src/main/scala/Main.scala < src/test/scala/TemplateSpec.scala < Date: Mon, 14 Feb 2011 11:33:54 -0800 Subject: [PATCH 004/483] re #1: Project definition now starting with capital letter (file and class). --- bin/sbt-setup | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/sbt-setup b/bin/sbt-setup index f86037929..3a86b2e40 100755 --- a/bin/sbt-setup +++ b/bin/sbt-setup @@ -16,7 +16,8 @@ if [ -z "$PROJECT" ]; then fi DIR=$(echo ${PROJECT} | tr '[A-Z]' '[a-z]') -PROJECT_CLASS=$(echo $PROJECT | sed -e 's/[^a-zA-Z_]//g;')Project +PROJECT_UC=$(echo ${PROJECT:0:1} | tr '[a-z]' '[A-Z]')${PROJECT:1} +PROJECT_CLASS=$(echo $PROJECT_UC | sed -e 's/[^a-zA-Z_]//g;')Project mkdir $DIR cd $DIR From 292533ab0644254283f81b409629e8c63e670b40 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 14 Feb 2011 14:48:57 -0800 Subject: [PATCH 005/483] Added example program "Rational". --- src/main/example/Rational.scala | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/example/Rational.scala diff --git a/src/main/example/Rational.scala b/src/main/example/Rational.scala new file mode 100644 index 000000000..72e27535b --- /dev/null +++ b/src/main/example/Rational.scala @@ -0,0 +1,26 @@ +package example + +// Primary constructor takes two arguments. +class Rational(n: Int, d: Int) { + // an auxiliary constructor: must call the primary constructor first. + def this(n: Int) = this(n, 1) + // A requirement: an exception is thrown upon construction if the condition is false. + require(d > 0, "denominator must be greater than zero") + + // A grossly inefficient greatest common divisor, for illustrative purposes only. + private def gcd(n: Int, d: Int) = ( + n max d to 2 by -1 find (g => n % g == 0 && d % g == 0) getOrElse 1 + ) + // Using the gcd to calculate reduced numerator and denominator. + private val g = gcd(n, d) + // Public, immutable values. + val numerator = n / g + val denominator = d / g + + // toString overrides a method in AnyRef so "override" is required. + override def toString = n + "/" + d + ( + // The result of the if/else is a String: + if (numerator == n) "" // the empty string if it is irreducible + else " (" + numerator + "/" + denominator + ")" // the reduced form otherwise + ) +} From e9b7b4ffab333fcbc699be1f92a800ecddd1bc29 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 14 Feb 2011 15:11:41 -0800 Subject: [PATCH 006/483] Fleshed out the Rational class some more. --- src/main/{ => scala}/example/Rational.scala | 16 ++++++++++++++++ src/main/scala/example/package.scala | 6 ++++++ 2 files changed, 22 insertions(+) rename src/main/{ => scala}/example/Rational.scala (61%) create mode 100644 src/main/scala/example/package.scala diff --git a/src/main/example/Rational.scala b/src/main/scala/example/Rational.scala similarity index 61% rename from src/main/example/Rational.scala rename to src/main/scala/example/Rational.scala index 72e27535b..a0e626c21 100644 --- a/src/main/example/Rational.scala +++ b/src/main/scala/example/Rational.scala @@ -17,6 +17,18 @@ class Rational(n: Int, d: Int) { val numerator = n / g val denominator = d / g + // Assume we have r1: Rational, r2: Rational, and num: Int. + // Since + is a method like any other, if we define it with a + // Rational argument then r1 + r2 is defined. + def +(that: Rational): Rational = new Rational( + this.numerator * that.denominator + that.numerator * this.denominator, + this.denominator * that.denominator + ) + // You can overload the + method with an Int argument: now r1 + num + // is also defined. However to make num + r1 work similarly requires + // an implicit conversion. (See the example package object.) + def +(that: Int): Rational = this + new Rational(that) + // toString overrides a method in AnyRef so "override" is required. override def toString = n + "/" + d + ( // The result of the if/else is a String: @@ -24,3 +36,7 @@ class Rational(n: Int, d: Int) { else " (" + numerator + "/" + denominator + ")" // the reduced form otherwise ) } + +// The Rational companion object. +object Rational { +} \ No newline at end of file diff --git a/src/main/scala/example/package.scala b/src/main/scala/example/package.scala new file mode 100644 index 000000000..09ad32615 --- /dev/null +++ b/src/main/scala/example/package.scala @@ -0,0 +1,6 @@ +// The example package object. +package object example { + // Importing an implicit method of type Int => Rational will + // henceforth let us use Ints as if they were Rationals. + implicit def intToRational(num: Int): Rational = new Rational(num) +} \ No newline at end of file From fa1f988bcff3459415fbe3908f369fdb40a7c798 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 14 Feb 2011 15:19:48 -0800 Subject: [PATCH 007/483] Fleshed out Rational even more. Added an ExampleSpec for running tests on package example. --- src/main/scala/example/Rational.scala | 16 +++++++++++++++- src/test/scala/ExampleSpec.scala | 13 +++++++++++++ src/test/scala/TemplateSpec.scala | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/test/scala/ExampleSpec.scala diff --git a/src/main/scala/example/Rational.scala b/src/main/scala/example/Rational.scala index a0e626c21..44434dd3b 100644 --- a/src/main/scala/example/Rational.scala +++ b/src/main/scala/example/Rational.scala @@ -29,14 +29,28 @@ class Rational(n: Int, d: Int) { // an implicit conversion. (See the example package object.) def +(that: Int): Rational = this + new Rational(that) - // toString overrides a method in AnyRef so "override" is required. + // toString, equals, and hashCode all override methods in AnyRef + // so "override" is required. override def toString = n + "/" + d + ( // The result of the if/else is a String: if (numerator == n) "" // the empty string if it is irreducible else " (" + numerator + "/" + denominator + ")" // the reduced form otherwise ) + + // To preserve symmetry we will be equal only to other Rationals. + override def equals(other: Any) = other match { + case x: Rational => this.numerator == x.numerator && this.denominator == x.denominator + case _ => false + } + // As with java, equals and hashCode should always be overridden together. + override def hashCode = numerator.## + denominator.## } // The Rational companion object. object Rational { + // A factory method on the companion object allows construction + // without explicit calls to new. Here, d is given a default argument + // of 1. This is an alternative mechanism to the auxiliary constructor. + // used in the class. + def apply(n: Int, d: Int = 1): Rational = new Rational(n, d) } \ No newline at end of file diff --git a/src/test/scala/ExampleSpec.scala b/src/test/scala/ExampleSpec.scala new file mode 100644 index 000000000..01ad8a1f1 --- /dev/null +++ b/src/test/scala/ExampleSpec.scala @@ -0,0 +1,13 @@ +package example + +import org.specs._ + +class ExampleSpec extends Specification { + "An example project" should { + "implement rational numbers" >> { + Rational(5) mustEqual Rational(5, 1) + Rational(1, 10) mustEqual Rational(2, 20) + (Rational(1, 3) + Rational(5, 15)) mustEqual Rational(4, 6) + } + } +} diff --git a/src/test/scala/TemplateSpec.scala b/src/test/scala/TemplateSpec.scala index a68dc1c44..7952ab21f 100644 --- a/src/test/scala/TemplateSpec.scala +++ b/src/test/scala/TemplateSpec.scala @@ -2,7 +2,7 @@ package template import org.specs._ -class SendSpec extends Specification { +class TemplateSpec extends Specification { "A template project" should { "not violate universal realities" >> { 1 mustEqual 1 From b9c3b0272554753a3622d37835fb57588e47714c Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 14 Feb 2011 15:31:49 -0800 Subject: [PATCH 008/483] Added some sequence exercises. --- src/main/scala/example/Sequences.scala | 22 ++++++++++++++++++++++ src/main/scala/example/package.scala | 5 ++++- src/test/scala/ExampleSpec.scala | 8 +++++++- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/main/scala/example/Sequences.scala diff --git a/src/main/scala/example/Sequences.scala b/src/main/scala/example/Sequences.scala new file mode 100644 index 000000000..be25b0e31 --- /dev/null +++ b/src/main/scala/example/Sequences.scala @@ -0,0 +1,22 @@ +package example + +// These implementations have no error checking: they will throw +// exceptions if the input is unexpected, e.g. an empty list has no +// penultimate member. +object Exercises { + def penultimate[T](xs: List[T]): T = xs.reverse.tail.head + // Other possible implementations: + // def penultimate[T](xs: List[T]): T = xs.init.last + // def penultimate[T](xs: List[T]): T = xs(xs.length - 2) + // def penultimate[T](xs: List[T]): T = xs takeRight 2 head + + // Test if the argument is a palindrome. + def isPalindrome[T](xs: List[T]) = xs == xs.reverse + + // Remove the Kth element from a list, returning the list and + // the removed element as a tuple. + def removeAt[T](index: Int, xs: List[T]): (List[T], T) = { + val (front, back) = xs splitAt index + (front ++ back.tail, back.head) + } +} \ No newline at end of file diff --git a/src/main/scala/example/package.scala b/src/main/scala/example/package.scala index 09ad32615..5581bcb09 100644 --- a/src/main/scala/example/package.scala +++ b/src/main/scala/example/package.scala @@ -2,5 +2,8 @@ package object example { // Importing an implicit method of type Int => Rational will // henceforth let us use Ints as if they were Rationals. - implicit def intToRational(num: Int): Rational = new Rational(num) + implicit def intToRational(num: Int): Rational = new Rational(num) + + // A handy method for exercises yet to be performed. + def ?? = throw new RuntimeException("Unimplemented.") } \ No newline at end of file diff --git a/src/test/scala/ExampleSpec.scala b/src/test/scala/ExampleSpec.scala index 01ad8a1f1..2b2ee3d61 100644 --- a/src/test/scala/ExampleSpec.scala +++ b/src/test/scala/ExampleSpec.scala @@ -4,10 +4,16 @@ import org.specs._ class ExampleSpec extends Specification { "An example project" should { - "implement rational numbers" >> { + "compare Rationals" >> { Rational(5) mustEqual Rational(5, 1) Rational(1, 10) mustEqual Rational(2, 20) + } + "add Rationals" >> { (Rational(1, 3) + Rational(5, 15)) mustEqual Rational(4, 6) } + "mix and match Rationals and Ints" >> { + (Rational(1, 2) + 1) mustEqual Rational(3, 2) + (1 + Rational(1, 2)) mustEqual Rational(3, 2) + } } } From b4eaaebf18ddd9dc913eac2fe83f6cdd6faaeb2e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 14 Feb 2011 20:24:03 -0800 Subject: [PATCH 009/483] Various improvements to sbt-setup. Finally discovered the impressively well hidden "latest.integration" setting for ivy. --- bin/sbt-setup | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/bin/sbt-setup b/bin/sbt-setup index 3a86b2e40..120e13da8 100755 --- a/bin/sbt-setup +++ b/bin/sbt-setup @@ -6,8 +6,7 @@ PROJECT="$1" DEFAULT_PACKAGE="template" PACKAGE=${ORGANIZATION:-$DEFAULT_PACKAGE} SCALA_VERSION="2.8.1" -SCALACHECK_VERSION="1.8" -SPECS_VERSION="1.6.7" +SCALA_LOCAL_VERSION="2.9.0-local" SBT_VERSION="0.7.5.RC0" if [ -z "$PROJECT" ]; then @@ -16,8 +15,9 @@ if [ -z "$PROJECT" ]; then fi DIR=$(echo ${PROJECT} | tr '[A-Z]' '[a-z]') -PROJECT_UC=$(echo ${PROJECT:0:1} | tr '[a-z]' '[A-Z]')${PROJECT:1} -PROJECT_CLASS=$(echo $PROJECT_UC | sed -e 's/[^a-zA-Z_]//g;')Project +PROJECT_UC=$(echo ${PROJECT:0:1} | tr '[a-z]' '[A-Z]')$(echo ${PROJECT:1} | sed -e 's/[^a-zA-Z_]//g;') +PROJECT_CLASS=${PROJECT_UC}Project +SPEC_CLASS=${PROJECT_UC}Spec mkdir $DIR cd $DIR @@ -37,20 +37,20 @@ cat > project/build/${PROJECT_CLASS}.scala < super.localScala case path => log.info("Found scala.local: " + path) - List(defineScala("2.9.0-local", new java.io.File(path))) + List(defineScala("$SCALA_LOCAL_VERSION", new java.io.File(path))) } - val scalacheck = "org.scala-tools.testing" %% "scalacheck" % "$SCALACHECK_VERSION" % "test" withSources() - val specs = "org.scala-tools.testing" %% "specs" % "$SPECS_VERSION" % "test" withSources() + val scalacheck = "org.scala-tools.testing" %% "scalacheck" % "latest.integration" % "test" withSources() + val specs = "org.scala-tools.testing" %% "specs" % "latest.integration" % "test" withSources() } EOF @@ -79,14 +79,14 @@ EOF mkdir -p src/test/scala -cat > src/test/scala/TemplateSpec.scala < src/test/scala/${SPEC_CLASS}.scala <> { +class ${SPEC_CLASS} extends Specification { + "A skeletal specification" should { + "do little beyond creating a skeleton" >> { 1 mustEqual 1 } } @@ -99,4 +99,4 @@ git commit -m "Initial Import for ${PROJECT} (autogenerated by sbt-setup)." sbt update echo "" -echo "Ready to roll in $PWD" \ No newline at end of file +echo "Ready to roll in $PWD" From f098e1f36c31646176a2cfdf4b65e887b28802e3 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 14 Feb 2011 22:03:00 -0800 Subject: [PATCH 010/483] Some breaking down of the project files, and a bunch of default dependencies for easy grabbing. Experimenting with more ways of being turnkey. --- bin/sbt-setup | 108 ++++++++++++++++++++++++++++++++++++++----- todo/artifacts.txt | 111 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 208 insertions(+), 11 deletions(-) create mode 100644 todo/artifacts.txt diff --git a/bin/sbt-setup b/bin/sbt-setup index 120e13da8..4b053b350 100755 --- a/bin/sbt-setup +++ b/bin/sbt-setup @@ -33,34 +33,119 @@ src_managed EOF mkdir -p project/build + +cat > project/build/Libraries.scala < ModuleID) +object ArtifactConfig { + implicit def defaultArtifactConfig: ArtifactConfig = new ArtifactConfig("", identity[ModuleID]) + implicit def testArtifactConfig: ArtifactConfig = new ArtifactConfig("test", identity[ModuleID]) +} + +trait LowPriorityLibraries { + self: DefaultProject => + + // "latest.integration", "latest.milestone", "latest.release" + def defaultRevision = "latest.integration" + protected implicit def defaultArtifactRevision = new ArtifactRevision(defaultRevision) + // protected implicit def defaultArtifactConfig = new ArtifactConfig("", identity[ModuleID]) + + protected implicit def autoConfig + (artifact: GroupArtifactID) + (implicit rev: ArtifactRevision, config: ArtifactConfig): ModuleID = + { + val ArtifactConfig(confs, fn) = config + fn( + if (confs == "") artifact % rev.revision + else artifact % rev.revision % config.confs + ) + } +} + +trait TestLibraries extends LowPriorityLibraries { + self: DefaultProject => + + private implicit val testDepConfig = ArtifactConfig("test", _.withSources) + val specs: ModuleID = "org.scala-tools.testing" %% "specs" + val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" +} + +trait Libraries extends Repositories with TestLibraries { + self: DefaultProject => + + import ArtifactConfig.defaultArtifactConfig + + // val ant: ModuleID = "org.apache.ant" % "ant" + // val asmAll: ModuleID = "asm" % "asm-all" withSources() + // val easymock: ModuleID = "org.easymock" % "easymock" + // val guava: ModuleID = "com.google.guava" % "guava" + // val ivy: ModuleID = "org.apache.ivy" % "ivy" + // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() + // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" + // val jmock: ModuleID = "org.jmock" % "jmock" + // val jodaTime: ModuleID = "joda-time" % "joda-time" + // val liftJson: ModuleID = "net.liftweb" %% "lift-json" + // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" + // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() + val scalaImproving: ModuleID = "org.improving" %% "scala-improving" + // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" + // val scalariform: ModuleID = "org.scalariform" %% "scalariform" + // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() + // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() + // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() +} +EOF + +cat > project/build/Repositories.scala < + + val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" + val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" + val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" + val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" + val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" +} +EOF + cat > project/build/${PROJECT_CLASS}.scala < super.localScala case path => log.info("Found scala.local: " + path) List(defineScala("$SCALA_LOCAL_VERSION", new java.io.File(path))) - } - - val scalacheck = "org.scala-tools.testing" %% "scalacheck" % "latest.integration" % "test" withSources() - val specs = "org.scala-tools.testing" %% "specs" % "latest.integration" % "test" withSources() + } } EOF +mkdir -p project/plugins +cat > project/plugins/Plugins.scala < project/build.properties < "http://commons.apache.org/io/api-1.4/") +val commonsFileupload = "commons-fileupload" % "commons-fileupload" % "1.2.1" % "compile" +val commonsHttpClient = "commons-httpclient" % "commons-httpclient" % "3.1" % "compile" //ApacheV2 +val commonsIo = "commons-io" % "commons-io" % "1.4" +val commons_codec = "commons-codec" % "commons-codec" % "1.4" % "compile" //ApacheV2 +val commons_coll = "commons-collections" % "commons-collections" % "3.2.1" % "test" //ApacheV2 +val commons_logging = "commons-logging" % "commons-logging" % "1.1.1" % "compile" +val commons_pool = "commons-pool" % "commons-pool" % "1.5.4" % "compile" //ApacheV2 +val core = "org.processing" % "core" % "1.1" +val defaultProject = "com.twitter" % "standard-project" % "0.9.8" +val easymockclass = "org.easymock" % "easymockclassextension" % "2.4" +val eclipse = "de.element34" % "sbt-eclipsify" % "0.5.0" +val extract = "org.scala-tools.sbt" % "installer-plugin" % "0.3.0" +val google_coll = "com.google.collections" % "google-collections" % "1.0" % "compile" //ApacheV2 +val gpgPlugin = "com.rossabaker" % "sbt-gpg-plugin" % "0.1.1" +val gstreamerJava = "com.googlecode.gstreamer-java" % "gstreamer-java" % "1.4" +val gsvideo = gsvideoName % gsvideoName % gsvideoVersion % (gsvideoConf + "->default") from(gsvideoURL) +val guicey = "org.guiceyfruit" % "guice-all" % "2.0" % "compile" +val gwtAsyncGen = "com.samskivert" % "gwt-asyncgen" % "1.0" % "system" +val gwtDev = "com.google.gwt" % "gwt-dev" % "2.1.0" % "system" +val gwtServlet = "com.google.gwt" % "gwt-servlet" % "2.1.0" % "system" +val gwtUser = "com.google.gwt" % "gwt-user" % "2.1.0" +val gwtUtils = "com.threerings" % "gwt-utils" % "1.2-SNAPSHOT" +val httpclient = "org.apache.httpcomponents" % "httpclient" % "4.0.1" +val idea = "com.github.mpeltonen" % "sbt-idea-plugin" % "0.2-SNAPSHOT" +val ideaPlugin = groupId % "sbt-idea-plugin" % testedVersion +val ivy = "org.apache.ivy" % "ivy" % "2.1.0" % "compile;runtime;test" +val jackson = "org.codehaus.jackson" % "jackson-mapper-asl" % JACKSON_VERSION % "compile" //ApacheV2 +val jacksonCore = "org.codehaus.jackson" % "jackson-core-asl" % jacksonVersion withSources() +val jacksonMapper = "org.codehaus.jackson" % "jackson-mapper-asl" % jacksonVersion withSources () +val jackson_core = "org.codehaus.jackson" % "jackson-core-asl" % JACKSON_VERSION % "compile" //ApacheV2 +val jcip = "net.jcip" % "jcip-annotations" % "1.0" % "provided->default" +val configgy = "net.lag" % "configgy" % "2.0.2-nologgy" % "compile" //ApacheV2 +val easymock = "org.easymock" % "easymock" % "2.5.1" +val guava = "com.google.guava" % "guava" "latest.release" +val jetty = "org.mortbay.jetty" % "jetty" % "6.1.25" +val jmock = "org.jmock" % "jmock" % "2.4.0" +val jodaTime = "joda-time" % "joda-time" % "1.6" +val jsengine = "javax.script" % "js-engine" % "1.0" +val jsr166x = "jsr166x" % "jsr166x" % "1.0" % "compile" //CC Public Domain +val jsr250 = "javax.annotation" % "jsr250-api" % "1.0" % "compile" //CDDL v1 +val jsr311 = "javax.ws.rs" % "jsr311-api" % "1.1" % "compile" //CDDL v1 +val jta = "javax.transaction" % "jta" % "1.1" % "provided" +val junit = "junit" % "junit" % "4.5" +val junit = "junit" % "junit" % "4.8.2" % "test" +val junitInterface = "com.novocode" % "junit-interface" % "0.4" % "test" +val logback = "ch.qos.logback" % "logback-classic" % LOGBACK_VERSION % "compile" //LGPL 2.1 +val markdown = "org.markdownj" % "markdownj" % "0.3.0-1.0.2b4" % "runtime" +val maven = "org.apache.maven" % "maven-ant-tasks" % "2.1.0" % "compile;runtime;test" +val miglayout = "com.miglayout" % "miglayout" % "3.7.1" +val mockito = "org.mockito" % "mockito-all" % "1.8.0" % "test" +val multiverse = "org.multiverse" % "multiverse-alpha" % MULTIVERSE_VERSION % "compile" intransitive //ApacheV2 +val naggati = "net.lag" % "naggati" % "0.7.2" +val netty = "org.jboss.netty" % "netty" % "3.2.3.Final" +val objenesis = "org.objenesis" % "objenesis" % "1.0" +val objenesis = "org.objenesis" % "objenesis" % "1.2" % "compile" +val opengl = "org.processing" % "opengl" % processingVersion.value +val ostrich = "com.twitter" % "ostrich" % "2.3.4" +val paranamer = "com.thoughtworks.paranamer" % "paranamer" % "2.3" withSources() +val posterous = "net.databinder" % "posterous-sbt" % "0.1.4" +val proguard = "org.scala-tools.sbt" % "sbt-proguard-plugin" % "0.0.5" +val proguardJar = "net.sf.proguard" % "proguard" % "4.4" % "tools->default" +val protobuf = "com.google.protobuf" % "protobuf-java" % "2.3.0" % "compile" //New BSD +val rsync = "com.codahale" % "rsync-sbt" % "0.1.1" +val sbinary = "sbinary" % "sbinary" % "2.8.0-0.3.1" % "compile" //MIT +val sbtIdea = "com.github.mpeltonen" % "sbt-idea-plugin" % "0.1.0" +val scalariform = "org.scalariform" % "scalariform_2.8.0" % "0.0.7"%"compile;runtime;test" +val scalate = "org.fusesource.scalate" % "scalate-core" % "1.3-SNAPSHOT" +val scriptapi = "javax.script" % "script-api" % "1.0" +val scripted = "org.scala-tools.sbt" % "scripted" % "0.7.4" +val scriptedTestUtils = groupId % "sbt-idea-tests_2.7.7" % testedVersion +val scriptjs = "javax.script" % "script-js" % "1.0" +val servlet = "javax.servlet" % "servlet-api" % "2.5" withSources +val servletApi = "org.mortbay.jetty" % "servlet-api" % "2.5-20081211" % "provided" +val sfl4japi = "org.slf4j" % "slf4j-api" % slf4jVersion % "compile" +val simplespec = "com.codahale" %% "simplespec" % "0.2.0" % "test" withSources () +val sjson = "sjson.json" % "sjson" % "0.8-2.8.0" % "compile" //ApacheV2 +val spdeSbt = "us.technically.spde" % "spde-sbt-plugin" % "0.4.2" +val spde_core = "org.processing" % "core-android" % "1.1" +val spde_sbt = "us.technically.spde" % "spde-sbt-plugin" % "0.4.2" +val spde_video = "us.technically.spde" %% "spde-video" % spdeVersion.value +val squeryl = "org.squeryl" % "squeryl_2.8.0" % "0.9.4-RC3" +val thrift = "thrift" % "libthrift" % "0.5.0" +val util = "com.twitter" % "util" % "1.4.13" +val uuid = "com.eaio" % "uuid" % "3.2" % "compile" //MIT license +val vscaladoc = "org.scala-tools" % "vscaladoc" % "1.1-md-3" +val wikitext = "org.eclipse.mylyn.wikitext" % "wikitext" % "0.9.4.I20090220-1600-e3x" +val wikitextile = "org.eclipse.mylyn.wikitext" % "wikitext.textile" % "0.9.4.I20090220-1600-e3x" +val xrayspecs = "com.twitter" % "xrayspecs" % "1.0.7" + +dispatch-http +dispatch-futures +dispatch-mime +dispatch-json +dispatch-http-json +dispatch-lift-json +dispatch-oauth +dispatch-meetup +dispatch-couch +dispatch-twitter +dispatch-times +dispatch-s3 +dispatch-google From 11468f360d8fa631e7fcf07b230e9bfe71565950 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 18 Feb 2011 17:14:07 -0800 Subject: [PATCH 011/483] Generated this project's project/ files with bin/sbt-setup. --- project/build.properties | 4 +- project/build/Libraries.scala | 61 ++++++++++++++++++++++++++ project/build/Repositories.scala | 11 +++++ project/build/SbtTemplateProject.scala | 13 ++---- 4 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 project/build/Libraries.scala create mode 100644 project/build/Repositories.scala diff --git a/project/build.properties b/project/build.properties index 1a58d1b82..eb8b9f777 100644 --- a/project/build.properties +++ b/project/build.properties @@ -2,7 +2,7 @@ #Generated by sbt-setup project.organization=improving project.name=sbt-template -sbt.version=0.7.4 -project.version=0.1 +sbt.version=0.7.5.RC0 +project.version=0.1.1 build.scala.versions=2.8.1 project.initialize=false diff --git a/project/build/Libraries.scala b/project/build/Libraries.scala new file mode 100644 index 000000000..b4f88544d --- /dev/null +++ b/project/build/Libraries.scala @@ -0,0 +1,61 @@ +import sbt._ + +case class ArtifactRevision(revision: String) +case class ArtifactConfig(confs: String, fn: ModuleID => ModuleID) +object ArtifactConfig { + implicit def defaultArtifactConfig: ArtifactConfig = new ArtifactConfig("", identity[ModuleID]) + implicit def testArtifactConfig: ArtifactConfig = new ArtifactConfig("test", identity[ModuleID]) +} + +trait LowPriorityLibraries { + self: DefaultProject => + + // "latest.integration", "latest.milestone", "latest.release" + def defaultRevision = "latest.integration" + protected implicit def defaultArtifactRevision = new ArtifactRevision(defaultRevision) + // protected implicit def defaultArtifactConfig = new ArtifactConfig("", identity[ModuleID]) + + protected implicit def autoConfig + (artifact: GroupArtifactID) + (implicit rev: ArtifactRevision, config: ArtifactConfig): ModuleID = + { + val ArtifactConfig(confs, fn) = config + fn( + if (confs == "") artifact % rev.revision + else artifact % rev.revision % config.confs + ) + } +} + +trait TestLibraries extends LowPriorityLibraries { + self: DefaultProject => + + private implicit val testDepConfig = ArtifactConfig("test", _.withSources) + val specs: ModuleID = "org.scala-tools.testing" %% "specs" + val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" +} + +trait Libraries extends Repositories with TestLibraries { + self: DefaultProject => + + import ArtifactConfig.defaultArtifactConfig + + // val ant: ModuleID = "org.apache.ant" % "ant" + // val asmAll: ModuleID = "asm" % "asm-all" withSources() + // val easymock: ModuleID = "org.easymock" % "easymock" + // val guava: ModuleID = "com.google.guava" % "guava" + // val ivy: ModuleID = "org.apache.ivy" % "ivy" + // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() + // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" + // val jmock: ModuleID = "org.jmock" % "jmock" + // val jodaTime: ModuleID = "joda-time" % "joda-time" + // val liftJson: ModuleID = "net.liftweb" %% "lift-json" + // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" + // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() + val scalaImproving: ModuleID = "org.improving" %% "scala-improving" + // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" + // val scalariform: ModuleID = "org.scalariform" %% "scalariform" + // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() + // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() + // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() +} diff --git a/project/build/Repositories.scala b/project/build/Repositories.scala new file mode 100644 index 000000000..25fd2037d --- /dev/null +++ b/project/build/Repositories.scala @@ -0,0 +1,11 @@ +import sbt._ + +trait Repositories { + self: DefaultProject => + + val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" + val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" + val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" + val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" + val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" +} diff --git a/project/build/SbtTemplateProject.scala b/project/build/SbtTemplateProject.scala index 365a5c87b..00038b02c 100644 --- a/project/build/SbtTemplateProject.scala +++ b/project/build/SbtTemplateProject.scala @@ -1,18 +1,11 @@ import sbt._ -class SbtTemplateProject(info: ProjectInfo) extends DefaultProject(info) { - val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" - val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" - val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" - - // local use +class SbttemplateProject(info: ProjectInfo) extends DefaultProject(info) with Libraries { + // -Dscala.local=/path/to/scala/build override def localScala = System.getenv("scala.local") match { case null => super.localScala case path => log.info("Found scala.local: " + path) List(defineScala("2.9.0-local", new java.io.File(path))) - } - - val scalacheck = "org.scala-tools.testing" %% "scalacheck" % "1.8" % "test" withSources() - val specs = "org.scala-tools.testing" %% "specs" % "1.6.7" % "test" withSources() + } } From bec874478113fa9f7e49a62d67d79415bb4868c4 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 26 Feb 2011 17:51:35 -0500 Subject: [PATCH 012/483] Minor updates. --- bin/sbt-setup | 12 ++++++++---- src/main/scala/Main.scala | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/sbt-setup b/bin/sbt-setup index 4b053b350..7d4c775cb 100755 --- a/bin/sbt-setup +++ b/bin/sbt-setup @@ -7,7 +7,7 @@ DEFAULT_PACKAGE="template" PACKAGE=${ORGANIZATION:-$DEFAULT_PACKAGE} SCALA_VERSION="2.8.1" SCALA_LOCAL_VERSION="2.9.0-local" -SBT_VERSION="0.7.5.RC0" +SBT_VERSION="0.7.5.RC1" if [ -z "$PROJECT" ]; then echo "Usage: $0 " @@ -79,6 +79,7 @@ trait Libraries extends Repositories with TestLibraries { // val ant: ModuleID = "org.apache.ant" % "ant" // val asmAll: ModuleID = "asm" % "asm-all" withSources() + // val commonsVFS: ModuleID = "org.apache.commons" % "commons-vfs-project" // val easymock: ModuleID = "org.easymock" % "easymock" // val guava: ModuleID = "com.google.guava" % "guava" // val ivy: ModuleID = "org.apache.ivy" % "ivy" @@ -89,7 +90,7 @@ trait Libraries extends Repositories with TestLibraries { // val liftJson: ModuleID = "net.liftweb" %% "lift-json" // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() - val scalaImproving: ModuleID = "org.improving" %% "scala-improving" + // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" // val scalariform: ModuleID = "org.scalariform" %% "scalariform" // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() @@ -128,6 +129,7 @@ EOF mkdir -p project/plugins cat > project/plugins/Plugins.scala < project/build.properties < project/build.properties < src/main/scala/Main.scala < Date: Sat, 2 Apr 2011 18:08:04 -0700 Subject: [PATCH 013/483] Major overhaul. --- bin/sbt-setup | 263 ++++++++++++++----------------- bin/util.sh | 14 ++ src/main/resources/support.scala | 89 +++++++++++ src/template/Libraries.scala | 62 ++++++++ src/template/Plugins.scala | 7 + src/template/Repositories.scala | 23 +++ 6 files changed, 314 insertions(+), 144 deletions(-) create mode 100755 bin/util.sh create mode 100644 src/main/resources/support.scala create mode 100644 src/template/Libraries.scala create mode 100644 src/template/Plugins.scala create mode 100644 src/template/Repositories.scala diff --git a/bin/sbt-setup b/bin/sbt-setup index 7d4c775cb..5bc09859c 100755 --- a/bin/sbt-setup +++ b/bin/sbt-setup @@ -1,173 +1,109 @@ -#!/bin/bash +#!/usr/bin/env bash # -PROJECT="$1" +BINDIR=$(abspath $(dirname "$0")) +. $BINDIR/util.sh +BASE=$(abspath $BINDIR/..) -DEFAULT_PACKAGE="template" -PACKAGE=${ORGANIZATION:-$DEFAULT_PACKAGE} +declare -a args +TEMPLATE="simple" SCALA_VERSION="2.8.1" -SCALA_LOCAL_VERSION="2.9.0-local" -SBT_VERSION="0.7.5.RC1" +PROJECT_VERSION="0.0.1" -if [ -z "$PROJECT" ]; then +while [ $# -gt 0 ]; do + case "$1" in + --simple) + TEMPLATE="simple" + shift + ;; + --fancy) + TEMPLATE="fancy" + shift + ;; + --version) + shift + PROJECT_VERSION="$1" + shift + ;; + --28) + SCALA_VERSION="2.8.1" + shift + ;; + --29) + SCALA_VERSION="2.9.0.RC1" + shift + ;; + *) + args=("${args[@]}" "$1") + shift + ;; + esac +done + +# reset "$@" to the remaining args +set -- "${args[@]}" + +if [[ $# -ne 1 ]]; then + cat < [dependencies] + + --simple use simple project template + --fancy use multi-file project template + --28 latest release of scala 2.8.x + --29 latest release of scala 2.9.x + + --version project initial version +EOM + + exit 1 +fi + +if [ -z "$1" ]; then echo "Usage: $0 " exit 1 fi +PROJECT="$1" +PACKAGE=${ORGANIZATION:-template} +SBT_VERSION="0.7.6.RC0" DIR=$(echo ${PROJECT} | tr '[A-Z]' '[a-z]') -PROJECT_UC=$(echo ${PROJECT:0:1} | tr '[a-z]' '[A-Z]')$(echo ${PROJECT:1} | sed -e 's/[^a-zA-Z_]//g;') -PROJECT_CLASS=${PROJECT_UC}Project -SPEC_CLASS=${PROJECT_UC}Spec +PROJECT_CC=`camelCase ${PROJECT}` +PROJECT_CLASS=${PROJECT_CC}Project +SPEC_CLASS=${PROJECT_CC}Spec -mkdir $DIR +[[ -e $DIR ]] && { echo "$DIR exists, please remove it first." ; exit 1; } + +mkdir -p $DIR cd $DIR -echo "Creating sbt project ${PROJECT} in ${PWD}" -echo "" +echo "Creating \"${PACKAGE} % ${PROJECT} % ${PROJECT_VERSION}\" from template \"$TEMPLATE\"." +echo "Building against scala $SCALA_VERSION with sbt $SBT_VERSION." +echo "Repository in ${PWD} ." +echo -cat > .gitignore < project/build/Libraries.scala < ModuleID) -object ArtifactConfig { - implicit def defaultArtifactConfig: ArtifactConfig = new ArtifactConfig("", identity[ModuleID]) - implicit def testArtifactConfig: ArtifactConfig = new ArtifactConfig("test", identity[ModuleID]) -} - -trait LowPriorityLibraries { - self: DefaultProject => - - // "latest.integration", "latest.milestone", "latest.release" - def defaultRevision = "latest.integration" - protected implicit def defaultArtifactRevision = new ArtifactRevision(defaultRevision) - // protected implicit def defaultArtifactConfig = new ArtifactConfig("", identity[ModuleID]) - - protected implicit def autoConfig - (artifact: GroupArtifactID) - (implicit rev: ArtifactRevision, config: ArtifactConfig): ModuleID = - { - val ArtifactConfig(confs, fn) = config - fn( - if (confs == "") artifact % rev.revision - else artifact % rev.revision % config.confs - ) - } -} - -trait TestLibraries extends LowPriorityLibraries { - self: DefaultProject => - - private implicit val testDepConfig = ArtifactConfig("test", _.withSources) - val specs: ModuleID = "org.scala-tools.testing" %% "specs" - val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" -} - -trait Libraries extends Repositories with TestLibraries { - self: DefaultProject => - - import ArtifactConfig.defaultArtifactConfig - - // val ant: ModuleID = "org.apache.ant" % "ant" - // val asmAll: ModuleID = "asm" % "asm-all" withSources() - // val commonsVFS: ModuleID = "org.apache.commons" % "commons-vfs-project" - // val easymock: ModuleID = "org.easymock" % "easymock" - // val guava: ModuleID = "com.google.guava" % "guava" - // val ivy: ModuleID = "org.apache.ivy" % "ivy" - // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() - // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" - // val jmock: ModuleID = "org.jmock" % "jmock" - // val jodaTime: ModuleID = "joda-time" % "joda-time" - // val liftJson: ModuleID = "net.liftweb" %% "lift-json" - // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" - // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() - // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" - // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" - // val scalariform: ModuleID = "org.scalariform" %% "scalariform" - // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() - // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() - // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() -} -EOF - -cat > project/build/Repositories.scala < - - val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" - val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" - val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" - val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" - val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" -} -EOF - -cat > project/build/${PROJECT_CLASS}.scala < super.localScala - case path => - log.info("Found scala.local: " + path) - List(defineScala("$SCALA_LOCAL_VERSION", new java.io.File(path))) - } -} -EOF - -mkdir -p project/plugins -cat > project/plugins/Plugins.scala < project/build.properties < src/main/scala/Main.scala < src/test/scala/${SPEC_CLASS}.scala < $FILE < $FILE <> $FILE + cp $BASE/src/template/Plugins.scala project/plugins +fi + +ln -s $FILE + +cat > .gitignore < + + /** Default "dynamic revision" to use with ivy. + * See [[http://www.jaya.free.fr/ivy/doc/ivyfile/dependency.html]]. + * Likely alternatives: latest.milestone, latest.release + */ + def dynamicRevision = "latest.integration" + + /** Repositories. Comment in or out to taste. + */ + val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" + val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" + val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" + val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" + val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" + + protected implicit lazy val implicitTransform: ArtifactTransform = + ArtifactTransform(inScope("test"), withSources) + + /*** Libraries ***/ + val specs: ModuleID = "org.scala-tools.testing" %% "specs" + val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" + + // val ant: ModuleID = "org.apache.ant" % "ant" + // val asmAll: ModuleID = "asm" % "asm-all" withSources() + // val commonsVFS: ModuleID = "org.apache.commons" % "commons-vfs-project" + // val easymock: ModuleID = "org.easymock" % "easymock" + // val guava: ModuleID = "com.google.guava" % "guava" + // val ivy: ModuleID = "org.apache.ivy" % "ivy" + // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() + // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" + // val jmock: ModuleID = "org.jmock" % "jmock" + // val jodaTime: ModuleID = "joda-time" % "joda-time" + // val liftJson: ModuleID = "net.liftweb" %% "lift-json" + // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" + // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() + // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" + // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" + // val scalariform: ModuleID = "org.scalariform" %% "scalariform" + // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() + // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() + // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() +} + +trait ModuleIdDynamifactory extends Dynamifactory { + self: DefaultProject => + + protected type DepId = GroupArtifactID + protected type DepOut = ModuleID + protected def finishDependency(in: GroupArtifactID, revision: String): ModuleID = in % revision + + protected implicit lazy val implicitRevision: ArtifactRevision = + ArtifactRevision(_ => dynamicRevision) + + protected def inScope(scope: String): DepFn = _ % scope + protected def withSources: DepFn = _.withSources() + protected def intransitive: DepFn = _.intransitive() + protected def withJavadoc: DepFn = _.withJavadoc + + protected def withRevision(newRevision: String): DepFn = (m: ModuleID) => { + ModuleID(m.organization, m.name, newRevision, m.configurations, m.isChanging, m.isTransitive, m.explicitArtifacts, m.extraAttributes) + } +} + +trait Dynamifactory { + protected type DepId + protected type DepOut + protected type DepFn = DepOut => DepOut + protected def dynamicRevision: String + protected def finishDependency(in: DepId, revision: String): DepOut + + case class ArtifactRevision(revisionFn: DepId => String) { + } + case class ArtifactTransform(fns: DepFn*) { + def apply(x: DepOut): DepOut = if (fns.isEmpty) x else fns.reduceLeft(_ andThen _)(x) + } + case class ArtifactConfig(rev: ArtifactRevision, transform: ArtifactTransform) { } + + protected implicit def autoassembleConfig(implicit rev: ArtifactRevision, transform: ArtifactTransform): ArtifactConfig = + ArtifactConfig(rev, transform) + + protected implicit def autoconfigureDependencies(in: DepId)(implicit config: ArtifactConfig): DepOut = { + val ArtifactConfig(ArtifactRevision(revisionFn), transform) = config + + transform(finishDependency(in, revisionFn(in))) + } +} diff --git a/src/template/Libraries.scala b/src/template/Libraries.scala new file mode 100644 index 000000000..dfd66a661 --- /dev/null +++ b/src/template/Libraries.scala @@ -0,0 +1,62 @@ +import sbt._ + +case class ArtifactRevision(revision: String) +case class ArtifactConfig(confs: String, fn: ModuleID => ModuleID) +object ArtifactConfig { + implicit def defaultArtifactConfig: ArtifactConfig = new ArtifactConfig("", identity[ModuleID]) + implicit def testArtifactConfig: ArtifactConfig = new ArtifactConfig("test", identity[ModuleID]) +} + +trait LowPriorityLibraries { + self: DefaultProject => + + // "latest.integration", "latest.milestone", "latest.release" + def defaultRevision = "latest.integration" + protected implicit def defaultArtifactRevision = new ArtifactRevision(defaultRevision) + // protected implicit def defaultArtifactConfig = new ArtifactConfig("", identity[ModuleID]) + + protected implicit def autoConfig + (artifact: GroupArtifactID) + (implicit rev: ArtifactRevision, config: ArtifactConfig): ModuleID = + { + val ArtifactConfig(confs, fn) = config + fn( + if (confs == "") artifact % rev.revision + else artifact % rev.revision % config.confs + ) + } +} + +trait TestLibraries extends LowPriorityLibraries { + self: DefaultProject => + + private implicit val testDepConfig = ArtifactConfig("test", _.withSources) + val specs: ModuleID = "org.scala-tools.testing" %% "specs" + val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" +} + +trait Libraries extends Repositories with TestLibraries { + self: DefaultProject => + + import ArtifactConfig.defaultArtifactConfig + + // val ant: ModuleID = "org.apache.ant" % "ant" + // val asmAll: ModuleID = "asm" % "asm-all" withSources() + // val commonsVFS: ModuleID = "org.apache.commons" % "commons-vfs-project" + // val easymock: ModuleID = "org.easymock" % "easymock" + // val guava: ModuleID = "com.google.guava" % "guava" + // val ivy: ModuleID = "org.apache.ivy" % "ivy" + // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() + // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" + // val jmock: ModuleID = "org.jmock" % "jmock" + // val jodaTime: ModuleID = "joda-time" % "joda-time" + // val liftJson: ModuleID = "net.liftweb" %% "lift-json" + // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" + // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() + // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" + // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" + // val scalariform: ModuleID = "org.scalariform" %% "scalariform" + // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() + // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() + // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() +} diff --git a/src/template/Plugins.scala b/src/template/Plugins.scala new file mode 100644 index 000000000..ea05fabe5 --- /dev/null +++ b/src/template/Plugins.scala @@ -0,0 +1,7 @@ +import sbt._ + +class Plugins(info: ProjectInfo) extends PluginDefinition(info) { + // def aquteRepo = "aQute Maven Repository" at "http://www.aqute.biz/repo" + // lazy val aquteModuleConfig = ModuleConfiguration("biz.aQute", aquteRepo) + // val bnd4sbt = "com.weiglewilczek.bnd4sbt" % "bnd4sbt" % "latest.release" +} diff --git a/src/template/Repositories.scala b/src/template/Repositories.scala new file mode 100644 index 000000000..c7f988f33 --- /dev/null +++ b/src/template/Repositories.scala @@ -0,0 +1,23 @@ +import sbt._ + +trait Repositories extends DefaultProject { + // self: DefaultProject => + + val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" + val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" + val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" + val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" + val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" + + // -Dscala.local=2.9.0.local=/scala/trunk/build/pack + override def localScala = System.getProperty("scala.local") match { + case null => super.localScala + case str => + val (name, path) = str indexOf '=' match { + case -1 => ("local", str) + case idx => (str take idx toString, str drop idx + 1 toString) + } + log.info("Found scala.local setting '" + name + "' at: " + path) + List(defineScala(name, new java.io.File(path))) + } +} From 592b4aca308230493ae07db06c86bd58042c45f4 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 2 Apr 2011 18:14:16 -0700 Subject: [PATCH 014/483] Generated this project from the simple template. --- .gitignore | 2 + project/build.properties | 6 +- project/build/Libraries.scala | 61 --------------- project/build/Repositories.scala | 11 --- project/build/SbtTemplateProject.scala | 100 +++++++++++++++++++++++-- project/plugins/Plugins.scala | 7 ++ 6 files changed, 104 insertions(+), 83 deletions(-) delete mode 100644 project/build/Libraries.scala delete mode 100644 project/build/Repositories.scala create mode 100644 project/plugins/Plugins.scala diff --git a/.gitignore b/.gitignore index f72e594c9..721cc4ea1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +/SbtTemplateProject.scala target /project/boot +/project/plugins lib_managed src_managed /ext diff --git a/project/build.properties b/project/build.properties index eb8b9f777..df961e0db 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,8 +1,8 @@ #Project properties -#Generated by sbt-setup +#Generated by sbt-setup on Sat Apr 2 18:11:54 PDT 2011 project.organization=improving project.name=sbt-template -sbt.version=0.7.5.RC0 -project.version=0.1.1 +sbt.version=0.7.6.RC0 +project.version=0.0.1 build.scala.versions=2.8.1 project.initialize=false diff --git a/project/build/Libraries.scala b/project/build/Libraries.scala deleted file mode 100644 index b4f88544d..000000000 --- a/project/build/Libraries.scala +++ /dev/null @@ -1,61 +0,0 @@ -import sbt._ - -case class ArtifactRevision(revision: String) -case class ArtifactConfig(confs: String, fn: ModuleID => ModuleID) -object ArtifactConfig { - implicit def defaultArtifactConfig: ArtifactConfig = new ArtifactConfig("", identity[ModuleID]) - implicit def testArtifactConfig: ArtifactConfig = new ArtifactConfig("test", identity[ModuleID]) -} - -trait LowPriorityLibraries { - self: DefaultProject => - - // "latest.integration", "latest.milestone", "latest.release" - def defaultRevision = "latest.integration" - protected implicit def defaultArtifactRevision = new ArtifactRevision(defaultRevision) - // protected implicit def defaultArtifactConfig = new ArtifactConfig("", identity[ModuleID]) - - protected implicit def autoConfig - (artifact: GroupArtifactID) - (implicit rev: ArtifactRevision, config: ArtifactConfig): ModuleID = - { - val ArtifactConfig(confs, fn) = config - fn( - if (confs == "") artifact % rev.revision - else artifact % rev.revision % config.confs - ) - } -} - -trait TestLibraries extends LowPriorityLibraries { - self: DefaultProject => - - private implicit val testDepConfig = ArtifactConfig("test", _.withSources) - val specs: ModuleID = "org.scala-tools.testing" %% "specs" - val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" -} - -trait Libraries extends Repositories with TestLibraries { - self: DefaultProject => - - import ArtifactConfig.defaultArtifactConfig - - // val ant: ModuleID = "org.apache.ant" % "ant" - // val asmAll: ModuleID = "asm" % "asm-all" withSources() - // val easymock: ModuleID = "org.easymock" % "easymock" - // val guava: ModuleID = "com.google.guava" % "guava" - // val ivy: ModuleID = "org.apache.ivy" % "ivy" - // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() - // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" - // val jmock: ModuleID = "org.jmock" % "jmock" - // val jodaTime: ModuleID = "joda-time" % "joda-time" - // val liftJson: ModuleID = "net.liftweb" %% "lift-json" - // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" - // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() - val scalaImproving: ModuleID = "org.improving" %% "scala-improving" - // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" - // val scalariform: ModuleID = "org.scalariform" %% "scalariform" - // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() - // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() - // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() -} diff --git a/project/build/Repositories.scala b/project/build/Repositories.scala deleted file mode 100644 index 25fd2037d..000000000 --- a/project/build/Repositories.scala +++ /dev/null @@ -1,11 +0,0 @@ -import sbt._ - -trait Repositories { - self: DefaultProject => - - val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" - val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" - val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" - val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" - val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" -} diff --git a/project/build/SbtTemplateProject.scala b/project/build/SbtTemplateProject.scala index 00038b02c..51c078369 100644 --- a/project/build/SbtTemplateProject.scala +++ b/project/build/SbtTemplateProject.scala @@ -1,11 +1,95 @@ import sbt._ -class SbttemplateProject(info: ProjectInfo) extends DefaultProject(info) with Libraries { - // -Dscala.local=/path/to/scala/build - override def localScala = System.getenv("scala.local") match { - case null => super.localScala - case path => - log.info("Found scala.local: " + path) - List(defineScala("2.9.0-local", new java.io.File(path))) - } +class SbtTemplateProject(info: ProjectInfo) extends DefaultProject(info) with ProjectSupport { + +} + + +trait ProjectSupport extends ModuleIdDynamifactory { + self: DefaultProject => + + /** Default "dynamic revision" to use with ivy. + * See [[http://www.jaya.free.fr/ivy/doc/ivyfile/dependency.html]]. + * Likely alternatives: latest.milestone, latest.release + */ + def dynamicRevision = "latest.integration" + + /** Repositories. Comment in or out to taste. + */ + val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" + val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" + val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" + val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" + val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" + + protected implicit lazy val implicitTransform: ArtifactTransform = + ArtifactTransform(inScope("test"), withSources) + + /*** Libraries ***/ + val specs: ModuleID = "org.scala-tools.testing" %% "specs" + val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" + + // val ant: ModuleID = "org.apache.ant" % "ant" + // val asmAll: ModuleID = "asm" % "asm-all" withSources() + // val commonsVFS: ModuleID = "org.apache.commons" % "commons-vfs-project" + // val easymock: ModuleID = "org.easymock" % "easymock" + // val guava: ModuleID = "com.google.guava" % "guava" + // val ivy: ModuleID = "org.apache.ivy" % "ivy" + // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() + // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" + // val jmock: ModuleID = "org.jmock" % "jmock" + // val jodaTime: ModuleID = "joda-time" % "joda-time" + // val liftJson: ModuleID = "net.liftweb" %% "lift-json" + // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" + // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() + // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" + // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" + // val scalariform: ModuleID = "org.scalariform" %% "scalariform" + // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() + // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() + // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() +} + +trait ModuleIdDynamifactory extends Dynamifactory { + self: DefaultProject => + + protected type DepId = GroupArtifactID + protected type DepOut = ModuleID + protected def finishDependency(in: GroupArtifactID, revision: String): ModuleID = in % revision + + protected implicit lazy val implicitRevision: ArtifactRevision = + ArtifactRevision(_ => dynamicRevision) + + protected def inScope(scope: String): DepFn = _ % scope + protected def withSources: DepFn = _.withSources() + protected def intransitive: DepFn = _.intransitive() + protected def withJavadoc: DepFn = _.withJavadoc + + protected def withRevision(newRevision: String): DepFn = (m: ModuleID) => { + ModuleID(m.organization, m.name, newRevision, m.configurations, m.isChanging, m.isTransitive, m.explicitArtifacts, m.extraAttributes) + } +} + +trait Dynamifactory { + protected type DepId + protected type DepOut + protected type DepFn = DepOut => DepOut + protected def dynamicRevision: String + protected def finishDependency(in: DepId, revision: String): DepOut + + case class ArtifactRevision(revisionFn: DepId => String) { + } + case class ArtifactTransform(fns: DepFn*) { + def apply(x: DepOut): DepOut = if (fns.isEmpty) x else fns.reduceLeft(_ andThen _)(x) + } + case class ArtifactConfig(rev: ArtifactRevision, transform: ArtifactTransform) { } + + protected implicit def autoassembleConfig(implicit rev: ArtifactRevision, transform: ArtifactTransform): ArtifactConfig = + ArtifactConfig(rev, transform) + + protected implicit def autoconfigureDependencies(in: DepId)(implicit config: ArtifactConfig): DepOut = { + val ArtifactConfig(ArtifactRevision(revisionFn), transform) = config + + transform(finishDependency(in, revisionFn(in))) + } } diff --git a/project/plugins/Plugins.scala b/project/plugins/Plugins.scala new file mode 100644 index 000000000..ea05fabe5 --- /dev/null +++ b/project/plugins/Plugins.scala @@ -0,0 +1,7 @@ +import sbt._ + +class Plugins(info: ProjectInfo) extends PluginDefinition(info) { + // def aquteRepo = "aQute Maven Repository" at "http://www.aqute.biz/repo" + // lazy val aquteModuleConfig = ModuleConfiguration("biz.aQute", aquteRepo) + // val bnd4sbt = "com.weiglewilczek.bnd4sbt" % "bnd4sbt" % "latest.release" +} From 1ce37d80bb39c66e5db91bd98f95bb90a996f1c2 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 2 Apr 2011 18:45:23 -0700 Subject: [PATCH 015/483] Adding github creation support. --- README | 8 +++++++- bin/sbt-setup | 15 +++++++++++++++ bin/util.sh | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/README b/README index 2d6b127b5..6068779c1 100644 --- a/README +++ b/README @@ -1 +1,7 @@ -This is a skeleton project for sbt. \ No newline at end of file +This is a skeleton project for sbt. + +Simple usage: + + bin/sbt-setup my-fancy-project + +That's it. Start hacking. \ No newline at end of file diff --git a/bin/sbt-setup b/bin/sbt-setup index 5bc09859c..3fb327ced 100755 --- a/bin/sbt-setup +++ b/bin/sbt-setup @@ -9,6 +9,7 @@ declare -a args TEMPLATE="simple" SCALA_VERSION="2.8.1" PROJECT_VERSION="0.0.1" +DO_GITHUB= while [ $# -gt 0 ]; do case "$1" in @@ -25,6 +26,10 @@ while [ $# -gt 0 ]; do PROJECT_VERSION="$1" shift ;; + --github) + shift + DO_GITHUB="true" + ;; --28) SCALA_VERSION="2.8.1" shift @@ -47,6 +52,7 @@ if [[ $# -ne 1 ]]; then cat < [dependencies] + --hub create github project (requires hub and more) --simple use simple project template --fancy use multi-file project template --28 latest release of scala 2.8.x @@ -163,5 +169,14 @@ git add -f project/plugins/Plugins.scala git commit -m "Initial Import for ${PROJECT_CC} (autogenerated by sbt-setup)." sbt update package test +if [[ $DO_GITHUB ]]; then + GIT_URL="git@github.com:$(githubUser)/$PROJECT.git" + echo Creating $GIT_URL + hub create + git config --local --add branch.master.remote origin + git config --local --add branch.master.merge refs/heads/master + git push origin master +fi + echo "" echo "Ready to roll in $PWD" diff --git a/bin/util.sh b/bin/util.sh index b29f28417..11915dbbe 100755 --- a/bin/util.sh +++ b/bin/util.sh @@ -12,3 +12,11 @@ function camelCase () { echo $1 | $SED -e 's/[-_]\([a-z]\)/\u\1/g' | $SED -e 's/^./\u&/;' } + +function githubUser () { + echo $(git config --global github.user) +} + +function githubToken () { + echo $(git config --global github.token) +} From 84d1909820b18ffc97da0cc899d41bb55db922a6 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 2 Apr 2011 22:51:46 -0700 Subject: [PATCH 016/483] Updates, and increasingly osx specific bash hacks. --- bin/sbt-setup | 2 +- src/main/resources/support.scala | 35 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/bin/sbt-setup b/bin/sbt-setup index 3fb327ced..92387bb30 100755 --- a/bin/sbt-setup +++ b/bin/sbt-setup @@ -1,7 +1,7 @@ #!/usr/bin/env bash # -BINDIR=$(abspath $(dirname "$0")) +BINDIR=$(dirname $(greadlink "$0")) . $BINDIR/util.sh BASE=$(abspath $BINDIR/..) diff --git a/src/main/resources/support.scala b/src/main/resources/support.scala index fa2612735..4395259a4 100644 --- a/src/main/resources/support.scala +++ b/src/main/resources/support.scala @@ -16,29 +16,32 @@ trait ProjectSupport extends ModuleIdDynamifactory { val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" - protected implicit lazy val implicitTransform: ArtifactTransform = - ArtifactTransform(inScope("test"), withSources) + private val testConfig: ArtifactConfig = ArtifactConfig( + ArtifactRevision(_ => dynamicRevision), ArtifactTransform(inScope("test"), withSources) + ) - /*** Libraries ***/ - val specs: ModuleID = "org.scala-tools.testing" %% "specs" - val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" + /*** Libraries ***/ + val specs: ModuleID = testConfig("org.scala-tools.testing" %% "specs") + val scalacheck: ModuleID = testConfig("org.scala-tools.testing" %% "scalacheck") + + private implicit lazy val implicitTransform: ArtifactTransform = ArtifactTransform() // val ant: ModuleID = "org.apache.ant" % "ant" - // val asmAll: ModuleID = "asm" % "asm-all" withSources() - // val commonsVFS: ModuleID = "org.apache.commons" % "commons-vfs-project" + // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() + // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" + // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" + // val scalariform: ModuleID = "org.scalariform" %% "scalariform" + // + // val asmAll: ModuleID = "asm" % "asm-all" % "3.3.1" withSources() // val easymock: ModuleID = "org.easymock" % "easymock" // val guava: ModuleID = "com.google.guava" % "guava" // val ivy: ModuleID = "org.apache.ivy" % "ivy" - // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" // val jmock: ModuleID = "org.jmock" % "jmock" // val jodaTime: ModuleID = "joda-time" % "joda-time" // val liftJson: ModuleID = "net.liftweb" %% "lift-json" // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() - // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" - // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" - // val scalariform: ModuleID = "org.scalariform" %% "scalariform" // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() @@ -76,14 +79,12 @@ trait Dynamifactory { case class ArtifactTransform(fns: DepFn*) { def apply(x: DepOut): DepOut = if (fns.isEmpty) x else fns.reduceLeft(_ andThen _)(x) } - case class ArtifactConfig(rev: ArtifactRevision, transform: ArtifactTransform) { } + case class ArtifactConfig(rev: ArtifactRevision, transform: ArtifactTransform) { + def apply(in: DepId): DepOut = transform(finishDependency(in, rev.revisionFn(in))) + } protected implicit def autoassembleConfig(implicit rev: ArtifactRevision, transform: ArtifactTransform): ArtifactConfig = ArtifactConfig(rev, transform) - protected implicit def autoconfigureDependencies(in: DepId)(implicit config: ArtifactConfig): DepOut = { - val ArtifactConfig(ArtifactRevision(revisionFn), transform) = config - - transform(finishDependency(in, revisionFn(in))) - } + protected implicit def autoconfigureDependencies(in: DepId)(implicit config: ArtifactConfig): DepOut = config(in) } From 7010cef2a57d9d06c59feed3771c2294f76b1383 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 15 May 2011 09:50:14 -0700 Subject: [PATCH 017/483] Made simple a lot simpler. --- bin/sbt-setup | 34 +++++++++++------ project/build.properties | 2 +- .../resources/{support.scala => fancy.scala} | 6 ++- src/main/resources/simple.scala | 37 +++++++++++++++++++ 4 files changed, 64 insertions(+), 15 deletions(-) rename src/main/resources/{support.scala => fancy.scala} (92%) create mode 100644 src/main/resources/simple.scala diff --git a/bin/sbt-setup b/bin/sbt-setup index 92387bb30..547df317d 100755 --- a/bin/sbt-setup +++ b/bin/sbt-setup @@ -1,13 +1,23 @@ #!/usr/bin/env bash # -BINDIR=$(dirname $(greadlink "$0")) +function programDir () { + SDIR=$(dirname "$1"); + echo $(cd $SDIR ; pwd -P) +} + +if [ -h "$0" ]; then + BINDIR=$(programDir $(greadlink "$0")) +else + BINDIR=$(programDir "$0") +fi + . $BINDIR/util.sh BASE=$(abspath $BINDIR/..) declare -a args TEMPLATE="simple" -SCALA_VERSION="2.8.1" + SCALA_VERSION="2.9.0" PROJECT_VERSION="0.0.1" DO_GITHUB= @@ -35,7 +45,7 @@ while [ $# -gt 0 ]; do shift ;; --29) - SCALA_VERSION="2.9.0.RC1" + SCALA_VERSION="2.9.0" shift ;; *) @@ -71,7 +81,7 @@ fi PROJECT="$1" PACKAGE=${ORGANIZATION:-template} -SBT_VERSION="0.7.6.RC0" +SBT_VERSION="0.7.7" DIR=$(echo ${PROJECT} | tr '[A-Z]' '[a-z]') PROJECT_CC=`camelCase ${PROJECT}` PROJECT_CLASS=${PROJECT_CC}Project @@ -102,13 +112,13 @@ build.scala.versions=$SCALA_VERSION project.initialize=false EOF -cat > src/main/scala/Main.scala < src/main/scala/Main.scala < src/test/scala/${SPEC_CLASS}.scala <> $FILE + cat $BASE/src/main/resources/$TEMPLATE.scala >> $FILE cp $BASE/src/template/Plugins.scala project/plugins fi diff --git a/project/build.properties b/project/build.properties index df961e0db..34584f137 100644 --- a/project/build.properties +++ b/project/build.properties @@ -2,7 +2,7 @@ #Generated by sbt-setup on Sat Apr 2 18:11:54 PDT 2011 project.organization=improving project.name=sbt-template -sbt.version=0.7.6.RC0 +sbt.version=0.7.7 project.version=0.0.1 build.scala.versions=2.8.1 project.initialize=false diff --git a/src/main/resources/support.scala b/src/main/resources/fancy.scala similarity index 92% rename from src/main/resources/support.scala rename to src/main/resources/fancy.scala index 4395259a4..293cfd238 100644 --- a/src/main/resources/support.scala +++ b/src/main/resources/fancy.scala @@ -15,14 +15,16 @@ trait ProjectSupport extends ModuleIdDynamifactory { val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" + // val akkaReleases = "Akka Maven Repository" at "http://scalablesolutions.se/akka/repository" private val testConfig: ArtifactConfig = ArtifactConfig( ArtifactRevision(_ => dynamicRevision), ArtifactTransform(inScope("test"), withSources) ) /*** Libraries ***/ - val specs: ModuleID = testConfig("org.scala-tools.testing" %% "specs") - val scalacheck: ModuleID = testConfig("org.scala-tools.testing" %% "scalacheck") + // val specs: ModuleID = testConfig("org.scala-tools.testing" %% "specs") + // val specs2: ModuleID = testConfig("org.specs2" %% "specs2") + // val scalacheck: ModuleID = testConfig("org.scala-tools.testing" %% "scalacheck") private implicit lazy val implicitTransform: ArtifactTransform = ArtifactTransform() diff --git a/src/main/resources/simple.scala b/src/main/resources/simple.scala new file mode 100644 index 000000000..77dab5f01 --- /dev/null +++ b/src/main/resources/simple.scala @@ -0,0 +1,37 @@ + +trait ProjectSupport { + self: DefaultProject => + + /** Repositories. Comment in or out to taste. + */ + val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" + val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" + val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" + val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" + val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" + // val akkaReleases = "Akka Maven Repository" at "http://scalablesolutions.se/akka/repository" + + /*** Libraries ***/ + val specs: ModuleID = "org.scala-tools.testing" %% "specs" % "1.6.8" + val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" % "1.9" + // val specs2: ModuleID = testConfig("org.specs2" %% "specs2") + // val ant: ModuleID = "org.apache.ant" % "ant" + // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() + // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" + // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" + // val scalariform: ModuleID = "org.scalariform" %% "scalariform" + // + // val asmAll: ModuleID = "asm" % "asm-all" % "3.3.1" withSources() + // val easymock: ModuleID = "org.easymock" % "easymock" + // val guava: ModuleID = "com.google.guava" % "guava" + // val ivy: ModuleID = "org.apache.ivy" % "ivy" + // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" + // val jmock: ModuleID = "org.jmock" % "jmock" + // val jodaTime: ModuleID = "joda-time" % "joda-time" + // val liftJson: ModuleID = "net.liftweb" %% "lift-json" + // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" + // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() + // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() + // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() + // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() +} From 5663bbe1e1988636cfb6aa2737e2577a86eb246e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 08:14:25 -0700 Subject: [PATCH 018/483] Working on a new template for 0.10. --- project/Build.scala | 98 ++++++++++++++++++++++++++ project/build.properties | 8 --- project/build/SbtTemplateProject.scala | 95 ------------------------- project/plugins/Plugins.scala | 7 -- 4 files changed, 98 insertions(+), 110 deletions(-) create mode 100644 project/Build.scala delete mode 100644 project/build.properties delete mode 100644 project/build/SbtTemplateProject.scala delete mode 100644 project/plugins/Plugins.scala diff --git a/project/Build.scala b/project/Build.scala new file mode 100644 index 000000000..8b2acbe31 --- /dev/null +++ b/project/Build.scala @@ -0,0 +1,98 @@ +import sbt._ +import Keys._ +import Load.{ BuildStructure, StructureIndex } +import scala.collection.{ mutable, immutable } + +object TemplateBuild extends Build { + // BuildStructure contains: + // units: Map[URI, LoadedBuildUnit] + // root: URI + // settings: Seq[Setting[_]] + // data: Settings[Scope] + // index: StructureIndex + // streams: Streams + // delegates: Scope => Seq[Scope] + // scopeLocal: ScopeLocal + + private val cachedExtraction = new collection.mutable.HashMap[State, WState] + private implicit def stateWrapper(state: State): WState = + cachedExtraction.getOrElseUpdate(state, new WState(state)) + private implicit def revealStructure(state: State): BuildStructure = + stateWrapper(state).structure + private implicit def revealStructureIndex(state: State): StructureIndex = + revealStructure(state).index + private implicit def revealSession(state: State): SessionSettings = + stateWrapper(state).session + + private class WState(state: State) { + val extracted = Project extract state + + def projectId = extracted.currentProject.id + def structure = extracted.structure + def session = extracted.session + def currentRef = extracted.currentRef + def rootProject = structure.rootProject + def allProjects = structure.allProjects + + def index = structure.index + def taskToKey = index.taskToKey + def keyMap = index.keyMap // Map[String, AttributeKey[_]] + def keyIndex = index.keyIndex + def currentKeys = keyIndex keys Some(currentRef) map index.keyMap + def sortedKeys = currentKeys.toSeq sortBy (_.label) + } + + private class Tap[T](target: T) { + def show(): Unit = target match { + case xs: TraversableOnce[_] => xs foreach println + case _ => println(target) + } + def tap[U](f: T => U): T = { + f(target) + target + } + } + private implicit def createTapper[T](target: T): Tap[T] = new Tap(target) + + def currentBranch = ("git status -sb".lines_! headOption) getOrElse "-" stripPrefix "## " + + val buildShellPrompt = { + (state: State) => "%s:%s>".format( + state.projectId, + currentBranch + ) + } + + lazy val testSettings = Seq( + libraryDependencies ++= Seq( + "org.specs2" %% "specs2" % "1.5", + "org.specs2" %% "specs2-scalaz-core" % "6.0.RC2" % "test" + ) + ) + + lazy val buildSettings = Seq( + resolvers += ScalaToolsSnapshots, + organization := "org.template", + version := "0.1-SNAPSHOT", + scalaVersion := "2.9.0-1", + retrieveManaged := true, + shellPrompt := buildShellPrompt + // logLevel := Level.Debug, + ) + + lazy val templateConfig = Project( + id = "template", + base = file("."), + aggregate = Nil, + dependencies = Nil, + delegates = Nil, + settings = Defaults.defaultSettings ++ buildSettings ++ Seq( + commands += helpNames + ) + ) + + // A sample command definition. + def helpNames = Command.command("help-names") { (state: State) => + state tap (_.sortedKeys map (_.label) show) + } +} diff --git a/project/build.properties b/project/build.properties deleted file mode 100644 index 34584f137..000000000 --- a/project/build.properties +++ /dev/null @@ -1,8 +0,0 @@ -#Project properties -#Generated by sbt-setup on Sat Apr 2 18:11:54 PDT 2011 -project.organization=improving -project.name=sbt-template -sbt.version=0.7.7 -project.version=0.0.1 -build.scala.versions=2.8.1 -project.initialize=false diff --git a/project/build/SbtTemplateProject.scala b/project/build/SbtTemplateProject.scala deleted file mode 100644 index 51c078369..000000000 --- a/project/build/SbtTemplateProject.scala +++ /dev/null @@ -1,95 +0,0 @@ -import sbt._ - -class SbtTemplateProject(info: ProjectInfo) extends DefaultProject(info) with ProjectSupport { - -} - - -trait ProjectSupport extends ModuleIdDynamifactory { - self: DefaultProject => - - /** Default "dynamic revision" to use with ivy. - * See [[http://www.jaya.free.fr/ivy/doc/ivyfile/dependency.html]]. - * Likely alternatives: latest.milestone, latest.release - */ - def dynamicRevision = "latest.integration" - - /** Repositories. Comment in or out to taste. - */ - val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" - val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" - val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" - val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" - val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" - - protected implicit lazy val implicitTransform: ArtifactTransform = - ArtifactTransform(inScope("test"), withSources) - - /*** Libraries ***/ - val specs: ModuleID = "org.scala-tools.testing" %% "specs" - val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" - - // val ant: ModuleID = "org.apache.ant" % "ant" - // val asmAll: ModuleID = "asm" % "asm-all" withSources() - // val commonsVFS: ModuleID = "org.apache.commons" % "commons-vfs-project" - // val easymock: ModuleID = "org.easymock" % "easymock" - // val guava: ModuleID = "com.google.guava" % "guava" - // val ivy: ModuleID = "org.apache.ivy" % "ivy" - // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() - // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" - // val jmock: ModuleID = "org.jmock" % "jmock" - // val jodaTime: ModuleID = "joda-time" % "joda-time" - // val liftJson: ModuleID = "net.liftweb" %% "lift-json" - // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" - // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() - // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" - // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" - // val scalariform: ModuleID = "org.scalariform" %% "scalariform" - // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() - // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() - // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() -} - -trait ModuleIdDynamifactory extends Dynamifactory { - self: DefaultProject => - - protected type DepId = GroupArtifactID - protected type DepOut = ModuleID - protected def finishDependency(in: GroupArtifactID, revision: String): ModuleID = in % revision - - protected implicit lazy val implicitRevision: ArtifactRevision = - ArtifactRevision(_ => dynamicRevision) - - protected def inScope(scope: String): DepFn = _ % scope - protected def withSources: DepFn = _.withSources() - protected def intransitive: DepFn = _.intransitive() - protected def withJavadoc: DepFn = _.withJavadoc - - protected def withRevision(newRevision: String): DepFn = (m: ModuleID) => { - ModuleID(m.organization, m.name, newRevision, m.configurations, m.isChanging, m.isTransitive, m.explicitArtifacts, m.extraAttributes) - } -} - -trait Dynamifactory { - protected type DepId - protected type DepOut - protected type DepFn = DepOut => DepOut - protected def dynamicRevision: String - protected def finishDependency(in: DepId, revision: String): DepOut - - case class ArtifactRevision(revisionFn: DepId => String) { - } - case class ArtifactTransform(fns: DepFn*) { - def apply(x: DepOut): DepOut = if (fns.isEmpty) x else fns.reduceLeft(_ andThen _)(x) - } - case class ArtifactConfig(rev: ArtifactRevision, transform: ArtifactTransform) { } - - protected implicit def autoassembleConfig(implicit rev: ArtifactRevision, transform: ArtifactTransform): ArtifactConfig = - ArtifactConfig(rev, transform) - - protected implicit def autoconfigureDependencies(in: DepId)(implicit config: ArtifactConfig): DepOut = { - val ArtifactConfig(ArtifactRevision(revisionFn), transform) = config - - transform(finishDependency(in, revisionFn(in))) - } -} diff --git a/project/plugins/Plugins.scala b/project/plugins/Plugins.scala deleted file mode 100644 index ea05fabe5..000000000 --- a/project/plugins/Plugins.scala +++ /dev/null @@ -1,7 +0,0 @@ -import sbt._ - -class Plugins(info: ProjectInfo) extends PluginDefinition(info) { - // def aquteRepo = "aQute Maven Repository" at "http://www.aqute.biz/repo" - // lazy val aquteModuleConfig = ModuleConfiguration("biz.aQute", aquteRepo) - // val bnd4sbt = "com.weiglewilczek.bnd4sbt" % "bnd4sbt" % "latest.release" -} From 0920f5dda87e30f388b585f13fb604efc154f9d4 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 08:22:50 -0700 Subject: [PATCH 019/483] Start of a more capable runner. --- bin/xsbt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 bin/xsbt diff --git a/bin/xsbt b/bin/xsbt new file mode 100755 index 000000000..3c6b785ce --- /dev/null +++ b/bin/xsbt @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# + +sbt_jar=/soft/inst/sbt/xsbt-launch.jar + +# get completion if present +[[ -f .sbt_completion.sh ]] && source .sbt_completion.sh + +java $JAVA_OPTS \ + $SBT_OPTS \ + -XX:+CMSClassUnloadingEnabled \ + -XX:ReservedCodeCacheSize=1g \ + -XX:MaxPermSize=512m -Xmx4g -Xss4m \ + -jar "$sbt_jar" \ + "$@" From 6c679d457f8b4fdf630cea6f5a90c266abd83250 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 08:48:29 -0700 Subject: [PATCH 020/483] Creation configuration starting to take shape. --- bin/sbt-setup | 79 ++------------------------------------------- bin/util.sh | 40 ++++++++++++++++++++--- bin/xsbt | 33 +++++++++++++++---- project/Build.scala | 23 ++++++++++++- 4 files changed, 88 insertions(+), 87 deletions(-) diff --git a/bin/sbt-setup b/bin/sbt-setup index 547df317d..e9c82ffe5 100755 --- a/bin/sbt-setup +++ b/bin/sbt-setup @@ -17,8 +17,8 @@ BASE=$(abspath $BINDIR/..) declare -a args TEMPLATE="simple" - SCALA_VERSION="2.9.0" -PROJECT_VERSION="0.0.1" + SCALA_VERSION="2.9.1" +PROJECT_VERSION="0.1" DO_GITHUB= while [ $# -gt 0 ]; do @@ -112,81 +112,8 @@ build.scala.versions=$SCALA_VERSION project.initialize=false EOF -# cat > src/main/scala/Main.scala < src/test/scala/${SPEC_CLASS}.scala <> { - 1 mustEqual 1 - } - } -} -EOF - -FILE=project/build/${PROJECT_CLASS}.scala -if [[ $TEMPLATE == "fancy" ]]; then - cp $BASE/src/template/Libraries.scala project/build - cp $BASE/src/template/Repositories.scala project/build - cp $BASE/src/template/Plugins.scala project/plugins - - cat > $FILE < $FILE <> $FILE - cp $BASE/src/template/Plugins.scala project/plugins -fi - -ln -s $FILE - -cat > .gitignore < .gitignore < project initial version +EOM +} + +# no args +[[ $# -gt 0 ]] || { usage ; exit 1; } + +# run +java \ + $JAVA_OPTS \ + $jvm_opts_standard \ + $jvm_opts_memory \ + $SBT_OPTS \ -jar "$sbt_jar" \ "$@" + + diff --git a/project/Build.scala b/project/Build.scala index 8b2acbe31..5f0a92a11 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -3,7 +3,26 @@ import Keys._ import Load.{ BuildStructure, StructureIndex } import scala.collection.{ mutable, immutable } -object TemplateBuild extends Build { +trait SbtCreateConfig { + def name: String + def organization: String + def version: String + def scalaVersion: String +} +object SbtCreateConfig { + private def prop(propName: String, alt: String) = System.getProperty(propName) match { + case null => alt + case value => value + } + implicit def defaultProjectConfig = new SbtCreateConfig { + def name = prop("sbt-create.name", "project-name-here") + def organization = prop("sbt-create.organization", "your.organization.here") + def version = prop("sbt-create.version", "0.1") + def scalaVersion = prop("sbt-create.scalaVersion", "2.9.0-1") + } +} + +class TemplateBuild(implicit sbtCreateConfig: SbtCreateConfig) extends Build { // BuildStructure contains: // units: Map[URI, LoadedBuildUnit] // root: URI @@ -96,3 +115,5 @@ object TemplateBuild extends Build { state tap (_.sortedKeys map (_.label) show) } } + +object TemplateBuild extends TemplateBuild { } From 7f6bd6b7a774524aa5a71f81d19774debc9d1640 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 09:05:01 -0700 Subject: [PATCH 021/483] Coming right along. --- bin/sbt-setup | 16 +--------------- bin/util.sh | 9 +-------- bin/xsbt | 39 +++++++++++++++++++++++++++++++-------- project/Build.scala | 10 +++++----- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/bin/sbt-setup b/bin/sbt-setup index e9c82ffe5..a81094f8c 100755 --- a/bin/sbt-setup +++ b/bin/sbt-setup @@ -96,21 +96,7 @@ echo "Building against scala $SCALA_VERSION with sbt $SBT_VERSION." echo "Repository in ${PWD} ." echo -for dir in project/build project/plugins src/main/scala src/main/java src/test/scala src/test/java -do - mkdir -p $dir -done - -cat > project/build.properties < project initial version + -help prints this message + -create creates a new project + -version project initial version + -28 latest release of scala 2.8.x + -29 latest release of scala 2.9.x + -210 latest snapshot of scala 2.10 EOM } # no args -[[ $# -gt 0 ]] || { usage ; exit 1; } +[[ $# -gt 0 ]] || echo "Starting $script_name: invoke with -help for other options" -# run +# pull -J and -D options to give to java. +declare -a args +declare -a java_args +addJavaArg () { + java_args=("${java_args[@]}" "$1") +} + +while [ $# -gt 0 ]; do + case "$1" in + -help) usage; exit 1 ;; + -D*) addJavaArg "$1"; shift ;; + -J*) addJavaArg "${1:2}"; shift ;; + -28) addJavaArg "-Dsbt-create.scalaVersion=2.8.1"; shift ;; + -29) addJavaArg "-Dsbt-create.scalaVersion=2.9.1"; shift ;; + -210) addJavaArg "-Dsbt-create.scalaVersion=2.10.0-SNAPSHOT"; shift ;; + *) args=("${args[@]}" "$1") ; shift ;; + esac +done + +# reset "$@" to the residual args +set -- "${args[@]}" + +# run sbt java \ $JAVA_OPTS \ $jvm_opts_standard \ $jvm_opts_memory \ $SBT_OPTS \ + ${java_args[@]} \ -jar "$sbt_jar" \ "$@" - - diff --git a/project/Build.scala b/project/Build.scala index 5f0a92a11..4a18be5bb 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -17,7 +17,7 @@ object SbtCreateConfig { implicit def defaultProjectConfig = new SbtCreateConfig { def name = prop("sbt-create.name", "project-name-here") def organization = prop("sbt-create.organization", "your.organization.here") - def version = prop("sbt-create.version", "0.1") + def version = prop("sbt-create.version", "0.1-SNAPSHOT") def scalaVersion = prop("sbt-create.scalaVersion", "2.9.0-1") } } @@ -91,16 +91,16 @@ class TemplateBuild(implicit sbtCreateConfig: SbtCreateConfig) extends Build { lazy val buildSettings = Seq( resolvers += ScalaToolsSnapshots, - organization := "org.template", - version := "0.1-SNAPSHOT", - scalaVersion := "2.9.0-1", + organization := sbtCreateConfig.organization, + version := sbtCreateConfig.version, + scalaVersion := sbtCreateConfig.scalaVersion, retrieveManaged := true, shellPrompt := buildShellPrompt // logLevel := Level.Debug, ) lazy val templateConfig = Project( - id = "template", + id = sbtCreateConfig.name, base = file("."), aggregate = Nil, dependencies = Nil, From 2c79fe5ddaeb2194a91b76d86567706f80c36ee9 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 09:55:31 -0700 Subject: [PATCH 022/483] Nearly ready to ship. --- bin/xsbt | 74 ++++++++++++++++++++++++++++----------- project/Build.scala | 2 +- src/main/scala/Main.scala | 3 +- 3 files changed, 55 insertions(+), 24 deletions(-) diff --git a/bin/xsbt b/bin/xsbt index 2ef442719..ec13fb472 100755 --- a/bin/xsbt +++ b/bin/xsbt @@ -3,9 +3,11 @@ declare -r script_name="$(basename $BASH_SOURCE)" declare -r sbt_jar=/soft/inst/sbt/xsbt-launch.jar - -jvm_opts_standard="-XX:+CMSClassUnloadingEnabled -XX:ReservedCodeCacheSize=1g" -jvm_opts_memory="-XX:MaxPermSize=512m -Xmx4g -Xss4m" +declare -r default_java_opts="-Dfile.encoding=UTF8" +declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" +declare -r latest_28="2.8.1" +declare -r latest_29="2.9.0-1" +declare -r latest_210="2.10.0-SNAPSHOT" # get completion if present [[ -f .sbt_completion.sh ]] && source .sbt_completion.sh @@ -15,33 +17,64 @@ usage () { Usage: $script_name [options] -help prints this message - -create creates a new project - -version project initial version - -28 latest release of scala 2.8.x - -29 latest release of scala 2.9.x - -210 latest snapshot of scala 2.10 + -boot path to shared sbt boot directory (default: none) + -debug set sbt log level to debug + -global path to directory containing global settings and plugins (default: ~/.sbt) + -ivy path to local Ivy repository (default: ~/.ivy2) + -nocolor disable ANSI color codes + + -28 set scala version to $latest_28 + -29 set scala version to $latest_29 + -210 set scala version to $latest_210 + + -Dkey=val pass -Dkey=val directly to the jvm + -J-X pass option -X directly to the jvm + +The contents of the following environment variables, if any, will be +passed to the jvm. Later variables take priority over earlier ones, and +command line options (-D/-J) take priority over all of them. + + JAVA_OPTS # defaults: $default_java_opts + SBT_OPTS # defaults: $default_sbt_opts + +If an environment variable is set, its defaults are not given. EOM } -# no args -[[ $# -gt 0 ]] || echo "Starting $script_name: invoke with -help for other options" +# no args - alert them there's stuff in here +[[ $# -gt 0 ]] || { + echo "Starting $script_name: invoke with -help for other options" + # so it still starts if we injected any sbt commands + set -- "shell" +} # pull -J and -D options to give to java. declare -a args declare -a java_args -addJavaArg () { +declare -a sbt_commands +addJava () { java_args=("${java_args[@]}" "$1") } +addSbt () { + sbt_commands=("${sbt_commands[@]}" "$1") +} while [ $# -gt 0 ]; do case "$1" in - -help) usage; exit 1 ;; - -D*) addJavaArg "$1"; shift ;; - -J*) addJavaArg "${1:2}"; shift ;; - -28) addJavaArg "-Dsbt-create.scalaVersion=2.8.1"; shift ;; - -29) addJavaArg "-Dsbt-create.scalaVersion=2.9.1"; shift ;; - -210) addJavaArg "-Dsbt-create.scalaVersion=2.10.0-SNAPSHOT"; shift ;; - *) args=("${args[@]}" "$1") ; shift ;; + -help) usage; exit 1 ;; + -global) addJava "-Dsbt.global.base=$2"; shift 2 ;; + -boot) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; + -ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;; + -nocolors) addJava "-Dsbt.log.noformat=true"; shift ;; + -28) addJava "-Dsbt.scala.version=$latest_28"; shift ;; + -29) addJava "-Dsbt.scala.version=$latest_29"; shift ;; + -210) addJava "-Dsbt.scala.version=$latest_210"; shift ;; + + -D*) addJava "$1"; shift ;; + -J*) addJava "${1:2}"; shift ;; + -debug) addSbt "set logLevel := Level.Debug"; shift ;; + + *) args=("${args[@]}" "$1") ; shift ;; esac done @@ -51,9 +84,8 @@ set -- "${args[@]}" # run sbt java \ $JAVA_OPTS \ - $jvm_opts_standard \ - $jvm_opts_memory \ - $SBT_OPTS \ + ${SBT_OPTS:-$default_sbt_opts} \ ${java_args[@]} \ -jar "$sbt_jar" \ + "${sbt_commands[@]}" \ "$@" diff --git a/project/Build.scala b/project/Build.scala index 4a18be5bb..c11f8f71a 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -18,7 +18,7 @@ object SbtCreateConfig { def name = prop("sbt-create.name", "project-name-here") def organization = prop("sbt-create.organization", "your.organization.here") def version = prop("sbt-create.version", "0.1-SNAPSHOT") - def scalaVersion = prop("sbt-create.scalaVersion", "2.9.0-1") + def scalaVersion = prop("sbt.scala.version", "2.9.0-1") } } diff --git a/src/main/scala/Main.scala b/src/main/scala/Main.scala index ff9395182..bff37c687 100644 --- a/src/main/scala/Main.scala +++ b/src/main/scala/Main.scala @@ -2,7 +2,6 @@ package template object Main { def main(args: Array[String]): Unit = { - // Your code here - args foreach println + println("Skeleton main, reporting for duty on " + util.Properties.versionString) } } From 92574653404eaa177c6d3e522a43cef3ce1dba3a Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 09:58:27 -0700 Subject: [PATCH 023/483] Preparing to branch. --- README | 7 +------ bin/{util.sh => git-util.sh} | 0 bin/{xsbt => sbt-runner} | 0 3 files changed, 1 insertion(+), 6 deletions(-) rename bin/{util.sh => git-util.sh} (100%) rename bin/{xsbt => sbt-runner} (100%) diff --git a/README b/README index 6068779c1..3adaf4e9c 100644 --- a/README +++ b/README @@ -1,7 +1,2 @@ -This is a skeleton project for sbt. +This is a more capable runner for sbt, as well as a template sbt project. -Simple usage: - - bin/sbt-setup my-fancy-project - -That's it. Start hacking. \ No newline at end of file diff --git a/bin/util.sh b/bin/git-util.sh similarity index 100% rename from bin/util.sh rename to bin/git-util.sh diff --git a/bin/xsbt b/bin/sbt-runner similarity index 100% rename from bin/xsbt rename to bin/sbt-runner From ba2f8d4afd661c2be27a35e7ded790610c2dd6b5 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 10:00:16 -0700 Subject: [PATCH 024/483] Removed everything but the runner and build file. --- bin/git-util.sh | 47 ----------- bin/sbt-setup | 105 ----------------------- bin/sbt-runner => sbt-runner | 0 src/main/{scala => }/Main.scala | 0 src/main/resources/fancy.scala | 92 -------------------- src/main/resources/simple.scala | 37 --------- src/main/scala/example/Rational.scala | 56 ------------- src/main/scala/example/Sequences.scala | 22 ----- src/main/scala/example/package.scala | 9 -- src/template/Libraries.scala | 62 -------------- src/template/Plugins.scala | 7 -- src/template/Repositories.scala | 23 ----- src/test/scala/ExampleSpec.scala | 19 ----- src/test/scala/TemplateSpec.scala | 11 --- todo/artifacts.txt | 111 ------------------------- 15 files changed, 601 deletions(-) delete mode 100755 bin/git-util.sh delete mode 100755 bin/sbt-setup rename bin/sbt-runner => sbt-runner (100%) rename src/main/{scala => }/Main.scala (100%) delete mode 100644 src/main/resources/fancy.scala delete mode 100644 src/main/resources/simple.scala delete mode 100644 src/main/scala/example/Rational.scala delete mode 100644 src/main/scala/example/Sequences.scala delete mode 100644 src/main/scala/example/package.scala delete mode 100644 src/template/Libraries.scala delete mode 100644 src/template/Plugins.scala delete mode 100644 src/template/Repositories.scala delete mode 100644 src/test/scala/ExampleSpec.scala delete mode 100644 src/test/scala/TemplateSpec.scala delete mode 100644 todo/artifacts.txt diff --git a/bin/git-util.sh b/bin/git-util.sh deleted file mode 100755 index 77abfa8bc..000000000 --- a/bin/git-util.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -# - -camelCase () { - # pretty sad having to resort to this in 2011 - SED="" - if [ -f /usr/local/bin/gsed ]; then - SED=/usr/local/bin/gsed - else - SED=sed - fi - - echo "$1" | $SED -e 's/[-_]\([a-z]\)/\u\1/g' | $SED -e 's/^./\u&/;' -} - -createGithub () { - which hub && { echo "You need hub for this." ; return } - - local project="$1" - # local git_token=$(git config --global github.token) - local git_url="git@github.com:$(git config --global github.user)/$project.git" - - echo Creating $git_url - hub create - git config --local --add branch.master.remote origin - git config --local --add branch.master.merge refs/heads/master - git push origin master -fi - -createGitIgnore () { - cat > .gitignore < [dependencies] - - --hub create github project (requires hub and more) - --simple use simple project template - --fancy use multi-file project template - --28 latest release of scala 2.8.x - --29 latest release of scala 2.9.x - - --version project initial version -EOM - - exit 1 -fi - -if [ -z "$1" ]; then - echo "Usage: $0 " - exit 1 -fi - -PROJECT="$1" -PACKAGE=${ORGANIZATION:-template} -SBT_VERSION="0.7.7" -DIR=$(echo ${PROJECT} | tr '[A-Z]' '[a-z]') -PROJECT_CC=`camelCase ${PROJECT}` -PROJECT_CLASS=${PROJECT_CC}Project -SPEC_CLASS=${PROJECT_CC}Spec - -[[ -e $DIR ]] && { echo "$DIR exists, please remove it first." ; exit 1; } - -mkdir -p $DIR -cd $DIR -echo "Creating \"${PACKAGE} % ${PROJECT} % ${PROJECT_VERSION}\" from template \"$TEMPLATE\"." -echo "Building against scala $SCALA_VERSION with sbt $SBT_VERSION." -echo "Repository in ${PWD} ." -echo - -mkdir -p project src/main/scala src/main/java src/test/scala src/test/java - -createGitRepo -sbt update package test - -echo "" -echo "Ready to roll in $PWD" diff --git a/bin/sbt-runner b/sbt-runner similarity index 100% rename from bin/sbt-runner rename to sbt-runner diff --git a/src/main/scala/Main.scala b/src/main/Main.scala similarity index 100% rename from src/main/scala/Main.scala rename to src/main/Main.scala diff --git a/src/main/resources/fancy.scala b/src/main/resources/fancy.scala deleted file mode 100644 index 293cfd238..000000000 --- a/src/main/resources/fancy.scala +++ /dev/null @@ -1,92 +0,0 @@ - -trait ProjectSupport extends ModuleIdDynamifactory { - self: DefaultProject => - - /** Default "dynamic revision" to use with ivy. - * See [[http://www.jaya.free.fr/ivy/doc/ivyfile/dependency.html]]. - * Likely alternatives: latest.milestone, latest.release - */ - def dynamicRevision = "latest.integration" - - /** Repositories. Comment in or out to taste. - */ - val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" - val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" - val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" - val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" - val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" - // val akkaReleases = "Akka Maven Repository" at "http://scalablesolutions.se/akka/repository" - - private val testConfig: ArtifactConfig = ArtifactConfig( - ArtifactRevision(_ => dynamicRevision), ArtifactTransform(inScope("test"), withSources) - ) - - /*** Libraries ***/ - // val specs: ModuleID = testConfig("org.scala-tools.testing" %% "specs") - // val specs2: ModuleID = testConfig("org.specs2" %% "specs2") - // val scalacheck: ModuleID = testConfig("org.scala-tools.testing" %% "scalacheck") - - private implicit lazy val implicitTransform: ArtifactTransform = ArtifactTransform() - - // val ant: ModuleID = "org.apache.ant" % "ant" - // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() - // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" - // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" - // val scalariform: ModuleID = "org.scalariform" %% "scalariform" - // - // val asmAll: ModuleID = "asm" % "asm-all" % "3.3.1" withSources() - // val easymock: ModuleID = "org.easymock" % "easymock" - // val guava: ModuleID = "com.google.guava" % "guava" - // val ivy: ModuleID = "org.apache.ivy" % "ivy" - // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" - // val jmock: ModuleID = "org.jmock" % "jmock" - // val jodaTime: ModuleID = "joda-time" % "joda-time" - // val liftJson: ModuleID = "net.liftweb" %% "lift-json" - // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" - // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() - // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() - // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() - // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() -} - -trait ModuleIdDynamifactory extends Dynamifactory { - self: DefaultProject => - - protected type DepId = GroupArtifactID - protected type DepOut = ModuleID - protected def finishDependency(in: GroupArtifactID, revision: String): ModuleID = in % revision - - protected implicit lazy val implicitRevision: ArtifactRevision = - ArtifactRevision(_ => dynamicRevision) - - protected def inScope(scope: String): DepFn = _ % scope - protected def withSources: DepFn = _.withSources() - protected def intransitive: DepFn = _.intransitive() - protected def withJavadoc: DepFn = _.withJavadoc - - protected def withRevision(newRevision: String): DepFn = (m: ModuleID) => { - ModuleID(m.organization, m.name, newRevision, m.configurations, m.isChanging, m.isTransitive, m.explicitArtifacts, m.extraAttributes) - } -} - -trait Dynamifactory { - protected type DepId - protected type DepOut - protected type DepFn = DepOut => DepOut - protected def dynamicRevision: String - protected def finishDependency(in: DepId, revision: String): DepOut - - case class ArtifactRevision(revisionFn: DepId => String) { - } - case class ArtifactTransform(fns: DepFn*) { - def apply(x: DepOut): DepOut = if (fns.isEmpty) x else fns.reduceLeft(_ andThen _)(x) - } - case class ArtifactConfig(rev: ArtifactRevision, transform: ArtifactTransform) { - def apply(in: DepId): DepOut = transform(finishDependency(in, rev.revisionFn(in))) - } - - protected implicit def autoassembleConfig(implicit rev: ArtifactRevision, transform: ArtifactTransform): ArtifactConfig = - ArtifactConfig(rev, transform) - - protected implicit def autoconfigureDependencies(in: DepId)(implicit config: ArtifactConfig): DepOut = config(in) -} diff --git a/src/main/resources/simple.scala b/src/main/resources/simple.scala deleted file mode 100644 index 77dab5f01..000000000 --- a/src/main/resources/simple.scala +++ /dev/null @@ -1,37 +0,0 @@ - -trait ProjectSupport { - self: DefaultProject => - - /** Repositories. Comment in or out to taste. - */ - val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" - val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" - val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" - val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" - val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" - // val akkaReleases = "Akka Maven Repository" at "http://scalablesolutions.se/akka/repository" - - /*** Libraries ***/ - val specs: ModuleID = "org.scala-tools.testing" %% "specs" % "1.6.8" - val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" % "1.9" - // val specs2: ModuleID = testConfig("org.specs2" %% "specs2") - // val ant: ModuleID = "org.apache.ant" % "ant" - // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() - // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" - // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" - // val scalariform: ModuleID = "org.scalariform" %% "scalariform" - // - // val asmAll: ModuleID = "asm" % "asm-all" % "3.3.1" withSources() - // val easymock: ModuleID = "org.easymock" % "easymock" - // val guava: ModuleID = "com.google.guava" % "guava" - // val ivy: ModuleID = "org.apache.ivy" % "ivy" - // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" - // val jmock: ModuleID = "org.jmock" % "jmock" - // val jodaTime: ModuleID = "joda-time" % "joda-time" - // val liftJson: ModuleID = "net.liftweb" %% "lift-json" - // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" - // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() - // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() - // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() - // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() -} diff --git a/src/main/scala/example/Rational.scala b/src/main/scala/example/Rational.scala deleted file mode 100644 index 44434dd3b..000000000 --- a/src/main/scala/example/Rational.scala +++ /dev/null @@ -1,56 +0,0 @@ -package example - -// Primary constructor takes two arguments. -class Rational(n: Int, d: Int) { - // an auxiliary constructor: must call the primary constructor first. - def this(n: Int) = this(n, 1) - // A requirement: an exception is thrown upon construction if the condition is false. - require(d > 0, "denominator must be greater than zero") - - // A grossly inefficient greatest common divisor, for illustrative purposes only. - private def gcd(n: Int, d: Int) = ( - n max d to 2 by -1 find (g => n % g == 0 && d % g == 0) getOrElse 1 - ) - // Using the gcd to calculate reduced numerator and denominator. - private val g = gcd(n, d) - // Public, immutable values. - val numerator = n / g - val denominator = d / g - - // Assume we have r1: Rational, r2: Rational, and num: Int. - // Since + is a method like any other, if we define it with a - // Rational argument then r1 + r2 is defined. - def +(that: Rational): Rational = new Rational( - this.numerator * that.denominator + that.numerator * this.denominator, - this.denominator * that.denominator - ) - // You can overload the + method with an Int argument: now r1 + num - // is also defined. However to make num + r1 work similarly requires - // an implicit conversion. (See the example package object.) - def +(that: Int): Rational = this + new Rational(that) - - // toString, equals, and hashCode all override methods in AnyRef - // so "override" is required. - override def toString = n + "/" + d + ( - // The result of the if/else is a String: - if (numerator == n) "" // the empty string if it is irreducible - else " (" + numerator + "/" + denominator + ")" // the reduced form otherwise - ) - - // To preserve symmetry we will be equal only to other Rationals. - override def equals(other: Any) = other match { - case x: Rational => this.numerator == x.numerator && this.denominator == x.denominator - case _ => false - } - // As with java, equals and hashCode should always be overridden together. - override def hashCode = numerator.## + denominator.## -} - -// The Rational companion object. -object Rational { - // A factory method on the companion object allows construction - // without explicit calls to new. Here, d is given a default argument - // of 1. This is an alternative mechanism to the auxiliary constructor. - // used in the class. - def apply(n: Int, d: Int = 1): Rational = new Rational(n, d) -} \ No newline at end of file diff --git a/src/main/scala/example/Sequences.scala b/src/main/scala/example/Sequences.scala deleted file mode 100644 index be25b0e31..000000000 --- a/src/main/scala/example/Sequences.scala +++ /dev/null @@ -1,22 +0,0 @@ -package example - -// These implementations have no error checking: they will throw -// exceptions if the input is unexpected, e.g. an empty list has no -// penultimate member. -object Exercises { - def penultimate[T](xs: List[T]): T = xs.reverse.tail.head - // Other possible implementations: - // def penultimate[T](xs: List[T]): T = xs.init.last - // def penultimate[T](xs: List[T]): T = xs(xs.length - 2) - // def penultimate[T](xs: List[T]): T = xs takeRight 2 head - - // Test if the argument is a palindrome. - def isPalindrome[T](xs: List[T]) = xs == xs.reverse - - // Remove the Kth element from a list, returning the list and - // the removed element as a tuple. - def removeAt[T](index: Int, xs: List[T]): (List[T], T) = { - val (front, back) = xs splitAt index - (front ++ back.tail, back.head) - } -} \ No newline at end of file diff --git a/src/main/scala/example/package.scala b/src/main/scala/example/package.scala deleted file mode 100644 index 5581bcb09..000000000 --- a/src/main/scala/example/package.scala +++ /dev/null @@ -1,9 +0,0 @@ -// The example package object. -package object example { - // Importing an implicit method of type Int => Rational will - // henceforth let us use Ints as if they were Rationals. - implicit def intToRational(num: Int): Rational = new Rational(num) - - // A handy method for exercises yet to be performed. - def ?? = throw new RuntimeException("Unimplemented.") -} \ No newline at end of file diff --git a/src/template/Libraries.scala b/src/template/Libraries.scala deleted file mode 100644 index dfd66a661..000000000 --- a/src/template/Libraries.scala +++ /dev/null @@ -1,62 +0,0 @@ -import sbt._ - -case class ArtifactRevision(revision: String) -case class ArtifactConfig(confs: String, fn: ModuleID => ModuleID) -object ArtifactConfig { - implicit def defaultArtifactConfig: ArtifactConfig = new ArtifactConfig("", identity[ModuleID]) - implicit def testArtifactConfig: ArtifactConfig = new ArtifactConfig("test", identity[ModuleID]) -} - -trait LowPriorityLibraries { - self: DefaultProject => - - // "latest.integration", "latest.milestone", "latest.release" - def defaultRevision = "latest.integration" - protected implicit def defaultArtifactRevision = new ArtifactRevision(defaultRevision) - // protected implicit def defaultArtifactConfig = new ArtifactConfig("", identity[ModuleID]) - - protected implicit def autoConfig - (artifact: GroupArtifactID) - (implicit rev: ArtifactRevision, config: ArtifactConfig): ModuleID = - { - val ArtifactConfig(confs, fn) = config - fn( - if (confs == "") artifact % rev.revision - else artifact % rev.revision % config.confs - ) - } -} - -trait TestLibraries extends LowPriorityLibraries { - self: DefaultProject => - - private implicit val testDepConfig = ArtifactConfig("test", _.withSources) - val specs: ModuleID = "org.scala-tools.testing" %% "specs" - val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" -} - -trait Libraries extends Repositories with TestLibraries { - self: DefaultProject => - - import ArtifactConfig.defaultArtifactConfig - - // val ant: ModuleID = "org.apache.ant" % "ant" - // val asmAll: ModuleID = "asm" % "asm-all" withSources() - // val commonsVFS: ModuleID = "org.apache.commons" % "commons-vfs-project" - // val easymock: ModuleID = "org.easymock" % "easymock" - // val guava: ModuleID = "com.google.guava" % "guava" - // val ivy: ModuleID = "org.apache.ivy" % "ivy" - // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() - // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" - // val jmock: ModuleID = "org.jmock" % "jmock" - // val jodaTime: ModuleID = "joda-time" % "joda-time" - // val liftJson: ModuleID = "net.liftweb" %% "lift-json" - // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" - // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() - // val scalaImproving: ModuleID = "org.improving" %% "scala-improving" - // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" - // val scalariform: ModuleID = "org.scalariform" %% "scalariform" - // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() - // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() - // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() -} diff --git a/src/template/Plugins.scala b/src/template/Plugins.scala deleted file mode 100644 index ea05fabe5..000000000 --- a/src/template/Plugins.scala +++ /dev/null @@ -1,7 +0,0 @@ -import sbt._ - -class Plugins(info: ProjectInfo) extends PluginDefinition(info) { - // def aquteRepo = "aQute Maven Repository" at "http://www.aqute.biz/repo" - // lazy val aquteModuleConfig = ModuleConfiguration("biz.aQute", aquteRepo) - // val bnd4sbt = "com.weiglewilczek.bnd4sbt" % "bnd4sbt" % "latest.release" -} diff --git a/src/template/Repositories.scala b/src/template/Repositories.scala deleted file mode 100644 index c7f988f33..000000000 --- a/src/template/Repositories.scala +++ /dev/null @@ -1,23 +0,0 @@ -import sbt._ - -trait Repositories extends DefaultProject { - // self: DefaultProject => - - val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository" - val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local" - val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public" - val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" - val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" - - // -Dscala.local=2.9.0.local=/scala/trunk/build/pack - override def localScala = System.getProperty("scala.local") match { - case null => super.localScala - case str => - val (name, path) = str indexOf '=' match { - case -1 => ("local", str) - case idx => (str take idx toString, str drop idx + 1 toString) - } - log.info("Found scala.local setting '" + name + "' at: " + path) - List(defineScala(name, new java.io.File(path))) - } -} diff --git a/src/test/scala/ExampleSpec.scala b/src/test/scala/ExampleSpec.scala deleted file mode 100644 index 2b2ee3d61..000000000 --- a/src/test/scala/ExampleSpec.scala +++ /dev/null @@ -1,19 +0,0 @@ -package example - -import org.specs._ - -class ExampleSpec extends Specification { - "An example project" should { - "compare Rationals" >> { - Rational(5) mustEqual Rational(5, 1) - Rational(1, 10) mustEqual Rational(2, 20) - } - "add Rationals" >> { - (Rational(1, 3) + Rational(5, 15)) mustEqual Rational(4, 6) - } - "mix and match Rationals and Ints" >> { - (Rational(1, 2) + 1) mustEqual Rational(3, 2) - (1 + Rational(1, 2)) mustEqual Rational(3, 2) - } - } -} diff --git a/src/test/scala/TemplateSpec.scala b/src/test/scala/TemplateSpec.scala deleted file mode 100644 index 7952ab21f..000000000 --- a/src/test/scala/TemplateSpec.scala +++ /dev/null @@ -1,11 +0,0 @@ -package template - -import org.specs._ - -class TemplateSpec extends Specification { - "A template project" should { - "not violate universal realities" >> { - 1 mustEqual 1 - } - } -} diff --git a/todo/artifacts.txt b/todo/artifacts.txt deleted file mode 100644 index d1fcbaa9f..000000000 --- a/todo/artifacts.txt +++ /dev/null @@ -1,111 +0,0 @@ -val Fastutil = "fastutil" % "fastutil" % "5.1.5" -val activemqCore = "org.apache.activemq" % "activemq-core" % "5.3.2" % "compile" withSources -val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "0.9.1" -val android = "org.scala-tools.sbt" % "sbt-android-plugin" % "0.5.0" -val bcel = "org.apache.bcel" % "bcel" % "5.2" -val bnd4sbt = "com.weiglewilczek.bnd4sbt" % "bnd4sbt" % "1.0.0.RC4" -val cglib = "cglib" % "cglib" % "2.1_3" -val cglibnodep = "cglib" % "cglib-nodep" % "2.1_3" -val commons = "commons-io" % "commons-io" % "1.4" withSources() extra("docUrl" -> "http://commons.apache.org/io/api-1.4/") -val commonsFileupload = "commons-fileupload" % "commons-fileupload" % "1.2.1" % "compile" -val commonsHttpClient = "commons-httpclient" % "commons-httpclient" % "3.1" % "compile" //ApacheV2 -val commonsIo = "commons-io" % "commons-io" % "1.4" -val commons_codec = "commons-codec" % "commons-codec" % "1.4" % "compile" //ApacheV2 -val commons_coll = "commons-collections" % "commons-collections" % "3.2.1" % "test" //ApacheV2 -val commons_logging = "commons-logging" % "commons-logging" % "1.1.1" % "compile" -val commons_pool = "commons-pool" % "commons-pool" % "1.5.4" % "compile" //ApacheV2 -val core = "org.processing" % "core" % "1.1" -val defaultProject = "com.twitter" % "standard-project" % "0.9.8" -val easymockclass = "org.easymock" % "easymockclassextension" % "2.4" -val eclipse = "de.element34" % "sbt-eclipsify" % "0.5.0" -val extract = "org.scala-tools.sbt" % "installer-plugin" % "0.3.0" -val google_coll = "com.google.collections" % "google-collections" % "1.0" % "compile" //ApacheV2 -val gpgPlugin = "com.rossabaker" % "sbt-gpg-plugin" % "0.1.1" -val gstreamerJava = "com.googlecode.gstreamer-java" % "gstreamer-java" % "1.4" -val gsvideo = gsvideoName % gsvideoName % gsvideoVersion % (gsvideoConf + "->default") from(gsvideoURL) -val guicey = "org.guiceyfruit" % "guice-all" % "2.0" % "compile" -val gwtAsyncGen = "com.samskivert" % "gwt-asyncgen" % "1.0" % "system" -val gwtDev = "com.google.gwt" % "gwt-dev" % "2.1.0" % "system" -val gwtServlet = "com.google.gwt" % "gwt-servlet" % "2.1.0" % "system" -val gwtUser = "com.google.gwt" % "gwt-user" % "2.1.0" -val gwtUtils = "com.threerings" % "gwt-utils" % "1.2-SNAPSHOT" -val httpclient = "org.apache.httpcomponents" % "httpclient" % "4.0.1" -val idea = "com.github.mpeltonen" % "sbt-idea-plugin" % "0.2-SNAPSHOT" -val ideaPlugin = groupId % "sbt-idea-plugin" % testedVersion -val ivy = "org.apache.ivy" % "ivy" % "2.1.0" % "compile;runtime;test" -val jackson = "org.codehaus.jackson" % "jackson-mapper-asl" % JACKSON_VERSION % "compile" //ApacheV2 -val jacksonCore = "org.codehaus.jackson" % "jackson-core-asl" % jacksonVersion withSources() -val jacksonMapper = "org.codehaus.jackson" % "jackson-mapper-asl" % jacksonVersion withSources () -val jackson_core = "org.codehaus.jackson" % "jackson-core-asl" % JACKSON_VERSION % "compile" //ApacheV2 -val jcip = "net.jcip" % "jcip-annotations" % "1.0" % "provided->default" -val configgy = "net.lag" % "configgy" % "2.0.2-nologgy" % "compile" //ApacheV2 -val easymock = "org.easymock" % "easymock" % "2.5.1" -val guava = "com.google.guava" % "guava" "latest.release" -val jetty = "org.mortbay.jetty" % "jetty" % "6.1.25" -val jmock = "org.jmock" % "jmock" % "2.4.0" -val jodaTime = "joda-time" % "joda-time" % "1.6" -val jsengine = "javax.script" % "js-engine" % "1.0" -val jsr166x = "jsr166x" % "jsr166x" % "1.0" % "compile" //CC Public Domain -val jsr250 = "javax.annotation" % "jsr250-api" % "1.0" % "compile" //CDDL v1 -val jsr311 = "javax.ws.rs" % "jsr311-api" % "1.1" % "compile" //CDDL v1 -val jta = "javax.transaction" % "jta" % "1.1" % "provided" -val junit = "junit" % "junit" % "4.5" -val junit = "junit" % "junit" % "4.8.2" % "test" -val junitInterface = "com.novocode" % "junit-interface" % "0.4" % "test" -val logback = "ch.qos.logback" % "logback-classic" % LOGBACK_VERSION % "compile" //LGPL 2.1 -val markdown = "org.markdownj" % "markdownj" % "0.3.0-1.0.2b4" % "runtime" -val maven = "org.apache.maven" % "maven-ant-tasks" % "2.1.0" % "compile;runtime;test" -val miglayout = "com.miglayout" % "miglayout" % "3.7.1" -val mockito = "org.mockito" % "mockito-all" % "1.8.0" % "test" -val multiverse = "org.multiverse" % "multiverse-alpha" % MULTIVERSE_VERSION % "compile" intransitive //ApacheV2 -val naggati = "net.lag" % "naggati" % "0.7.2" -val netty = "org.jboss.netty" % "netty" % "3.2.3.Final" -val objenesis = "org.objenesis" % "objenesis" % "1.0" -val objenesis = "org.objenesis" % "objenesis" % "1.2" % "compile" -val opengl = "org.processing" % "opengl" % processingVersion.value -val ostrich = "com.twitter" % "ostrich" % "2.3.4" -val paranamer = "com.thoughtworks.paranamer" % "paranamer" % "2.3" withSources() -val posterous = "net.databinder" % "posterous-sbt" % "0.1.4" -val proguard = "org.scala-tools.sbt" % "sbt-proguard-plugin" % "0.0.5" -val proguardJar = "net.sf.proguard" % "proguard" % "4.4" % "tools->default" -val protobuf = "com.google.protobuf" % "protobuf-java" % "2.3.0" % "compile" //New BSD -val rsync = "com.codahale" % "rsync-sbt" % "0.1.1" -val sbinary = "sbinary" % "sbinary" % "2.8.0-0.3.1" % "compile" //MIT -val sbtIdea = "com.github.mpeltonen" % "sbt-idea-plugin" % "0.1.0" -val scalariform = "org.scalariform" % "scalariform_2.8.0" % "0.0.7"%"compile;runtime;test" -val scalate = "org.fusesource.scalate" % "scalate-core" % "1.3-SNAPSHOT" -val scriptapi = "javax.script" % "script-api" % "1.0" -val scripted = "org.scala-tools.sbt" % "scripted" % "0.7.4" -val scriptedTestUtils = groupId % "sbt-idea-tests_2.7.7" % testedVersion -val scriptjs = "javax.script" % "script-js" % "1.0" -val servlet = "javax.servlet" % "servlet-api" % "2.5" withSources -val servletApi = "org.mortbay.jetty" % "servlet-api" % "2.5-20081211" % "provided" -val sfl4japi = "org.slf4j" % "slf4j-api" % slf4jVersion % "compile" -val simplespec = "com.codahale" %% "simplespec" % "0.2.0" % "test" withSources () -val sjson = "sjson.json" % "sjson" % "0.8-2.8.0" % "compile" //ApacheV2 -val spdeSbt = "us.technically.spde" % "spde-sbt-plugin" % "0.4.2" -val spde_core = "org.processing" % "core-android" % "1.1" -val spde_sbt = "us.technically.spde" % "spde-sbt-plugin" % "0.4.2" -val spde_video = "us.technically.spde" %% "spde-video" % spdeVersion.value -val squeryl = "org.squeryl" % "squeryl_2.8.0" % "0.9.4-RC3" -val thrift = "thrift" % "libthrift" % "0.5.0" -val util = "com.twitter" % "util" % "1.4.13" -val uuid = "com.eaio" % "uuid" % "3.2" % "compile" //MIT license -val vscaladoc = "org.scala-tools" % "vscaladoc" % "1.1-md-3" -val wikitext = "org.eclipse.mylyn.wikitext" % "wikitext" % "0.9.4.I20090220-1600-e3x" -val wikitextile = "org.eclipse.mylyn.wikitext" % "wikitext.textile" % "0.9.4.I20090220-1600-e3x" -val xrayspecs = "com.twitter" % "xrayspecs" % "1.0.7" - -dispatch-http -dispatch-futures -dispatch-mime -dispatch-json -dispatch-http-json -dispatch-lift-json -dispatch-oauth -dispatch-meetup -dispatch-couch -dispatch-twitter -dispatch-times -dispatch-s3 -dispatch-google From c34a55af5a2f1a3d99914900598e65fdf4743cce Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 10:13:55 -0700 Subject: [PATCH 025/483] Finishing the job. --- README | 2 +- sbt-runner => sbt | 38 +++++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 14 deletions(-) rename sbt-runner => sbt (73%) diff --git a/README b/README index 3adaf4e9c..840cf97cd 100644 --- a/README +++ b/README @@ -1,2 +1,2 @@ -This is a more capable runner for sbt, as well as a template sbt project. +This is a script for running sbt 0.10, and a template sbt project. diff --git a/sbt-runner b/sbt similarity index 73% rename from sbt-runner rename to sbt index ec13fb472..dac479927 100755 --- a/sbt-runner +++ b/sbt @@ -1,5 +1,9 @@ #!/usr/bin/env bash # +# A more capable sbt runner, coincidentally called sbt. +# Author: Paul Phillips + +set -e declare -r script_name="$(basename $BASH_SOURCE)" declare -r sbt_jar=/soft/inst/sbt/xsbt-launch.jar @@ -9,7 +13,7 @@ declare -r latest_28="2.8.1" declare -r latest_29="2.9.0-1" declare -r latest_210="2.10.0-SNAPSHOT" -# get completion if present +# pick up completion if present [[ -f .sbt_completion.sh ]] && source .sbt_completion.sh usage () { @@ -17,19 +21,20 @@ usage () { Usage: $script_name [options] -help prints this message - -boot path to shared sbt boot directory (default: none) - -debug set sbt log level to debug - -global path to directory containing global settings and plugins (default: ~/.sbt) - -ivy path to local Ivy repository (default: ~/.ivy2) -nocolor disable ANSI color codes - + -debug set sbt log level to debug -28 set scala version to $latest_28 -29 set scala version to $latest_29 -210 set scala version to $latest_210 - -Dkey=val pass -Dkey=val directly to the jvm -J-X pass option -X directly to the jvm + # Options which require a path: + -ivy local Ivy repository (default: ~/.ivy2) + -sbtdir directory containing global settings and plugins (default: ~/.sbt) + -shared shared sbt boot directory (default: nones, no sharing) + -local local scala installation to set as scala home + The contents of the following environment variables, if any, will be passed to the jvm. Later variables take priority over earlier ones, and command line options (-D/-J) take priority over all of them. @@ -37,7 +42,7 @@ command line options (-D/-J) take priority over all of them. JAVA_OPTS # defaults: $default_java_opts SBT_OPTS # defaults: $default_sbt_opts -If an environment variable is set, its defaults are not given. +If an environment variable is set, the defaults are not given. EOM } @@ -62,9 +67,10 @@ addSbt () { while [ $# -gt 0 ]; do case "$1" in -help) usage; exit 1 ;; - -global) addJava "-Dsbt.global.base=$2"; shift 2 ;; - -boot) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; + -ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;; + -shared) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; + -global) addJava "-Dsbt.global.base=$2"; shift 2 ;; -nocolors) addJava "-Dsbt.log.noformat=true"; shift ;; -28) addJava "-Dsbt.scala.version=$latest_28"; shift ;; -29) addJava "-Dsbt.scala.version=$latest_29"; shift ;; @@ -72,7 +78,8 @@ while [ $# -gt 0 ]; do -D*) addJava "$1"; shift ;; -J*) addJava "${1:2}"; shift ;; - -debug) addSbt "set logLevel := Level.Debug"; shift ;; + -debug) debug=1 ; addSbt "set logLevel := Level.Debug"; shift ;; + -local) addSbt "set scalaHome := Some(file(\"/path/to/scala\"))"; shift ;; *) args=("${args[@]}" "$1") ; shift ;; esac @@ -81,9 +88,14 @@ done # reset "$@" to the residual args set -- "${args[@]}" +execRunner () { + (( debug )) && echo "[command line] $@" + "$@" +} + # run sbt -java \ - $JAVA_OPTS \ +execRunner java \ + ${JAVA_OPTS:-$default_java_opts} \ ${SBT_OPTS:-$default_sbt_opts} \ ${java_args[@]} \ -jar "$sbt_jar" \ From 01b1daf0b9815f5c3ec6464b15e0b146f544f497 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 10:17:16 -0700 Subject: [PATCH 026/483] Main. --- sbt | 4 ++-- src/main/{ => scala}/Main.scala | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename src/main/{ => scala}/Main.scala (100%) diff --git a/sbt b/sbt index dac479927..b0124b8aa 100755 --- a/sbt +++ b/sbt @@ -78,8 +78,8 @@ while [ $# -gt 0 ]; do -D*) addJava "$1"; shift ;; -J*) addJava "${1:2}"; shift ;; - -debug) debug=1 ; addSbt "set logLevel := Level.Debug"; shift ;; - -local) addSbt "set scalaHome := Some(file(\"/path/to/scala\"))"; shift ;; + -debug) addSbt "set logLevel := Level.Debug"; debug=1; shift ;; + -local) addSbt "set scalaHome := Some(file(\"$2\"))"; shift 2 ;; *) args=("${args[@]}" "$1") ; shift ;; esac diff --git a/src/main/Main.scala b/src/main/scala/Main.scala similarity index 100% rename from src/main/Main.scala rename to src/main/scala/Main.scala From 1b681960f438760a9b37db2286370e4f0edfa981 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 10:35:53 -0700 Subject: [PATCH 027/483] downloading launcher --- .gitignore | 1 + lib/README | 1 + sbt | 66 ++++++++++++++++++++++++++++++++++++------------------ 3 files changed, 46 insertions(+), 22 deletions(-) create mode 100644 lib/README diff --git a/.gitignore b/.gitignore index 721cc4ea1..01c53bb64 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ target lib_managed src_managed /ext +lib/sbt-launch.jar \ No newline at end of file diff --git a/lib/README b/lib/README new file mode 100644 index 000000000..46e4a96f1 --- /dev/null +++ b/lib/README @@ -0,0 +1 @@ +sbt-launch.jar to be downloaded into here. \ No newline at end of file diff --git a/sbt b/sbt index b0124b8aa..12851eb56 100755 --- a/sbt +++ b/sbt @@ -5,44 +5,66 @@ set -e +# todo - make this dynamic +launch_base=http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch +launch_url=$launch_base/0.10.1/sbt-launch.jar + +declare -r script_dir=$(cd $(dirname $BASH_SOURCE) ; pwd) declare -r script_name="$(basename $BASH_SOURCE)" -declare -r sbt_jar=/soft/inst/sbt/xsbt-launch.jar +declare -r sbt_jar="$script_dir/lib/sbt-launch.jar" declare -r default_java_opts="-Dfile.encoding=UTF8" declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" declare -r latest_28="2.8.1" declare -r latest_29="2.9.0-1" declare -r latest_210="2.10.0-SNAPSHOT" -# pick up completion if present +# pick up completion if present; todo [[ -f .sbt_completion.sh ]] && source .sbt_completion.sh +# no jar? download it. +[[ -f "$sbt_jar" ]] || { + echo "Downloading sbt launcher, this should only take a moment..." + + if which curl >/dev/null; then + curl "$launch_url" --output "$sbt_jar" + elif which wget >/dev/null; then + wget "$launch_url" > "$sbt_jar" + fi +} + +# still no jar? uh-oh. +[[ -f "$sbt_jar" ]] || { + echo "Download failed. Obtain the jar manually and place it at $sbt_jar" + exit 1 +} + usage () { cat < location of global settings and plugins (default: ~/.sbt) + -ivy local Ivy repository (default: ~/.ivy2) + -shared shared sbt boot directory (default: none, no sharing) - # Options which require a path: - -ivy local Ivy repository (default: ~/.ivy2) - -sbtdir directory containing global settings and plugins (default: ~/.sbt) - -shared shared sbt boot directory (default: nones, no sharing) - -local local scala installation to set as scala home + # setting scala version + -28 set scala version to $latest_28 + -29 set scala version to $latest_29 + -210 set scala version to $latest_210 + -local set scala version to local installation at path -The contents of the following environment variables, if any, will be -passed to the jvm. Later variables take priority over earlier ones, and -command line options (-D/-J) take priority over all of them. + # passing options to jvm + JAVA_OPTS environment variable # default: "$default_java_opts" + SBT_OPTS environment variable # default: "$default_sbt_opts" + -Dkey=val pass -Dkey=val directly to the jvm + -J-X pass option -X directly to the jvm (-J is stripped) - JAVA_OPTS # defaults: $default_java_opts - SBT_OPTS # defaults: $default_sbt_opts - -If an environment variable is set, the defaults are not given. +The defaults list for JAVA_OPTS and SBT_OPTS are only given if the +corresponding variable is unset. In the case of a duplicated option, +SBT_OPTS takes precedence over JAVA_OPTS, and command line options +take precedence over both. EOM } From 0e0dded42fa2c1350bb93a6bee78648fe0bef2b9 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 10:55:33 -0700 Subject: [PATCH 028/483] Quoting arguments. --- sbt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sbt b/sbt index 12851eb56..cf4152220 100755 --- a/sbt +++ b/sbt @@ -111,7 +111,18 @@ done set -- "${args[@]}" execRunner () { - (( debug )) && echo "[command line] $@" + # print the arguments one to a line, quoting any containing spaces + (( debug )) && echo "# Executing command line:" && { + for arg; do + if echo "$arg" | grep -q ' '; then + printf "\"%s\"\n" "$arg" + else + printf "%s\n" "$arg" + fi + done + echo "" + } + "$@" } From f4290b8d0445c6c0f9a788828710714e8b48af39 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 10:57:18 -0700 Subject: [PATCH 029/483] Markdown. --- README | 2 -- README.md | 29 +++++++++++++++++++++++++++++ lib/README | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index 840cf97cd..000000000 --- a/README +++ /dev/null @@ -1,2 +0,0 @@ -This is a script for running sbt 0.10, and a template sbt project. - diff --git a/README.md b/README.md new file mode 100644 index 000000000..bafdfc263 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +An alternative script for running [[sbt 0.10|https://github.com/harrah/xsbt]]. + + ./sbt -help + +Usage: sbt [options] + + -help prints this message + -nocolor disable ANSI color codes + -debug set sbt log level to debug + -sbtdir location of global settings and plugins (default: ~/.sbt) + -ivy local Ivy repository (default: ~/.ivy2) + -shared shared sbt boot directory (default: none, no sharing) + + # setting scala version + -28 set scala version to 2.8.1 + -29 set scala version to 2.9.0-1 + -210 set scala version to 2.10.0-SNAPSHOT + -local set scala version to local installation at path + + # passing options to jvm + JAVA_OPTS environment variable # default: "-Dfile.encoding=UTF8" + SBT_OPTS environment variable # default: "-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" + -Dkey=val pass -Dkey=val directly to the jvm + -J-X pass option -X directly to the jvm (-J is stripped) + +The defaults list for JAVA_OPTS and SBT_OPTS are only given if the +corresponding variable is unset. In the case of a duplicated option, +SBT_OPTS takes precedence over JAVA_OPTS, and command line options +take precedence over both. diff --git a/lib/README b/lib/README index 46e4a96f1..6e3f9b576 100644 --- a/lib/README +++ b/lib/README @@ -1 +1 @@ -sbt-launch.jar to be downloaded into here. \ No newline at end of file +sbt-launch.jar is downloaded into here. From b46a5fa4b8cfb92e6d9e6b47b927515a2d537869 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 10:59:47 -0700 Subject: [PATCH 030/483] README --- README.md | 9 ++++++++- sbt | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bafdfc263..642afd01a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ +sbt: the rebel cut +================== + An alternative script for running [[sbt 0.10|https://github.com/harrah/xsbt]]. +There's also a template project sbt coming together, but it's unfinished. +However the runner is quite useful already. + ./sbt -help @@ -23,7 +29,8 @@ Usage: sbt [options] -Dkey=val pass -Dkey=val directly to the jvm -J-X pass option -X directly to the jvm (-J is stripped) -The defaults list for JAVA_OPTS and SBT_OPTS are only given if the +The defaults given for JAVA_OPTS and SBT_OPTS are only used if the corresponding variable is unset. In the case of a duplicated option, SBT_OPTS takes precedence over JAVA_OPTS, and command line options take precedence over both. + diff --git a/sbt b/sbt index cf4152220..ae5726c45 100755 --- a/sbt +++ b/sbt @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# A more capable sbt runner, coincidentally called sbt. +# A more capable sbt runner, coincidentally also called sbt. # Author: Paul Phillips set -e @@ -61,7 +61,7 @@ Usage: $script_name [options] -Dkey=val pass -Dkey=val directly to the jvm -J-X pass option -X directly to the jvm (-J is stripped) -The defaults list for JAVA_OPTS and SBT_OPTS are only given if the +The defaults given for JAVA_OPTS and SBT_OPTS are only used if the corresponding variable is unset. In the case of a duplicated option, SBT_OPTS takes precedence over JAVA_OPTS, and command line options take precedence over both. From b479a586d557ccb8bc804fd92e894af80c594425 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 11:04:39 -0700 Subject: [PATCH 031/483] Can't write markdown. --- README.md | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 642afd01a..bd80ed9db 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,35 @@ sbt: the rebel cut ================== -An alternative script for running [[sbt 0.10|https://github.com/harrah/xsbt]]. +An alternative script for running [sbt 0.10](https://github.com/harrah/xsbt). There's also a template project sbt coming together, but it's unfinished. However the runner is quite useful already. - ./sbt -help -Usage: sbt [options] + Usage: sbt [options] - -help prints this message - -nocolor disable ANSI color codes - -debug set sbt log level to debug - -sbtdir location of global settings and plugins (default: ~/.sbt) - -ivy local Ivy repository (default: ~/.ivy2) - -shared shared sbt boot directory (default: none, no sharing) + -help prints this message + -nocolor disable ANSI color codes + -debug set sbt log level to debug + -sbtdir location of global settings and plugins (default: ~/.sbt) + -ivy local Ivy repository (default: ~/.ivy2) + -shared shared sbt boot directory (default: none, no sharing) - # setting scala version - -28 set scala version to 2.8.1 - -29 set scala version to 2.9.0-1 - -210 set scala version to 2.10.0-SNAPSHOT - -local set scala version to local installation at path + # setting scala version + -28 set scala version to 2.8.1 + -29 set scala version to 2.9.0-1 + -210 set scala version to 2.10.0-SNAPSHOT + -local set scala version to local installation at path - # passing options to jvm - JAVA_OPTS environment variable # default: "-Dfile.encoding=UTF8" - SBT_OPTS environment variable # default: "-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" - -Dkey=val pass -Dkey=val directly to the jvm - -J-X pass option -X directly to the jvm (-J is stripped) + # passing options to jvm + JAVA_OPTS environment variable # default: "-Dfile.encoding=UTF8" + SBT_OPTS environment variable # default: "-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" + -Dkey=val pass -Dkey=val directly to the jvm + -J-X pass option -X directly to the jvm (-J is stripped) -The defaults given for JAVA_OPTS and SBT_OPTS are only used if the -corresponding variable is unset. In the case of a duplicated option, -SBT_OPTS takes precedence over JAVA_OPTS, and command line options -take precedence over both. + The defaults given for JAVA_OPTS and SBT_OPTS are only used if the + corresponding variable is unset. In the case of a duplicated option, + SBT_OPTS takes precedence over JAVA_OPTS, and command line options + take precedence over both. From 7c65e39d281298484f6ca5ffaf85ae703cafb3d3 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 11:17:28 -0700 Subject: [PATCH 032/483] more me to read. --- README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bd80ed9db..49385c435 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,41 @@ An alternative script for running [sbt 0.10](https://github.com/harrah/xsbt). There's also a template project sbt coming together, but it's unfinished. However the runner is quite useful already. - ./sbt -help +Here's a sample first run, which uses a shared boot directory and a local scala. + + % ./sbt -shared /tmp/bippy -local /scala/inst/3 run + Downloading sbt launcher, this should only take a moment... + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 100 915k 100 915k 0 0 339k 0 0:00:02 0:00:02 --:--:-- 354k + [info] Set current project to project-name-here (in build file:/repo/sbt-template/) + [info] Running template.Main + Skeleton main, reporting for duty on version 2.10.0.r25487-b20110811131227 + [success] Total time: 0 s, completed Aug 14, 2011 11:12:58 AM + +Adding -debug to the same command line reveals the command line arguments: + + % ./sbt -shared /tmp/bippy -local /scala/inst/3 run + # Executing command line: + java + -Xss2m + -Xms256M + -Xmx1536M + -XX:MaxPermSize=256M + -XX:+CMSClassUnloadingEnabled + -XX:MaxPermSize=512m + -Xmx2g + -Xss2m + -Dsbt.boot.directory=/tmp/bippy + -jar + /repo/sbt-template/lib/sbt-launch.jar + "set logLevel := Level.Debug" + "set scalaHome := Some(file("/scala/inst/3"))" + run + +Current -help output: + + % ./sbt -help Usage: sbt [options] From d2477cbcdc132910b9e706fdab57a5ab3227be85 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 11:37:35 -0700 Subject: [PATCH 033/483] symlink issues. --- sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbt b/sbt index ae5726c45..24b88a546 100755 --- a/sbt +++ b/sbt @@ -9,7 +9,7 @@ set -e launch_base=http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch launch_url=$launch_base/0.10.1/sbt-launch.jar -declare -r script_dir=$(cd $(dirname $BASH_SOURCE) ; pwd) +declare -r script_dir="$(dirname $(readlink $BASH_SOURCE))" declare -r script_name="$(basename $BASH_SOURCE)" declare -r sbt_jar="$script_dir/lib/sbt-launch.jar" declare -r default_java_opts="-Dfile.encoding=UTF8" From 8ff3e12a0e5060ebb988f2bb8c63cda46e810400 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 12:29:10 -0700 Subject: [PATCH 034/483] More path/symlink issues, a few bugs which had crept in in the hours since this project was founded, added an -sbtjar option. --- .gitignore | 2 +- {lib => .lib}/README | 0 README.md | 2 +- sbt | 67 ++++++++++++++++++++++++++++---------------- 4 files changed, 45 insertions(+), 26 deletions(-) rename {lib => .lib}/README (100%) diff --git a/.gitignore b/.gitignore index 01c53bb64..2b251dfd9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ target lib_managed src_managed /ext -lib/sbt-launch.jar \ No newline at end of file +.lib/sbt-launch.jar \ No newline at end of file diff --git a/lib/README b/.lib/README similarity index 100% rename from lib/README rename to .lib/README diff --git a/README.md b/README.md index 49385c435..c94af3f21 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Current -help output: -help prints this message -nocolor disable ANSI color codes -debug set sbt log level to debug + -sbtjar location of sbt launcher (default: ./.lib/sbt-launch.jar) -sbtdir location of global settings and plugins (default: ~/.sbt) -ivy local Ivy repository (default: ~/.ivy2) -shared shared sbt boot directory (default: none, no sharing) @@ -66,4 +67,3 @@ Current -help output: corresponding variable is unset. In the case of a duplicated option, SBT_OPTS takes precedence over JAVA_OPTS, and command line options take precedence over both. - diff --git a/sbt b/sbt index 24b88a546..fe06d5d84 100755 --- a/sbt +++ b/sbt @@ -9,35 +9,30 @@ set -e launch_base=http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch launch_url=$launch_base/0.10.1/sbt-launch.jar -declare -r script_dir="$(dirname $(readlink $BASH_SOURCE))" -declare -r script_name="$(basename $BASH_SOURCE)" -declare -r sbt_jar="$script_dir/lib/sbt-launch.jar" +# this seems to cover the bases on OSX, and someone will +# have to tell me about the others. +get_script_path () { + local path="$1" + [[ -L "$path" ]] || { echo "$path" ; return; } + + local target=$(readlink "$path") + if [[ "${target:0:1}" == "/" ]]; then + echo "$target" + else + echo "$path/$target" + fi +} + +declare -r script_path=$(get_script_path "$BASH_SOURCE") +declare -r script_dir="$(dirname $script_path)" +declare -r script_name="$(basename $script_path)" +declare -r default_sbt_jar="$script_dir/.lib/sbt-launch.jar" declare -r default_java_opts="-Dfile.encoding=UTF8" declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" declare -r latest_28="2.8.1" declare -r latest_29="2.9.0-1" declare -r latest_210="2.10.0-SNAPSHOT" -# pick up completion if present; todo -[[ -f .sbt_completion.sh ]] && source .sbt_completion.sh - -# no jar? download it. -[[ -f "$sbt_jar" ]] || { - echo "Downloading sbt launcher, this should only take a moment..." - - if which curl >/dev/null; then - curl "$launch_url" --output "$sbt_jar" - elif which wget >/dev/null; then - wget "$launch_url" > "$sbt_jar" - fi -} - -# still no jar? uh-oh. -[[ -f "$sbt_jar" ]] || { - echo "Download failed. Obtain the jar manually and place it at $sbt_jar" - exit 1 -} - usage () { cat < location of sbt launcher (default: $default_sbt_jar) -sbtdir location of global settings and plugins (default: ~/.sbt) -ivy local Ivy repository (default: ~/.ivy2) -shared shared sbt boot directory (default: none, no sharing) @@ -79,6 +75,8 @@ EOM declare -a args declare -a java_args declare -a sbt_commands +declare sbt_jar="$default_sbt_jar" + addJava () { java_args=("${java_args[@]}" "$1") } @@ -92,7 +90,7 @@ while [ $# -gt 0 ]; do -ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;; -shared) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; - -global) addJava "-Dsbt.global.base=$2"; shift 2 ;; + -sbtdir) addJava "-Dsbt.global.base=$2"; shift 2 ;; -nocolors) addJava "-Dsbt.log.noformat=true"; shift ;; -28) addJava "-Dsbt.scala.version=$latest_28"; shift ;; -29) addJava "-Dsbt.scala.version=$latest_29"; shift ;; @@ -102,6 +100,7 @@ while [ $# -gt 0 ]; do -J*) addJava "${1:2}"; shift ;; -debug) addSbt "set logLevel := Level.Debug"; debug=1; shift ;; -local) addSbt "set scalaHome := Some(file(\"$2\"))"; shift 2 ;; + -sbtjar) sbt_jar="$2"; shift 2 ;; *) args=("${args[@]}" "$1") ; shift ;; esac @@ -110,6 +109,26 @@ done # reset "$@" to the residual args set -- "${args[@]}" +# pick up completion if present; todo +[[ -f .sbt_completion.sh ]] && source .sbt_completion.sh + +# no jar? download it. +[[ -f "$sbt_jar" ]] || { + echo "Downloading sbt launcher, this should only take a moment..." + + if which curl >/dev/null; then + curl "$launch_url" --output "$sbt_jar" + elif which wget >/dev/null; then + wget "$launch_url" > "$sbt_jar" + fi +} + +# still no jar? uh-oh. +[[ -f "$sbt_jar" ]] || { + echo "Download failed. Obtain the jar manually and place it at $sbt_jar" + exit 1 +} + execRunner () { # print the arguments one to a line, quoting any containing spaces (( debug )) && echo "# Executing command line:" && { From 5175afdf5a3ccd8790db77c313817547101753bf Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 12:54:59 -0700 Subject: [PATCH 035/483] Tweaks based on feedback from mr. sbt himself. --- sbt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sbt b/sbt index fe06d5d84..b26e53156 100755 --- a/sbt +++ b/sbt @@ -67,8 +67,6 @@ EOM # no args - alert them there's stuff in here [[ $# -gt 0 ]] || { echo "Starting $script_name: invoke with -help for other options" - # so it still starts if we injected any sbt commands - set -- "shell" } # pull -J and -D options to give to java. @@ -92,14 +90,14 @@ while [ $# -gt 0 ]; do -shared) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; -sbtdir) addJava "-Dsbt.global.base=$2"; shift 2 ;; -nocolors) addJava "-Dsbt.log.noformat=true"; shift ;; - -28) addJava "-Dsbt.scala.version=$latest_28"; shift ;; - -29) addJava "-Dsbt.scala.version=$latest_29"; shift ;; - -210) addJava "-Dsbt.scala.version=$latest_210"; shift ;; -D*) addJava "$1"; shift ;; -J*) addJava "${1:2}"; shift ;; - -debug) addSbt "set logLevel := Level.Debug"; debug=1; shift ;; - -local) addSbt "set scalaHome := Some(file(\"$2\"))"; shift 2 ;; + -28) addSbt "set scalaVersion := \"$latest_28\""; shift ;; + -29) addSbt "set scalaVersion := \"$latest_29\""; shift ;; + -210) addSbt "set scalaVersion := \"$latest_210\""; shift ;; + -debug) addSbt "set logLevel in Global := Level.Debug"; debug=1; shift ;; + -local) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; -sbtjar) sbt_jar="$2"; shift 2 ;; *) args=("${args[@]}" "$1") ; shift ;; @@ -152,4 +150,5 @@ execRunner java \ ${java_args[@]} \ -jar "$sbt_jar" \ "${sbt_commands[@]}" \ + "iflast shell" \ "$@" From 77d57ab7246894c8eaf817b959d35e05981ec313 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 13:03:19 -0700 Subject: [PATCH 036/483] Added a -v/-verbose option so you can see the command line without having to enter into debug output land. --- sbt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sbt b/sbt index b26e53156..d51c19ee1 100755 --- a/sbt +++ b/sbt @@ -40,6 +40,7 @@ Usage: $script_name [options] -help prints this message -nocolor disable ANSI color codes -debug set sbt log level to debug + -v | -verbose this runner is chattier -sbtjar location of sbt launcher (default: $default_sbt_jar) -sbtdir location of global settings and plugins (default: ~/.sbt) -ivy local Ivy repository (default: ~/.ivy2) @@ -74,6 +75,7 @@ declare -a args declare -a java_args declare -a sbt_commands declare sbt_jar="$default_sbt_jar" +declare verbose=0 addJava () { java_args=("${java_args[@]}" "$1") @@ -98,6 +100,8 @@ while [ $# -gt 0 ]; do -210) addSbt "set scalaVersion := \"$latest_210\""; shift ;; -debug) addSbt "set logLevel in Global := Level.Debug"; debug=1; shift ;; -local) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; + + -v|-verbose) verbose=1 ; shift ;; -sbtjar) sbt_jar="$2"; shift 2 ;; *) args=("${args[@]}" "$1") ; shift ;; @@ -129,7 +133,7 @@ set -- "${args[@]}" execRunner () { # print the arguments one to a line, quoting any containing spaces - (( debug )) && echo "# Executing command line:" && { + (( debug )) || (( verbose )) && echo "# Executing command line:" && { for arg; do if echo "$arg" | grep -q ' '; then printf "\"%s\"\n" "$arg" From bdd7b32b35acfe4dddcd83979c52d3418ac30fe3 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 13:04:37 -0700 Subject: [PATCH 037/483] Oh yeah, ThisBuild. --- sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbt b/sbt index d51c19ee1..e5c821537 100755 --- a/sbt +++ b/sbt @@ -95,9 +95,9 @@ while [ $# -gt 0 ]; do -D*) addJava "$1"; shift ;; -J*) addJava "${1:2}"; shift ;; - -28) addSbt "set scalaVersion := \"$latest_28\""; shift ;; - -29) addSbt "set scalaVersion := \"$latest_29\""; shift ;; - -210) addSbt "set scalaVersion := \"$latest_210\""; shift ;; + -28) addSbt "set scalaVersion in ThisBuild := \"$latest_28\""; shift ;; + -29) addSbt "set scalaVersion in ThisBuild := \"$latest_29\""; shift ;; + -210) addSbt "set scalaVersion in ThisBuild := \"$latest_210\""; shift ;; -debug) addSbt "set logLevel in Global := Level.Debug"; debug=1; shift ;; -local) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; From c7a8a53a0bbcefa45b0dd08be6a5bee5f9977900 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 13:14:51 -0700 Subject: [PATCH 038/483] Minor problem with ThisBuild: everything ceases to work. Tabled it. --- sbt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sbt b/sbt index e5c821537..2973b92a9 100755 --- a/sbt +++ b/sbt @@ -95,11 +95,11 @@ while [ $# -gt 0 ]; do -D*) addJava "$1"; shift ;; -J*) addJava "${1:2}"; shift ;; - -28) addSbt "set scalaVersion in ThisBuild := \"$latest_28\""; shift ;; - -29) addSbt "set scalaVersion in ThisBuild := \"$latest_29\""; shift ;; - -210) addSbt "set scalaVersion in ThisBuild := \"$latest_210\""; shift ;; + -28) addSbt "set scalaVersion := \"$latest_28\""; shift ;; + -29) addSbt "set scalaVersion := \"$latest_29\""; shift ;; + -210) addSbt "set scalaVersion := \"$latest_210\""; shift ;; -debug) addSbt "set logLevel in Global := Level.Debug"; debug=1; shift ;; - -local) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; + -local) addSbt "set scalaHome := Some(file(\"$2\"))"; shift 2 ;; -v|-verbose) verbose=1 ; shift ;; -sbtjar) sbt_jar="$2"; shift 2 ;; From ab64bea2d059e6783ad99fd852146b1548aaf99e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 13:44:38 -0700 Subject: [PATCH 039/483] ThisBuild, reborn as two pluses. --- sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbt b/sbt index 2973b92a9..5eb50f4ee 100755 --- a/sbt +++ b/sbt @@ -95,9 +95,9 @@ while [ $# -gt 0 ]; do -D*) addJava "$1"; shift ;; -J*) addJava "${1:2}"; shift ;; - -28) addSbt "set scalaVersion := \"$latest_28\""; shift ;; - -29) addSbt "set scalaVersion := \"$latest_29\""; shift ;; - -210) addSbt "set scalaVersion := \"$latest_210\""; shift ;; + -28) addSbt "++ $latest_28"; shift ;; + -29) addSbt "++ $latest_29"; shift ;; + -210) addSbt "++ $latest_210"; shift ;; -debug) addSbt "set logLevel in Global := Level.Debug"; debug=1; shift ;; -local) addSbt "set scalaHome := Some(file(\"$2\"))"; shift 2 ;; From 9d98762538c474044b8657ef078c4bcf164f52b0 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 14 Aug 2011 14:11:10 -0700 Subject: [PATCH 040/483] Restored the other ThisBuild. --- sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbt b/sbt index 5eb50f4ee..063a00027 100755 --- a/sbt +++ b/sbt @@ -99,7 +99,7 @@ while [ $# -gt 0 ]; do -29) addSbt "++ $latest_29"; shift ;; -210) addSbt "++ $latest_210"; shift ;; -debug) addSbt "set logLevel in Global := Level.Debug"; debug=1; shift ;; - -local) addSbt "set scalaHome := Some(file(\"$2\"))"; shift 2 ;; + -local) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; -v|-verbose) verbose=1 ; shift ;; -sbtjar) sbt_jar="$2"; shift 2 ;; From c26f6a863ca795e0b67f7c755491aa9e3832409f Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 15 Aug 2011 09:30:57 -0700 Subject: [PATCH 041/483] Fixed nocolors. --- sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbt b/sbt index 063a00027..a38e4bd99 100755 --- a/sbt +++ b/sbt @@ -38,7 +38,7 @@ usage () { Usage: $script_name [options] -help prints this message - -nocolor disable ANSI color codes + -nocolors disable ANSI color codes -debug set sbt log level to debug -v | -verbose this runner is chattier -sbtjar location of sbt launcher (default: $default_sbt_jar) From ce1f6fb7c74558d5237cca1af65838a43d102a9a Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 25 Aug 2011 08:23:24 -0700 Subject: [PATCH 042/483] Added more options. Can choose to use an sbt snapshot with -snapshot. Now by default it refuses to run sbt in a directory with no sign it is an sbt directory; give -create to force it. --- .gitignore | 2 +- sbt | 101 ++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 74 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 2b251dfd9..a13d4dfa0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ target lib_managed src_managed /ext -.lib/sbt-launch.jar \ No newline at end of file +.lib \ No newline at end of file diff --git a/sbt b/sbt index a38e4bd99..7980f3979 100755 --- a/sbt +++ b/sbt @@ -5,9 +5,40 @@ set -e +jar_url () { + local where=$1 # releases or snapshots + local ver=$2 + + echo "http://typesafe.artifactoryonline.com/typesafe/ivy-$where/org.scala-tools.sbt/sbt-launch/$ver/sbt-launch.jar" +} +jar_file () { + echo "$script_dir/.lib/$1/sbt-launch.jar" +} + # todo - make this dynamic -launch_base=http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch -launch_url=$launch_base/0.10.1/sbt-launch.jar +sbt_release_version=0.10.1 +sbt_release_url=$(jar_url releases $sbt_release_version) +sbt_release_jar=$(jar_file $sbt_release_version) +sbt_snapshot_version=0.11.0-20110825-052147 +sbt_snapshot_url=$(jar_url snapshots $sbt_snapshot_version) +sbt_snapshot_jar=$(jar_file $sbt_snapshot_version) + +# Falses made true via command line options +useSnapshot=0 +createProject=0 + +set_sbt_jar () { + if (( $useSnapshot )); then + sbt_version=$sbt_snapshot_version + sbt_url=$sbt_snapshot_url + else + sbt_version=$sbt_release_version + sbt_url=$sbt_release_url + fi + + sbt_jar="$script_dir/.lib/$sbt_version/sbt-launch.jar" +} + # this seems to cover the bases on OSX, and someone will # have to tell me about the others. @@ -26,11 +57,10 @@ get_script_path () { declare -r script_path=$(get_script_path "$BASH_SOURCE") declare -r script_dir="$(dirname $script_path)" declare -r script_name="$(basename $script_path)" -declare -r default_sbt_jar="$script_dir/.lib/sbt-launch.jar" declare -r default_java_opts="-Dfile.encoding=UTF8" declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" -declare -r latest_28="2.8.1" -declare -r latest_29="2.9.0-1" +declare -r latest_28="2.8.2.RC1" +declare -r latest_29="2.9.1.RC4" declare -r latest_210="2.10.0-SNAPSHOT" usage () { @@ -38,43 +68,38 @@ usage () { Usage: $script_name [options] -help prints this message - -nocolors disable ANSI color codes - -debug set sbt log level to debug -v | -verbose this runner is chattier - -sbtjar location of sbt launcher (default: $default_sbt_jar) + -debug set sbt log level to debug + -create start sbt even in a directory with no project + -sbtjar location of sbt launcher (default: $(jar_file '')) -sbtdir location of global settings and plugins (default: ~/.sbt) -ivy local Ivy repository (default: ~/.ivy2) -shared shared sbt boot directory (default: none, no sharing) - # setting scala version + # setting scala and sbt versions -28 set scala version to $latest_28 -29 set scala version to $latest_29 -210 set scala version to $latest_210 -local set scala version to local installation at path + -snapshot use a snapshot of sbt (otherwise, latest released version) - # passing options to jvm - JAVA_OPTS environment variable # default: "$default_java_opts" - SBT_OPTS environment variable # default: "$default_sbt_opts" + # jvm options and output control + JAVA_OPTS environment variable, if unset uses "$default_java_opts" + SBT_OPTS environment variable, if unset uses "$default_sbt_opts" -Dkey=val pass -Dkey=val directly to the jvm -J-X pass option -X directly to the jvm (-J is stripped) + -nocolors disable ANSI color codes -The defaults given for JAVA_OPTS and SBT_OPTS are only used if the -corresponding variable is unset. In the case of a duplicated option, -SBT_OPTS takes precedence over JAVA_OPTS, and command line options -take precedence over both. +In the case of a duplicated option, SBT_OPTS takes precedence over +JAVA_OPTS, and command line options take precedence over both. EOM } -# no args - alert them there's stuff in here -[[ $# -gt 0 ]] || { - echo "Starting $script_name: invoke with -help for other options" -} - # pull -J and -D options to give to java. declare -a args declare -a java_args declare -a sbt_commands -declare sbt_jar="$default_sbt_jar" +declare sbt_jar= declare verbose=0 addJava () { @@ -91,7 +116,9 @@ while [ $# -gt 0 ]; do -ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;; -shared) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; -sbtdir) addJava "-Dsbt.global.base=$2"; shift 2 ;; + -snapshot) useSnapshot=1; shift ;; -nocolors) addJava "-Dsbt.log.noformat=true"; shift ;; + -create) createProject=1; shift ;; -D*) addJava "$1"; shift ;; -J*) addJava "${1:2}"; shift ;; @@ -111,18 +138,36 @@ done # reset "$@" to the residual args set -- "${args[@]}" +# verify this is an sbt dir or -create was given +[[ -f "build.sbt" ]] || [[ -d "project" ]] || (( $createProject )) || { + cat </dev/null; then - curl "$launch_url" --output "$sbt_jar" - elif which wget >/dev/null; then - wget "$launch_url" > "$sbt_jar" - fi + mkdir -p $(dirname "$sbt_jar") && + if which curl >/dev/null; then + curl --silent "$sbt_url" --output "$sbt_jar" + elif which wget >/dev/null; then + wget --quiet "$sbt_url" > "$sbt_jar" + fi } # still no jar? uh-oh. From 1bd64f238136a79641c85ebf8cc1a582c16a2617 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 25 Aug 2011 08:52:59 -0700 Subject: [PATCH 043/483] Added .sbtopts facility. Put such a file in the sbt root directory and these options will be passed always. Specific handy use is a file with "-snapshot" if the project depends on snapshot sbt. --- sbt | 69 +++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/sbt b/sbt index 7980f3979..5904cf2ee 100755 --- a/sbt +++ b/sbt @@ -59,6 +59,7 @@ declare -r script_dir="$(dirname $script_path)" declare -r script_name="$(basename $script_path)" declare -r default_java_opts="-Dfile.encoding=UTF8" declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" +declare -r sbt_opts_filename=".sbtopts" declare -r latest_28="2.8.2.RC1" declare -r latest_29="2.9.1.RC4" declare -r latest_210="2.10.0-SNAPSHOT" @@ -70,6 +71,7 @@ Usage: $script_name [options] -help prints this message -v | -verbose this runner is chattier -debug set sbt log level to debug + -nocolors disable ANSI color codes -create start sbt even in a directory with no project -sbtjar location of sbt launcher (default: $(jar_file '')) -sbtdir location of global settings and plugins (default: ~/.sbt) @@ -86,12 +88,12 @@ Usage: $script_name [options] # jvm options and output control JAVA_OPTS environment variable, if unset uses "$default_java_opts" SBT_OPTS environment variable, if unset uses "$default_sbt_opts" + .sbtopts file in sbt root directory, if present contents passed to sbt -Dkey=val pass -Dkey=val directly to the jvm -J-X pass option -X directly to the jvm (-J is stripped) - -nocolors disable ANSI color codes -In the case of a duplicated option, SBT_OPTS takes precedence over -JAVA_OPTS, and command line options take precedence over both. +In the case of duplicated or conflicting options, the order above +shows precedence: JAVA_OPTS lowest, command line options highest. EOM } @@ -109,31 +111,45 @@ addSbt () { sbt_commands=("${sbt_commands[@]}" "$1") } -while [ $# -gt 0 ]; do - case "$1" in - -help) usage; exit 1 ;; +process_args () +{ + while [ $# -gt 0 ]; do + case "$1" in + -help) usage; exit 1 ;; - -ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;; - -shared) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; - -sbtdir) addJava "-Dsbt.global.base=$2"; shift 2 ;; - -snapshot) useSnapshot=1; shift ;; - -nocolors) addJava "-Dsbt.log.noformat=true"; shift ;; - -create) createProject=1; shift ;; + -ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;; + -shared) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; + -sbtdir) addJava "-Dsbt.global.base=$2"; shift 2 ;; + -snapshot) useSnapshot=1; shift ;; + -nocolors) addJava "-Dsbt.log.noformat=true"; shift ;; + -create) createProject=1; shift ;; - -D*) addJava "$1"; shift ;; - -J*) addJava "${1:2}"; shift ;; - -28) addSbt "++ $latest_28"; shift ;; - -29) addSbt "++ $latest_29"; shift ;; - -210) addSbt "++ $latest_210"; shift ;; - -debug) addSbt "set logLevel in Global := Level.Debug"; debug=1; shift ;; - -local) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; + -D*) addJava "$1"; shift ;; + -J*) addJava "${1:2}"; shift ;; + -28) addSbt "++ $latest_28"; shift ;; + -29) addSbt "++ $latest_29"; shift ;; + -210) addSbt "++ $latest_210"; shift ;; + -debug) addSbt "set logLevel in Global := Level.Debug"; debug=1; shift ;; + -local) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; - -v|-verbose) verbose=1 ; shift ;; - -sbtjar) sbt_jar="$2"; shift 2 ;; + -v|-verbose) verbose=1 ; shift ;; + -sbtjar) sbt_jar="$2"; shift 2 ;; - *) args=("${args[@]}" "$1") ; shift ;; - esac -done + *) args=("${args[@]}" "$1") ; shift ;; + esac + done +} + +# if .sbtopts exists, prepend its contents +[[ -f "$sbt_opts_filename" ]] && set -- $(cat $sbt_opts_filename) "${@}" + +# no args - alert them there's stuff in here +[[ $# -gt 0 ]] || { + echo "Starting $script_name: invoke with -help for other options" +} + +# process the unified options +process_args "$@" # reset "$@" to the residual args set -- "${args[@]}" @@ -149,11 +165,6 @@ EOM exit 1 } -# no args - alert them there's stuff in here -[[ $# -gt 0 ]] || { - echo "Starting $script_name: invoke with -help for other options" -} - # pick up completion if present; todo [[ -f .sbt_completion.sh ]] && source .sbt_completion.sh From 8149652729f093070c8bff5170ccf81bbdc273fb Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 25 Aug 2011 09:34:14 -0700 Subject: [PATCH 044/483] Updated the documentation. --- README.md | 76 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index c94af3f21..590bb314e 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,14 @@ sbt: the rebel cut ================== -An alternative script for running [sbt 0.10](https://github.com/harrah/xsbt). +An alternative script for running [sbt 0.10+](https://github.com/harrah/xsbt). There's also a template project sbt coming together, but it's unfinished. However the runner is quite useful already. -Here's a sample first run, which uses a shared boot directory and a local scala. +Here's a sample first run, which creates a new project using a snapshot +version of sbt, and runs the sbt "about" command. - % ./sbt -shared /tmp/bippy -local /scala/inst/3 run - Downloading sbt launcher, this should only take a moment... - % Total % Received % Xferd Average Speed Time Time Time Current - Dload Upload Total Spent Left Speed - 100 915k 100 915k 0 0 339k 0 0:00:02 0:00:02 --:--:-- 354k - [info] Set current project to project-name-here (in build file:/repo/sbt-template/) - [info] Running template.Main - Skeleton main, reporting for duty on version 2.10.0.r25487-b20110811131227 - [success] Total time: 0 s, completed Aug 14, 2011 11:12:58 AM - -Adding -debug to the same command line reveals the command line arguments: - - % ./sbt -shared /tmp/bippy -local /scala/inst/3 run + % sbt -debug -snapshot -create about # Executing command line: java -Xss2m @@ -30,12 +19,33 @@ Adding -debug to the same command line reveals the command line arguments: -XX:MaxPermSize=512m -Xmx2g -Xss2m - -Dsbt.boot.directory=/tmp/bippy -jar - /repo/sbt-template/lib/sbt-launch.jar - "set logLevel := Level.Debug" - "set scalaHome := Some(file("/scala/inst/3"))" - run + /r/sbt-extras/.lib/0.11.0-20110825-052147/sbt-launch.jar + "set logLevel in Global := Level.Debug" + "iflast shell" + about + + Getting net.java.dev.jna jna 3.2.3 ... + :: retrieving :: org.scala-tools.sbt#boot-app + confs: [default] + 1 artifacts copied, 0 already retrieved (838kB/15ms) + Getting Scala 2.9.1.RC4 (for sbt)... + :: retrieving :: org.scala-tools.sbt#boot-scala + confs: [default] + 4 artifacts copied, 0 already retrieved (19939kB/97ms) + Getting org.scala-tools.sbt sbt_2.9.1.RC4 0.11.0-20110825-052147 ... + :: retrieving :: org.scala-tools.sbt#boot-app + confs: [default] + 38 artifacts copied, 0 already retrieved (6948kB/71ms) + [info] Set current project to default-06d8dd (in build file:/private/tmp/sbt-project/) + [info] Reapplying settings... + [info] Set current project to default-06d8dd (in build file:/private/tmp/sbt-project/) + [info] This is sbt 0.11.0-20110825-052147 + [info] The current project is {file:/private/tmp/sbt-project/}default-06d8dd + [info] The current project is built against Scala 2.9.1.RC4 + [info] sbt, sbt plugins, and build definitions are using Scala 2.9.1.RC4 + [info] All logging output for this session is available at /var/folders/iO/iOpjflOpHzG8Mr1BL67D6k+++TI/-Tmp-/sbt75419762724938334.log + Current -help output: @@ -44,26 +54,28 @@ Current -help output: Usage: sbt [options] -help prints this message - -nocolor disable ANSI color codes + -v | -verbose this runner is chattier -debug set sbt log level to debug - -sbtjar location of sbt launcher (default: ./.lib/sbt-launch.jar) + -nocolors disable ANSI color codes + -create start sbt even in a directory with no project + -sbtjar location of sbt launcher (default: ./.lib//sbt-launch.jar) -sbtdir location of global settings and plugins (default: ~/.sbt) -ivy local Ivy repository (default: ~/.ivy2) -shared shared sbt boot directory (default: none, no sharing) - # setting scala version - -28 set scala version to 2.8.1 - -29 set scala version to 2.9.0-1 + # setting scala and sbt versions + -28 set scala version to 2.8.2.RC1 + -29 set scala version to 2.9.1.RC4 -210 set scala version to 2.10.0-SNAPSHOT -local set scala version to local installation at path + -snapshot use a snapshot of sbt (otherwise, latest released version) - # passing options to jvm - JAVA_OPTS environment variable # default: "-Dfile.encoding=UTF8" - SBT_OPTS environment variable # default: "-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" + # jvm options and output control + JAVA_OPTS environment variable, if unset uses "-Dfile.encoding=UTF8" + SBT_OPTS environment variable, if unset uses "-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" + .sbtopts file in sbt root directory, if present contents passed to sbt -Dkey=val pass -Dkey=val directly to the jvm -J-X pass option -X directly to the jvm (-J is stripped) - The defaults given for JAVA_OPTS and SBT_OPTS are only used if the - corresponding variable is unset. In the case of a duplicated option, - SBT_OPTS takes precedence over JAVA_OPTS, and command line options - take precedence over both. + In the case of duplicated or conflicting options, the order above + shows precedence: JAVA_OPTS lowest, command line options highest. From c922e084c01b179c7bedb197252a19cbfb384bf2 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 25 Aug 2011 11:51:31 -0700 Subject: [PATCH 045/483] Added support for sbt 0.7 series, and an explicit -sbt-version option. --- sbt | 53 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/sbt b/sbt index 5904cf2ee..d88ce8170 100755 --- a/sbt +++ b/sbt @@ -5,38 +5,41 @@ set -e +# todo - make this dynamic +sbt_release_version=0.10.1 +sbt_snapshot_version=0.11.0-20110825-052147 + +# Falses made true via command line options +useSnapshot=0 +createProject=0 +sbt_version= + jar_url () { local where=$1 # releases or snapshots local ver=$2 - echo "http://typesafe.artifactoryonline.com/typesafe/ivy-$where/org.scala-tools.sbt/sbt-launch/$ver/sbt-launch.jar" + if [[ $ver = 0.7* ]]; then + echo "http://simple-build-tool.googlecode.com/files/sbt-launch-$ver.jar" + else + echo "http://typesafe.artifactoryonline.com/typesafe/ivy-$where/org.scala-tools.sbt/sbt-launch/$ver/sbt-launch.jar" + fi } jar_file () { echo "$script_dir/.lib/$1/sbt-launch.jar" } -# todo - make this dynamic -sbt_release_version=0.10.1 -sbt_release_url=$(jar_url releases $sbt_release_version) -sbt_release_jar=$(jar_file $sbt_release_version) -sbt_snapshot_version=0.11.0-20110825-052147 -sbt_snapshot_url=$(jar_url snapshots $sbt_snapshot_version) -sbt_snapshot_jar=$(jar_file $sbt_snapshot_version) - -# Falses made true via command line options -useSnapshot=0 -createProject=0 - set_sbt_jar () { - if (( $useSnapshot )); then + if [[ -n "$sbt_version" ]]; then + sbt_url=$(jar_url releases $sbt_version) + elif (( $useSnapshot )); then sbt_version=$sbt_snapshot_version - sbt_url=$sbt_snapshot_url + sbt_url=$(jar_url snapshots $sbt_version) else sbt_version=$sbt_release_version - sbt_url=$sbt_release_url + sbt_url=$(jar_url releases $sbt_version) fi - sbt_jar="$script_dir/.lib/$sbt_version/sbt-launch.jar" + sbt_jar=$(jar_file $sbt_version) } @@ -83,6 +86,7 @@ Usage: $script_name [options] -29 set scala version to $latest_29 -210 set scala version to $latest_210 -local set scala version to local installation at path + -sbt-version use specified version of sbt -snapshot use a snapshot of sbt (otherwise, latest released version) # jvm options and output control @@ -123,6 +127,7 @@ process_args () -snapshot) useSnapshot=1; shift ;; -nocolors) addJava "-Dsbt.log.noformat=true"; shift ;; -create) createProject=1; shift ;; + -sbt-version) sbt_version="$2"; shift 2 ;; -D*) addJava "$1"; shift ;; -J*) addJava "${1:2}"; shift ;; @@ -171,7 +176,9 @@ EOM # no jar? download it. [[ -f "$sbt_jar" ]] || set_sbt_jar [[ -f "$sbt_jar" ]] || { - echo "Downloading sbt launcher $sbt_version, this should only take a moment..." + echo "Downloading sbt launcher $sbt_version:" + echo " From $sbt_url" + echo " To $sbt_jar" mkdir -p $(dirname "$sbt_jar") && if which curl >/dev/null; then @@ -203,6 +210,14 @@ execRunner () { "$@" } +iflast-shell () { + if [[ $sbt_version = 0.7* ]]; then + echo "shell" + else + echo "iflast shell" + fi +} + # run sbt execRunner java \ ${JAVA_OPTS:-$default_java_opts} \ @@ -210,5 +225,5 @@ execRunner java \ ${java_args[@]} \ -jar "$sbt_jar" \ "${sbt_commands[@]}" \ - "iflast shell" \ + "$(iflast-shell)" \ "$@" From 41311fcecd0cf2adc352c5a92eb9b1fdcc027081 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 25 Aug 2011 11:56:33 -0700 Subject: [PATCH 046/483] Get the version out of project/build.properties. --- sbt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sbt b/sbt index d88ce8170..68b46f007 100755 --- a/sbt +++ b/sbt @@ -12,7 +12,17 @@ sbt_snapshot_version=0.11.0-20110825-052147 # Falses made true via command line options useSnapshot=0 createProject=0 -sbt_version= +sbt_version=$( + if [[ -f project/build.properties ]]; then + versionLine=$(grep ^sbt.version project/build.properties) + versionString=${versionLine##sbt.version=} + + if [[ $versionString =~ ^[0-9]\.[0-9]\.[0-9]$ ]]; then + echo "$versionString" + fi + fi +) +echo $sbt_version jar_url () { local where=$1 # releases or snapshots From 221a049cc065f2611864a4922df0b3a410d16b5c Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 25 Aug 2011 14:43:12 -0700 Subject: [PATCH 047/483] Changed a bunch of option names to be consistent with one another. Added some more. --- sbt | 113 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 62 insertions(+), 51 deletions(-) diff --git a/sbt b/sbt index 68b46f007..a9d2731dc 100755 --- a/sbt +++ b/sbt @@ -9,10 +9,11 @@ set -e sbt_release_version=0.10.1 sbt_snapshot_version=0.11.0-20110825-052147 -# Falses made true via command line options -useSnapshot=0 -createProject=0 -sbt_version=$( +# A bunch of falses and empties as defaults. +declare sbt_jar= +declare sbt_create=0 +declare sbt_snapshot=0 +declare sbt_version=$( if [[ -f project/build.properties ]]; then versionLine=$(grep ^sbt.version project/build.properties) versionString=${versionLine##sbt.version=} @@ -22,7 +23,11 @@ sbt_version=$( fi fi ) -echo $sbt_version + +declare scala_version= +declare java_cmd=java +declare java_home= +declare verbose=0 jar_url () { local where=$1 # releases or snapshots @@ -41,7 +46,7 @@ jar_file () { set_sbt_jar () { if [[ -n "$sbt_version" ]]; then sbt_url=$(jar_url releases $sbt_version) - elif (( $useSnapshot )); then + elif (( $sbt_snapshot )); then sbt_version=$sbt_snapshot_version sbt_url=$(jar_url snapshots $sbt_version) else @@ -72,39 +77,47 @@ declare -r script_dir="$(dirname $script_path)" declare -r script_name="$(basename $script_path)" declare -r default_java_opts="-Dfile.encoding=UTF8" declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" -declare -r sbt_opts_filename=".sbtopts" -declare -r latest_28="2.8.2.RC1" -declare -r latest_29="2.9.1.RC4" +declare -r sbt_opts=".sbtopts" +declare -r latest_28="2.8.1" +declare -r latest_29="2.9.0-1" +declare -r latest_29rc="2.9.1.RC4" declare -r latest_210="2.10.0-SNAPSHOT" usage () { cat < location of sbt launcher (default: $(jar_file '')) - -sbtdir location of global settings and plugins (default: ~/.sbt) - -ivy local Ivy repository (default: ~/.ivy2) - -shared shared sbt boot directory (default: none, no sharing) - - # setting scala and sbt versions - -28 set scala version to $latest_28 - -29 set scala version to $latest_29 - -210 set scala version to $latest_210 - -local set scala version to local installation at path - -sbt-version use specified version of sbt - -snapshot use a snapshot of sbt (otherwise, latest released version) + -h | -help print this message + -v | -verbose this runner is chattier + -debug set sbt log level to debug + -no-colors disable ANSI color codes + -sbt-create start sbt even if location has no sbt project + -sbt-dir location of global settings and plugins (default: ~/.sbt) + -sbt-boot shared sbt boot directory (default: none, no sharing) + -ivy local Ivy repository (default: ~/.ivy2) + + # sbt version (default: from project/build.properties if there, else latest release) + -sbt-version use the specified version of sbt + -sbt-jar use the specified jar as the sbt launcher + -sbt-snapshot use a snapshot version of sbt + + # scala version (default: latest release) + -28 use $latest_28 + -29 use $latest_29 + -29rc use $latest_29rc + -210 use $latest_210 + -scala-home use the scala build at the specified directory + -scala-version use the specified version of scala + + # java version (default: $(which java)) + -java-home use specified path as JAVA_HOME # jvm options and output control JAVA_OPTS environment variable, if unset uses "$default_java_opts" SBT_OPTS environment variable, if unset uses "$default_sbt_opts" - .sbtopts file in sbt root directory, if present contents passed to sbt - -Dkey=val pass -Dkey=val directly to the jvm - -J-X pass option -X directly to the jvm (-J is stripped) + .sbtopts if this file is in the sbt root directory, its contents are arguments + -Dkey=val pass -Dkey=val directly to the java runtime + -J-X pass option -X directly to the java runtime (-J is stripped) In the case of duplicated or conflicting options, the order above shows precedence: JAVA_OPTS lowest, command line options highest. @@ -115,8 +128,6 @@ EOM declare -a args declare -a java_args declare -a sbt_commands -declare sbt_jar= -declare verbose=0 addJava () { java_args=("${java_args[@]}" "$1") @@ -129,48 +140,47 @@ process_args () { while [ $# -gt 0 ]; do case "$1" in - -help) usage; exit 1 ;; + -h|-help) usage; exit 1 ;; + -v|-verbose) verbose=1 ; shift ;; -ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;; - -shared) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; - -sbtdir) addJava "-Dsbt.global.base=$2"; shift 2 ;; - -snapshot) useSnapshot=1; shift ;; - -nocolors) addJava "-Dsbt.log.noformat=true"; shift ;; - -create) createProject=1; shift ;; + -no-colors) addJava "-Dsbt.log.noformat=true"; shift ;; + -sbt-boot) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; + -sbt-dir) addJava "-Dsbt.global.base=$2"; shift 2 ;; + + -sbt-create) sbt_create=1; shift ;; + -sbt-snapshot) sbt_snapshot=1; shift ;; + -sbt-jar) sbt_jar="$2"; shift 2 ;; -sbt-version) sbt_version="$2"; shift 2 ;; + -scala-version) scala_version="$2"; shift 2 ;; + -scala-home) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; + -java-home) java_cmd="$2/bin/java"; shift 2 ;; -D*) addJava "$1"; shift ;; -J*) addJava "${1:2}"; shift ;; -28) addSbt "++ $latest_28"; shift ;; -29) addSbt "++ $latest_29"; shift ;; + -29rc) addSbt "++ $latest_29rc"; shift ;; -210) addSbt "++ $latest_210"; shift ;; -debug) addSbt "set logLevel in Global := Level.Debug"; debug=1; shift ;; - -local) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; - - -v|-verbose) verbose=1 ; shift ;; - -sbtjar) sbt_jar="$2"; shift 2 ;; *) args=("${args[@]}" "$1") ; shift ;; esac done } -# if .sbtopts exists, prepend its contents -[[ -f "$sbt_opts_filename" ]] && set -- $(cat $sbt_opts_filename) "${@}" +# if .sbtopts exists, prepend its contents so it can be processed by this runner +[[ -f "$sbt_opts" ]] && set -- $(cat $sbt_opts) "${@}" # no args - alert them there's stuff in here -[[ $# -gt 0 ]] || { - echo "Starting $script_name: invoke with -help for other options" -} +[[ $# -gt 0 ]] || echo "Starting $script_name: invoke with -help for other options" -# process the unified options +# process the combined args, then reset "$@" to the residuals process_args "$@" - -# reset "$@" to the residual args set -- "${args[@]}" # verify this is an sbt dir or -create was given -[[ -f "build.sbt" ]] || [[ -d "project" ]] || (( $createProject )) || { +[[ -f build.sbt ]] || [[ -d project ]] || (( $sbt_create )) || { cat < Date: Thu, 25 Aug 2011 14:55:22 -0700 Subject: [PATCH 048/483] Phoned in some tests. Updated the docs again. --- README.md | 80 ++++++++++++++++++++------------- project/Build.scala | 8 ++-- sbt | 38 ++++++++-------- src/test/scala/RunnerTest.scala | 51 +++++++++++++++++++++ 4 files changed, 124 insertions(+), 53 deletions(-) create mode 100644 src/test/scala/RunnerTest.scala diff --git a/README.md b/README.md index 590bb314e..2faa1f8a2 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,19 @@ sbt: the rebel cut ================== -An alternative script for running [sbt 0.10+](https://github.com/harrah/xsbt). +An alternative script for running [sbt](https://github.com/harrah/xsbt). +It works with sbt 0.7 projects as well as 0.10+. If you're in a directory +with an sbt project, you can just run it and it will use the right version +of sbt, including downloading sbt if necessary. + There's also a template project sbt coming together, but it's unfinished. However the runner is quite useful already. -Here's a sample first run, which creates a new project using a snapshot -version of sbt, and runs the sbt "about" command. +Here's a sample use of the runner: it creates a new project using a +snapshot version of sbt as well as a snapshot version of scala, then +runs the sbt "about" command. - % sbt -debug -snapshot -create about + % sbt -d -sbt-snapshot -210 -sbt-create about # Executing command line: java -Xss2m @@ -22,29 +27,36 @@ version of sbt, and runs the sbt "about" command. -jar /r/sbt-extras/.lib/0.11.0-20110825-052147/sbt-launch.jar "set logLevel in Global := Level.Debug" + "++ 2.10.0-SNAPSHOT" "iflast shell" about Getting net.java.dev.jna jna 3.2.3 ... :: retrieving :: org.scala-tools.sbt#boot-app confs: [default] - 1 artifacts copied, 0 already retrieved (838kB/15ms) + 1 artifacts copied, 0 already retrieved (838kB/12ms) Getting Scala 2.9.1.RC4 (for sbt)... :: retrieving :: org.scala-tools.sbt#boot-scala confs: [default] - 4 artifacts copied, 0 already retrieved (19939kB/97ms) + 4 artifacts copied, 0 already retrieved (19939kB/32ms) Getting org.scala-tools.sbt sbt_2.9.1.RC4 0.11.0-20110825-052147 ... :: retrieving :: org.scala-tools.sbt#boot-app confs: [default] - 38 artifacts copied, 0 already retrieved (6948kB/71ms) - [info] Set current project to default-06d8dd (in build file:/private/tmp/sbt-project/) + 38 artifacts copied, 0 already retrieved (6948kB/45ms) + [info] Set current project to default-30ae78 (in build file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/) [info] Reapplying settings... - [info] Set current project to default-06d8dd (in build file:/private/tmp/sbt-project/) + [info] Set current project to default-30ae78 (in build file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/) + Setting version to 2.10.0-SNAPSHOT + [info] Set current project to default-30ae78 (in build file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/) + Getting Scala 2.10.0-SNAPSHOT ... + :: retrieving :: org.scala-tools.sbt#boot-scala + confs: [default] + 4 artifacts copied, 0 already retrieved (20650kB/58ms) [info] This is sbt 0.11.0-20110825-052147 - [info] The current project is {file:/private/tmp/sbt-project/}default-06d8dd - [info] The current project is built against Scala 2.9.1.RC4 + [info] The current project is {file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/}default-30ae78 + [info] The current project is built against Scala 2.10.0-SNAPSHOT [info] sbt, sbt plugins, and build definitions are using Scala 2.9.1.RC4 - [info] All logging output for this session is available at /var/folders/iO/iOpjflOpHzG8Mr1BL67D6k+++TI/-Tmp-/sbt75419762724938334.log + [info] All logging output for this session is available at /var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/sbt8625229869994477318.log Current -help output: @@ -53,29 +65,37 @@ Current -help output: Usage: sbt [options] - -help prints this message - -v | -verbose this runner is chattier - -debug set sbt log level to debug - -nocolors disable ANSI color codes - -create start sbt even in a directory with no project - -sbtjar location of sbt launcher (default: ./.lib//sbt-launch.jar) - -sbtdir location of global settings and plugins (default: ~/.sbt) - -ivy local Ivy repository (default: ~/.ivy2) - -shared shared sbt boot directory (default: none, no sharing) + -h | -help print this message + -v | -verbose this runner is chattier + -d | -debug set sbt log level to debug + -no-colors disable ANSI color codes + -sbt-create start sbt even if current directory contains no sbt project + -sbt-dir path to global settings/plugins directory (default: ~/.sbt) + -sbt-boot path to shared boot directory (default: none, no sharing) + -ivy path to local Ivy repository (default: ~/.ivy2) - # setting scala and sbt versions - -28 set scala version to 2.8.2.RC1 - -29 set scala version to 2.9.1.RC4 - -210 set scala version to 2.10.0-SNAPSHOT - -local set scala version to local installation at path - -snapshot use a snapshot of sbt (otherwise, latest released version) + # sbt version (default: from project/build.properties if there, else latest release) + -sbt-version use the specified version of sbt + -sbt-jar use the specified jar as the sbt launcher + -sbt-snapshot use a snapshot version of sbt + + # scala version (default: latest release) + -28 use 2.8.1 + -29 use 2.9.0-1 + -29rc use 2.9.1.RC4 + -210 use 2.10.0-SNAPSHOT + -scala-home use the scala build at the specified directory + -scala-version use the specified version of scala + + # java version (default: java from PATH, currently java version "1.6.0_26") + -java-home alternate JAVA_HOME # jvm options and output control JAVA_OPTS environment variable, if unset uses "-Dfile.encoding=UTF8" SBT_OPTS environment variable, if unset uses "-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" - .sbtopts file in sbt root directory, if present contents passed to sbt - -Dkey=val pass -Dkey=val directly to the jvm - -J-X pass option -X directly to the jvm (-J is stripped) + .sbtopts if this file exists in the sbt root, it is prepended to the runner args + -Dkey=val pass -Dkey=val directly to the java runtime + -J-X pass option -X directly to the java runtime (-J is stripped) In the case of duplicated or conflicting options, the order above shows precedence: JAVA_OPTS lowest, command line options highest. diff --git a/project/Build.scala b/project/Build.scala index c11f8f71a..0e04e51a8 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -84,9 +84,9 @@ class TemplateBuild(implicit sbtCreateConfig: SbtCreateConfig) extends Build { lazy val testSettings = Seq( libraryDependencies ++= Seq( - "org.specs2" %% "specs2" % "1.5", - "org.specs2" %% "specs2-scalaz-core" % "6.0.RC2" % "test" - ) + "org.scala-tools.testing" % "specs_2.9.0-1" % "1.6.8" % "test" + ), + libraryDependencies <+= (scalaVersion)(v => "org.scala-lang" % "scala-compiler" % v) ) lazy val buildSettings = Seq( @@ -105,7 +105,7 @@ class TemplateBuild(implicit sbtCreateConfig: SbtCreateConfig) extends Build { aggregate = Nil, dependencies = Nil, delegates = Nil, - settings = Defaults.defaultSettings ++ buildSettings ++ Seq( + settings = Defaults.defaultSettings ++ buildSettings ++ testSettings ++ Seq( commands += helpNames ) ) diff --git a/sbt b/sbt index a9d2731dc..014cbd1a0 100755 --- a/sbt +++ b/sbt @@ -17,7 +17,7 @@ declare sbt_version=$( if [[ -f project/build.properties ]]; then versionLine=$(grep ^sbt.version project/build.properties) versionString=${versionLine##sbt.version=} - + if [[ $versionString =~ ^[0-9]\.[0-9]\.[0-9]$ ]]; then echo "$versionString" fi @@ -32,7 +32,7 @@ declare verbose=0 jar_url () { local where=$1 # releases or snapshots local ver=$2 - + if [[ $ver = 0.7* ]]; then echo "http://simple-build-tool.googlecode.com/files/sbt-launch-$ver.jar" else @@ -63,7 +63,7 @@ set_sbt_jar () { get_script_path () { local path="$1" [[ -L "$path" ]] || { echo "$path" ; return; } - + local target=$(readlink "$path") if [[ "${target:0:1}" == "/" ]]; then echo "$target" @@ -89,18 +89,18 @@ Usage: $script_name [options] -h | -help print this message -v | -verbose this runner is chattier - -debug set sbt log level to debug + -d | -debug set sbt log level to debug -no-colors disable ANSI color codes - -sbt-create start sbt even if location has no sbt project - -sbt-dir location of global settings and plugins (default: ~/.sbt) - -sbt-boot shared sbt boot directory (default: none, no sharing) - -ivy local Ivy repository (default: ~/.ivy2) - + -sbt-create start sbt even if current directory contains no sbt project + -sbt-dir path to global settings/plugins directory (default: ~/.sbt) + -sbt-boot path to shared boot directory (default: none, no sharing) + -ivy path to local Ivy repository (default: ~/.ivy2) + # sbt version (default: from project/build.properties if there, else latest release) -sbt-version use the specified version of sbt -sbt-jar use the specified jar as the sbt launcher -sbt-snapshot use a snapshot version of sbt - + # scala version (default: latest release) -28 use $latest_28 -29 use $latest_29 @@ -108,14 +108,14 @@ Usage: $script_name [options] -210 use $latest_210 -scala-home use the scala build at the specified directory -scala-version use the specified version of scala - - # java version (default: $(which java)) - -java-home use specified path as JAVA_HOME + + # java version (default: java from PATH, currently $(java -version |& grep version)) + -java-home alternate JAVA_HOME # jvm options and output control JAVA_OPTS environment variable, if unset uses "$default_java_opts" SBT_OPTS environment variable, if unset uses "$default_sbt_opts" - .sbtopts if this file is in the sbt root directory, its contents are arguments + .sbtopts if this file exists in the sbt root, it is prepended to the runner args -Dkey=val pass -Dkey=val directly to the java runtime -J-X pass option -X directly to the java runtime (-J is stripped) @@ -141,7 +141,8 @@ process_args () while [ $# -gt 0 ]; do case "$1" in -h|-help) usage; exit 1 ;; - -v|-verbose) verbose=1 ; shift ;; + -v|-verbose) verbose=1; shift ;; + -d|-debug) debug=1; addSbt "set logLevel in Global := Level.Debug"; shift ;; -ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;; -no-colors) addJava "-Dsbt.log.noformat=true"; shift ;; @@ -152,7 +153,7 @@ process_args () -sbt-snapshot) sbt_snapshot=1; shift ;; -sbt-jar) sbt_jar="$2"; shift 2 ;; -sbt-version) sbt_version="$2"; shift 2 ;; - -scala-version) scala_version="$2"; shift 2 ;; + -scala-version) addSbt "++ $2"; shift 2 ;; -scala-home) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; -java-home) java_cmd="$2/bin/java"; shift 2 ;; @@ -162,13 +163,12 @@ process_args () -29) addSbt "++ $latest_29"; shift ;; -29rc) addSbt "++ $latest_29rc"; shift ;; -210) addSbt "++ $latest_210"; shift ;; - -debug) addSbt "set logLevel in Global := Level.Debug"; debug=1; shift ;; *) args=("${args[@]}" "$1") ; shift ;; esac done } - + # if .sbtopts exists, prepend its contents so it can be processed by this runner [[ -f "$sbt_opts" ]] && set -- $(cat $sbt_opts) "${@}" @@ -200,7 +200,7 @@ EOM echo " From $sbt_url" echo " To $sbt_jar" - mkdir -p $(dirname "$sbt_jar") && + mkdir -p $(dirname "$sbt_jar") && if which curl >/dev/null; then curl --silent "$sbt_url" --output "$sbt_jar" elif which wget >/dev/null; then diff --git a/src/test/scala/RunnerTest.scala b/src/test/scala/RunnerTest.scala new file mode 100644 index 000000000..9db52d254 --- /dev/null +++ b/src/test/scala/RunnerTest.scala @@ -0,0 +1,51 @@ +package org.improving + +import scala.tools.nsc.io._ +import org.specs._ + +object SbtRunnerTest extends Specification { + val scripts = { + import Predef._ + List[String]( + """|sbt -sbt-create -sbt-snapshot -210 + |sbt update + |sbt about + """, + """|sbt -sbt-create -sbt-snapshot -29 + |sbt update + |sbt version + """, + """|sbt -sbt-create -sbt-version 0.7.7 -28 + |sbt help + |sbt -h + """ + ) map (_.trim.stripMargin.lines.toList) + } + + val singles = """ +sbt -v -d -no-colors update package +sbt -verbose -210 -debug -ivy /tmp update +""".trim.lines + + import scala.sys.process._ + + def sbtProjectLines(lines: List[String]) = { + println("Running: " + lines.mkString(", ")) + + val dir = Directory.makeTemp("sbt-runner-test").jfile + val result = lines map (x => Process(x, dir)) reduceLeft (_ #&& _) ! ; + + result == 0 + } + def sbtProjectLine(line: String) = + sbtProjectLines(List("sbt -sbt-create version", line)) + + "Sbt Runner" should { + "deal with lots of different command lines" in { + singles foreach (x => sbtProjectLine(x) mustEqual true) + } + "handle various command sequences" in { + scripts foreach (xs => sbtProjectLines(xs) mustEqual true) + } + } +} From ab02dcfc36aceb1a9187de8f95b7f9088d505c44 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 25 Aug 2011 16:06:12 -0700 Subject: [PATCH 049/483] Added BSD license. --- LICENSE.txt | 11 +++++++++++ README.md | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 000000000..dc8aa7aad --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,11 @@ +// Generated from http://www.opensource.org/licenses/bsd-license.php +Copyright (c) 2011, Paul Phillips. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index 2faa1f8a2..5d564b2c0 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ sbt: the rebel cut ================== An alternative script for running [sbt](https://github.com/harrah/xsbt). -It works with sbt 0.7 projects as well as 0.10+. If you're in a directory -with an sbt project, you can just run it and it will use the right version -of sbt, including downloading sbt if necessary. +It works with sbt 0.7x projects as well as 0.10+. If you're in an sbt +project directory, the runner will figure out the versions of sbt +and scala required by the project and download them if necessary. There's also a template project sbt coming together, but it's unfinished. However the runner is quite useful already. From 5b424725b4595ad529cdd7f7c5dc9cc1eb8926b4 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 26 Aug 2011 15:10:24 -0700 Subject: [PATCH 050/483] Calculate the latest sbt snapshot from the directory listing. --- sbt | 53 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/sbt b/sbt index 014cbd1a0..bbe5b1759 100755 --- a/sbt +++ b/sbt @@ -17,9 +17,11 @@ declare sbt_version=$( if [[ -f project/build.properties ]]; then versionLine=$(grep ^sbt.version project/build.properties) versionString=${versionLine##sbt.version=} + noRC=${versionString%.RC*} + echo $noRC - if [[ $versionString =~ ^[0-9]\.[0-9]\.[0-9]$ ]]; then - echo "$versionString" + if [[ $noRC =~ ^[0-9]\.[0-9]\.[0-9]$ ]]; then + echo "$noRC" fi fi ) @@ -42,10 +44,24 @@ jar_url () { jar_file () { echo "$script_dir/.lib/$1/sbt-launch.jar" } +jar_url_latest_snapshot () { + # e.g. 0.11.0 + local version=${1%-SNAPSHOT} + # trailing slash is important + local base="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" + # e.g. 0.11.0-20110826-052141/ + local version1=$(curl -s --list-only "$base" | grep -F $version | tail -1 | perl -pe 's#^/dev/null; then + curl --silent "$url" --output "$jar" + elif which wget >/dev/null; then + wget --quiet "$url" > "$jar" + fi +} # this seems to cover the bases on OSX, and someone will # have to tell me about the others. @@ -196,16 +226,13 @@ EOM # no jar? download it. [[ -f "$sbt_jar" ]] || set_sbt_jar [[ -f "$sbt_jar" ]] || { - echo "Downloading sbt launcher $sbt_version:" - echo " From $sbt_url" - echo " To $sbt_jar" - - mkdir -p $(dirname "$sbt_jar") && - if which curl >/dev/null; then - curl --silent "$sbt_url" --output "$sbt_jar" - elif which wget >/dev/null; then - wget --quiet "$sbt_url" > "$sbt_jar" - fi + download_sbt_jar || { + [[ "$sbt_version" = *.RC* ]] && { + sbt_version="${sbt_version%.RC*}" && + set_sbt_jar && + download_sbt_jar + } + } } # still no jar? uh-oh. From f61f5e03c71a748129880359b93bc00b73777f42 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 26 Aug 2011 17:54:45 -0700 Subject: [PATCH 051/483] More on auto-snapshot detection. --- project/Build.scala | 2 +- sbt | 40 +++++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 0e04e51a8..49ca97009 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -94,7 +94,7 @@ class TemplateBuild(implicit sbtCreateConfig: SbtCreateConfig) extends Build { organization := sbtCreateConfig.organization, version := sbtCreateConfig.version, scalaVersion := sbtCreateConfig.scalaVersion, - retrieveManaged := true, + // retrieveManaged := true, shellPrompt := buildShellPrompt // logLevel := Level.Debug, ) diff --git a/sbt b/sbt index bbe5b1759..54551edf5 100755 --- a/sbt +++ b/sbt @@ -6,8 +6,16 @@ set -e # todo - make this dynamic -sbt_release_version=0.10.1 -sbt_snapshot_version=0.11.0-20110825-052147 +declare -r sbt_release_version=0.10.1 +declare -r sbt_snapshot_version=0.11.0-SNAPSHOT + +declare -r default_java_opts="-Dfile.encoding=UTF8" +declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" +declare -r sbt_opts=".sbtopts" +declare -r latest_28="2.8.1" +declare -r latest_29="2.9.0-1" +declare -r latest_29rc="2.9.1.RC4" +declare -r latest_210="2.10.0-SNAPSHOT" # A bunch of falses and empties as defaults. declare sbt_jar= @@ -44,27 +52,32 @@ jar_url () { jar_file () { echo "$script_dir/.lib/$1/sbt-launch.jar" } -jar_url_latest_snapshot () { - # e.g. 0.11.0 + +# argument is e.g. 0.11.0-SNAPSHOT +sbt_snapshot_actual_version () { + # -> 0.11.0 local version=${1%-SNAPSHOT} # trailing slash is important local base="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" # e.g. 0.11.0-20110826-052141/ - local version1=$(curl -s --list-only "$base" | grep -F $version | tail -1 | perl -pe 's#^ Date: Wed, 31 Aug 2011 15:00:58 -0700 Subject: [PATCH 052/483] scala 2.9.1. --- README.md | 7 +++---- sbt | 9 +++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5d564b2c0..5827e0f91 100644 --- a/README.md +++ b/README.md @@ -74,15 +74,14 @@ Current -help output: -sbt-boot path to shared boot directory (default: none, no sharing) -ivy path to local Ivy repository (default: ~/.ivy2) - # sbt version (default: from project/build.properties if there, else latest release) + # sbt version (default: from project/build.properties if present, else latest release) -sbt-version use the specified version of sbt -sbt-jar use the specified jar as the sbt launcher -sbt-snapshot use a snapshot version of sbt # scala version (default: latest release) -28 use 2.8.1 - -29 use 2.9.0-1 - -29rc use 2.9.1.RC4 + -29 use 2.9.1 -210 use 2.10.0-SNAPSHOT -scala-home use the scala build at the specified directory -scala-version use the specified version of scala @@ -92,7 +91,7 @@ Current -help output: # jvm options and output control JAVA_OPTS environment variable, if unset uses "-Dfile.encoding=UTF8" - SBT_OPTS environment variable, if unset uses "-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" + SBT_OPTS environment variable, if unset uses "-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xms1536m -Xmx1536m -Xss2m" .sbtopts if this file exists in the sbt root, it is prepended to the runner args -Dkey=val pass -Dkey=val directly to the java runtime -J-X pass option -X directly to the java runtime (-J is stripped) diff --git a/sbt b/sbt index 54551edf5..4c80c012e 100755 --- a/sbt +++ b/sbt @@ -10,11 +10,10 @@ declare -r sbt_release_version=0.10.1 declare -r sbt_snapshot_version=0.11.0-SNAPSHOT declare -r default_java_opts="-Dfile.encoding=UTF8" -declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" +declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xms1536m -Xmx1536m -Xss2m" declare -r sbt_opts=".sbtopts" declare -r latest_28="2.8.1" -declare -r latest_29="2.9.0-1" -declare -r latest_29rc="2.9.1.RC4" +declare -r latest_29="2.9.1" declare -r latest_210="2.10.0-SNAPSHOT" # A bunch of falses and empties as defaults. @@ -132,7 +131,7 @@ Usage: $script_name [options] -sbt-boot path to shared boot directory (default: none, no sharing) -ivy path to local Ivy repository (default: ~/.ivy2) - # sbt version (default: from project/build.properties if there, else latest release) + # sbt version (default: from project/build.properties if present, else latest release) -sbt-version use the specified version of sbt -sbt-jar use the specified jar as the sbt launcher -sbt-snapshot use a snapshot version of sbt @@ -140,7 +139,6 @@ Usage: $script_name [options] # scala version (default: latest release) -28 use $latest_28 -29 use $latest_29 - -29rc use $latest_29rc -210 use $latest_210 -scala-home use the scala build at the specified directory -scala-version use the specified version of scala @@ -197,7 +195,6 @@ process_args () -J*) addJava "${1:2}"; shift ;; -28) addSbt "++ $latest_28"; shift ;; -29) addSbt "++ $latest_29"; shift ;; - -29rc) addSbt "++ $latest_29rc"; shift ;; -210) addSbt "++ $latest_210"; shift ;; *) args=("${args[@]}" "$1") ; shift ;; From 7a86e640f354c808a46e9f182209f5c3f03d7344 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 4 Sep 2011 12:25:45 -0700 Subject: [PATCH 053/483] Too much to detail. 0.7 compat, -sbt-rc, try it. --- README.md | 5 +- sbt | 244 +++++++++++++++++++++++++++++++----------------------- 2 files changed, 142 insertions(+), 107 deletions(-) diff --git a/README.md b/README.md index 5827e0f91..52dd980e4 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,6 @@ runs the sbt "about" command. Current -help output: - % ./sbt -help - Usage: sbt [options] -h | -help print this message @@ -71,12 +69,13 @@ Current -help output: -no-colors disable ANSI color codes -sbt-create start sbt even if current directory contains no sbt project -sbt-dir path to global settings/plugins directory (default: ~/.sbt) - -sbt-boot path to shared boot directory (default: none, no sharing) + -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) -ivy path to local Ivy repository (default: ~/.ivy2) # sbt version (default: from project/build.properties if present, else latest release) -sbt-version use the specified version of sbt -sbt-jar use the specified jar as the sbt launcher + -sbt-rc use an RC version of sbt -sbt-snapshot use a snapshot version of sbt # scala version (default: latest release) diff --git a/sbt b/sbt index 4c80c012e..43711e100 100755 --- a/sbt +++ b/sbt @@ -3,11 +3,11 @@ # A more capable sbt runner, coincidentally also called sbt. # Author: Paul Phillips -set -e - # todo - make this dynamic declare -r sbt_release_version=0.10.1 +declare -r sbt_rc_version=0.11.0-RC0 declare -r sbt_snapshot_version=0.11.0-SNAPSHOT +declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" declare -r default_java_opts="-Dfile.encoding=UTF8" declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xms1536m -Xmx1536m -Xss2m" @@ -18,88 +18,138 @@ declare -r latest_210="2.10.0-SNAPSHOT" # A bunch of falses and empties as defaults. declare sbt_jar= -declare sbt_create=0 -declare sbt_snapshot=0 +declare sbt_create= declare sbt_version=$( if [[ -f project/build.properties ]]; then versionLine=$(grep ^sbt.version project/build.properties) versionString=${versionLine##sbt.version=} - noRC=${versionString%.RC*} - echo $noRC - - if [[ $noRC =~ ^[0-9]\.[0-9]\.[0-9]$ ]]; then - echo "$noRC" - fi + echo "${versionString%%.RC*}" fi ) - -declare scala_version= +declare scala_version=$( + if [[ -f project/build.properties ]]; then + versionLine=$(grep ^build.scala.versions project/build.properties) + versionString=${versionLine##build.scala.versions=} + echo ${versionString%% .*} + fi +) +declare sbt_snapshot=0 declare java_cmd=java declare java_home= -declare verbose=0 +unset verbose +unset debug -jar_url () { - local where=$1 # releases or snapshots - local ver=$2 +execRunner () { + # print the arguments one to a line, quoting any containing spaces + [[ $verbose || $debug ]] && echo "# Executing command line:" && { + for arg; do + if echo "$arg" | grep -q ' '; then + printf "\"%s\"\n" "$arg" + else + printf "%s\n" "$arg" + fi + done + echo "" + } - if [[ $ver = 0.7* ]]; then - echo "http://simple-build-tool.googlecode.com/files/sbt-launch-$ver.jar" - else - echo "http://typesafe.artifactoryonline.com/typesafe/ivy-$where/org.scala-tools.sbt/sbt-launch/$ver/sbt-launch.jar" - fi + "$@" } +echoerr () { + echo 1>&2 "$@" +} +dlog () { + [[ $verbose || $debug ]] && echoerr "$@" +} + +[[ "$sbt_version" = *-SNAPSHOT* || "$sbt_version" = *-RC* ]] && sbt_snapshot=1 +[[ -n "$sbt_version" ]] && echo "Detected sbt version $sbt_version" +[[ -n "$scala_version" ]] && echo "Detected scala version $scala_version" + +sbtjar_07_url () { + echo "http://simple-build-tool.googlecode.com/files/sbt-launch-${1}.jar" +} +sbtjar_release_url () { + echo "http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/$sbt_version/sbt-launch.jar" +} +sbtjar_snapshot_url () { + local ver="$sbt_version" + [[ "$sbt_version" == *-SNAPSHOT ]] && { + ver=$(sbt_snapshot_actual_version) + echoerr "sbt snapshot is $ver" + } + + echo "${sbt_snapshot_baseurl}${ver}/sbt-launch.jar" +} +jar_url () { + case $sbt_version in + 0.7.4*) sbtjar_07_url 0.7.4 ;; + 0.7.5*) sbtjar_07_url 0.7.5 ;; + 0.7.7*) sbtjar_07_url 0.7.7 ;; + 0.7.*) sbtjar_07_url 0.7.7 ;; + *-SNAPSHOT*) sbtjar_snapshot_url ;; + *-RC*) sbtjar_snapshot_url ;; + *) sbtjar_release_url ;; + esac +} + jar_file () { echo "$script_dir/.lib/$1/sbt-launch.jar" } -# argument is e.g. 0.11.0-SNAPSHOT -sbt_snapshot_actual_version () { - # -> 0.11.0 - local version=${1%-SNAPSHOT} - # trailing slash is important - local base="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" - # e.g. 0.11.0-20110826-052141/ - curl -s --list-only "$base" | grep -F $version | tail -1 | perl -pe 's#^' | \ + perl -pe 's#^/dev/null + dlog "curl returned: $?" + echo "$ver" + return + done +} + +download_url () { + local url="$1" + local jar="$2" echo "Downloading sbt launcher $sbt_version:" echo " From $url" echo " To $jar" - mkdir -p $(dirname "$jar") && + mkdir -p $(dirname "$jar") && { if which curl >/dev/null; then curl --silent "$url" --output "$jar" elif which wget >/dev/null; then wget --quiet "$url" > "$jar" fi + } && [[ -f "$jar" ]] } +acquire_sbt_jar () { + if (( $sbt_snapshot )); then + sbt_version=$sbt_snapshot_version + elif [[ ! $sbt_version ]]; then + sbt_version=$sbt_release_version + fi + + sbt_url="$(jar_url)" + sbt_jar="$(jar_file $sbt_version)" + + [[ -f "$sbt_jar" ]] || download_url "$sbt_url" "$sbt_jar" +} + + # this seems to cover the bases on OSX, and someone will # have to tell me about the others. get_script_path () { @@ -128,12 +178,13 @@ Usage: $script_name [options] -no-colors disable ANSI color codes -sbt-create start sbt even if current directory contains no sbt project -sbt-dir path to global settings/plugins directory (default: ~/.sbt) - -sbt-boot path to shared boot directory (default: none, no sharing) + -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) -ivy path to local Ivy repository (default: ~/.ivy2) # sbt version (default: from project/build.properties if present, else latest release) -sbt-version use the specified version of sbt -sbt-jar use the specified jar as the sbt launcher + -sbt-rc use an RC version of sbt -sbt-snapshot use a snapshot version of sbt # scala version (default: latest release) @@ -159,7 +210,7 @@ EOM } # pull -J and -D options to give to java. -declare -a args +declare -a residual_args declare -a java_args declare -a sbt_commands @@ -169,22 +220,27 @@ addJava () { addSbt () { sbt_commands=("${sbt_commands[@]}" "$1") } +addResidual () { + residual_args=("${residual_args[@]}" "$1") +} process_args () { - while [ $# -gt 0 ]; do + while [[ $# -gt 0 ]]; do case "$1" in -h|-help) usage; exit 1 ;; -v|-verbose) verbose=1; shift ;; - -d|-debug) debug=1; addSbt "set logLevel in Global := Level.Debug"; shift ;; + -d|-debug) debug=1; shift ;; + # -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload ; shift ;; -ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;; -no-colors) addJava "-Dsbt.log.noformat=true"; shift ;; -sbt-boot) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; -sbt-dir) addJava "-Dsbt.global.base=$2"; shift 2 ;; - -sbt-create) sbt_create=1; shift ;; - -sbt-snapshot) sbt_snapshot=1; shift ;; + -sbt-create) sbt_create=true; shift ;; + -sbt-rc) sbt_version=$sbt_rc_version; shift ;; + -sbt-snapshot) sbt_version=$sbt_snapshot_version; shift ;; -sbt-jar) sbt_jar="$2"; shift 2 ;; -sbt-version) sbt_version="$2"; shift 2 ;; -scala-version) addSbt "++ $2"; shift 2 ;; @@ -197,23 +253,31 @@ process_args () -29) addSbt "++ $latest_29"; shift ;; -210) addSbt "++ $latest_210"; shift ;; - *) args=("${args[@]}" "$1") ; shift ;; + *) addResidual "$1"; shift ;; esac done + + [[ $debug ]] && { + case "$sbt_version" in + 0.7*) addSbt "debug" ;; + *) addSbt "set logLevel in Global := Level.Debug" ;; + esac + } } -# if .sbtopts exists, prepend its contents so it can be processed by this runner -[[ -f "$sbt_opts" ]] && set -- $(cat $sbt_opts) "${@}" - -# no args - alert them there's stuff in here -[[ $# -gt 0 ]] || echo "Starting $script_name: invoke with -help for other options" +# if .sbtopts exists, prepend its contents to $@ so it can be processed by this runner +[[ -f "$sbt_opts" ]] && set -- $(cat $sbt_opts) "$@" # process the combined args, then reset "$@" to the residuals process_args "$@" -set -- "${args[@]}" +set -- "${residual_args[@]}" +argumentCount=$# + +# no args - alert them there's stuff in here +(( $argumentCount > 0 )) || echo "Starting $script_name: invoke with -help for other options" # verify this is an sbt dir or -create was given -[[ -f build.sbt ]] || [[ -d project ]] || (( $sbt_create )) || { +[[ -f ./build.sbt || -d ./project || -n "$sbt_create" ]] || { cat < Date: Mon, 5 Sep 2011 14:16:43 -0700 Subject: [PATCH 054/483] Fix for multiword sbt commands. --- sbt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sbt b/sbt index 43711e100..efd42b754 100755 --- a/sbt +++ b/sbt @@ -215,13 +215,13 @@ declare -a java_args declare -a sbt_commands addJava () { - java_args=("${java_args[@]}" "$1") + java_args=( "${java_args[@]}" "$1" ) } addSbt () { - sbt_commands=("${sbt_commands[@]}" "$1") + sbt_commands=( "${sbt_commands[@]}" "$1" ) } addResidual () { - residual_args=("${residual_args[@]}" "$1") + residual_args=( "${residual_args[@]}" "$1" ) } process_args () @@ -313,4 +313,4 @@ execRunner "$java_cmd" \ ${java_args[@]} \ -jar "$sbt_jar" \ "${sbt_commands[@]}" \ - "$(sbt-args)" + $(sbt-args) From 849214c208ed56db8efe8b9990f5a9d12b59e010 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 5 Sep 2011 14:38:21 -0700 Subject: [PATCH 055/483] Resolving the sbt version correctly. --- sbt | 87 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/sbt b/sbt index efd42b754..e72290453 100755 --- a/sbt +++ b/sbt @@ -3,6 +3,20 @@ # A more capable sbt runner, coincidentally also called sbt. # Author: Paul Phillips +# this seems to cover the bases on OSX, and someone will +# have to tell me about the others. +get_script_path () { + local path="$1" + [[ -L "$path" ]] || { echo "$path" ; return; } + + local target=$(readlink "$path") + if [[ "${target:0:1}" == "/" ]]; then + echo "$target" + else + echo "$path/$target" + fi +} + # todo - make this dynamic declare -r sbt_release_version=0.10.1 declare -r sbt_rc_version=0.11.0-RC0 @@ -16,29 +30,36 @@ declare -r latest_28="2.8.1" declare -r latest_29="2.9.1" declare -r latest_210="2.10.0-SNAPSHOT" +declare -r script_path=$(get_script_path "$BASH_SOURCE") +declare -r script_dir="$(dirname $script_path)" +declare -r script_name="$(basename $script_path)" + # A bunch of falses and empties as defaults. declare sbt_jar= declare sbt_create= -declare sbt_version=$( - if [[ -f project/build.properties ]]; then - versionLine=$(grep ^sbt.version project/build.properties) - versionString=${versionLine##sbt.version=} - echo "${versionString%%.RC*}" - fi -) -declare scala_version=$( - if [[ -f project/build.properties ]]; then - versionLine=$(grep ^build.scala.versions project/build.properties) - versionString=${versionLine##build.scala.versions=} - echo ${versionString%% .*} - fi -) +declare sbt_version= +declare scala_version= declare sbt_snapshot=0 declare java_cmd=java declare java_home= unset verbose unset debug +build_props_sbt () { + if [[ -f project/build.properties ]]; then + versionLine=$(grep ^sbt.version project/build.properties) + versionString=${versionLine##sbt.version=} + echo "$versionString" + fi +} +build_props_scala () { + if [[ -f project/build.properties ]]; then + versionLine=$(grep ^build.scala.versions project/build.properties) + versionString=${versionLine##build.scala.versions=} + echo ${versionString%% .*} + fi +} + execRunner () { # print the arguments one to a line, quoting any containing spaces [[ $verbose || $debug ]] && echo "# Executing command line:" && { @@ -61,10 +82,6 @@ dlog () { [[ $verbose || $debug ]] && echoerr "$@" } -[[ "$sbt_version" = *-SNAPSHOT* || "$sbt_version" = *-RC* ]] && sbt_snapshot=1 -[[ -n "$sbt_version" ]] && echo "Detected sbt version $sbt_version" -[[ -n "$scala_version" ]] && echo "Detected scala version $scala_version" - sbtjar_07_url () { echo "http://simple-build-tool.googlecode.com/files/sbt-launch-${1}.jar" } @@ -150,24 +167,6 @@ acquire_sbt_jar () { } -# this seems to cover the bases on OSX, and someone will -# have to tell me about the others. -get_script_path () { - local path="$1" - [[ -L "$path" ]] || { echo "$path" ; return; } - - local target=$(readlink "$path") - if [[ "${target:0:1}" == "/" ]]; then - echo "$target" - else - echo "$path/$target" - fi -} - -declare -r script_path=$(get_script_path "$BASH_SOURCE") -declare -r script_dir="$(dirname $script_path)" -declare -r script_name="$(basename $script_path)" - usage () { cat < 0 )) || echo "Starting $script_name: invoke with -help for other options" From 6d09f201ea2a0af4e14ed8eedf5ce63dd0f2043f Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 5 Sep 2011 14:59:08 -0700 Subject: [PATCH 056/483] I'll get the quoting right eventually. --- sbt | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/sbt b/sbt index e72290453..debbc8cf4 100755 --- a/sbt +++ b/sbt @@ -45,6 +45,11 @@ declare java_home= unset verbose unset debug +# pull -J and -D options to give to java. +declare -a residual_args +declare -a java_args +declare -a sbt_commands + build_props_sbt () { if [[ -f project/build.properties ]]; then versionLine=$(grep ^sbt.version project/build.properties) @@ -64,7 +69,7 @@ execRunner () { # print the arguments one to a line, quoting any containing spaces [[ $verbose || $debug ]] && echo "# Executing command line:" && { for arg; do - if echo "$arg" | grep -q ' '; then + if printf "%s\n" "$arg" | grep -q ' '; then printf "\"%s\"\n" "$arg" else printf "%s\n" "$arg" @@ -75,6 +80,7 @@ execRunner () { "$@" } + echoerr () { echo 1>&2 "$@" } @@ -209,12 +215,15 @@ EOM } addJava () { + dlog "[addJava] arg = '$1'" java_args=( "${java_args[@]}" "$1" ) } addSbt () { + dlog "[addSbt] arg = '$1'" sbt_commands=( "${sbt_commands[@]}" "$1" ) } addResidual () { + dlog "[residual] arg = '$1'" residual_args=( "${residual_args[@]}" "$1" ) } @@ -273,11 +282,6 @@ argumentCount=$# [[ -n "$sbt_version" ]] && echo "Detected sbt version $sbt_version" [[ -n "$scala_version" ]] && echo "Detected scala version $scala_version" -# pull -J and -D options to give to java. -declare -a residual_args -declare -a java_args -declare -a sbt_commands - # no args - alert them there's stuff in here (( $argumentCount > 0 )) || echo "Starting $script_name: invoke with -help for other options" @@ -302,14 +306,8 @@ EOM exit 1 } -sbt-args () { - # since sbt 0.7 doesn't understand iflast - if (( "${#residual_args[@]}" == 0 )); then - echo "shell" - else - echo "${residual_args[@]}" - fi -} +# since sbt 0.7 doesn't understand iflast +(( ${#residual_args[@]} == 0 )) && residual_args=( "shell" ) # run sbt execRunner "$java_cmd" \ @@ -318,4 +316,4 @@ execRunner "$java_cmd" \ ${java_args[@]} \ -jar "$sbt_jar" \ "${sbt_commands[@]}" \ - $(sbt-args) + "${residual_args[@]}" From a100c052e6f69003816e95462f3554c18548bd3b Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 5 Sep 2011 15:46:24 -0700 Subject: [PATCH 057/483] -debug-inc. --- sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/sbt b/sbt index debbc8cf4..4318a4342 100755 --- a/sbt +++ b/sbt @@ -240,6 +240,7 @@ process_args () -no-colors) addJava "-Dsbt.log.noformat=true"; shift ;; -sbt-boot) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; -sbt-dir) addJava "-Dsbt.global.base=$2"; shift 2 ;; + -debug-inc) addJava "-Dxsbt.inc.debug=true"; shift ;; -sbt-create) sbt_create=true; shift ;; -sbt-rc) sbt_version=$sbt_rc_version; shift ;; From eb413bec840d60f06e83b59ca45b99212195bba7 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 13 Sep 2011 10:56:37 -0700 Subject: [PATCH 058/483] Shuffling around so -sbt-rc works. --- sbt | 72 ++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/sbt b/sbt index 4318a4342..22911ddfb 100755 --- a/sbt +++ b/sbt @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash --norc # # A more capable sbt runner, coincidentally also called sbt. # Author: Paul Phillips @@ -17,15 +17,28 @@ get_script_path () { fi } +# a ham-fisted attempt to move some memory settings in concert +# so they need not be dicked around with individually. +get_mem_opts () { + local mem=${1:-1536} + local perm=$(( $mem / 4 )) + (( $perm > 256 )) || perm=256 + (( $perm < 1024 )) || perm=1024 + local codecache=$(( $perm / 8 )) + + echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" +} + # todo - make this dynamic declare -r sbt_release_version=0.10.1 -declare -r sbt_rc_version=0.11.0-RC0 +declare -r sbt_rc_version=0.11.0-RC1 declare -r sbt_snapshot_version=0.11.0-SNAPSHOT declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" declare -r default_java_opts="-Dfile.encoding=UTF8" -declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xms1536m -Xmx1536m -Xss2m" -declare -r sbt_opts=".sbtopts" +declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled" +declare -r default_sbt_mem=1536 +declare -r sbt_opts_file=".sbtopts" declare -r latest_28="2.8.1" declare -r latest_29="2.9.1" declare -r latest_210="2.10.0-SNAPSHOT" @@ -34,16 +47,14 @@ declare -r script_path=$(get_script_path "$BASH_SOURCE") declare -r script_dir="$(dirname $script_path)" declare -r script_name="$(basename $script_path)" -# A bunch of falses and empties as defaults. -declare sbt_jar= -declare sbt_create= -declare sbt_version= -declare scala_version= -declare sbt_snapshot=0 declare java_cmd=java -declare java_home= -unset verbose -unset debug +declare sbt_mem=$default_sbt_mem +declare java_opts="${JAVA_OPTS:-$default_java_opts}" + +unset sbt_jar sbt_create sbt_version sbt_snapshot +unset scala_version +unset java_home +unset verbose debug # pull -J and -D options to give to java. declare -a residual_args @@ -65,6 +76,13 @@ build_props_scala () { fi } +isSnapshot () { + [[ "$sbt_version" = *-SNAPSHOT* ]] +} +isRC () { + [[ "$sbt_version" = *-RC* ]] +} + execRunner () { # print the arguments one to a line, quoting any containing spaces [[ $verbose || $debug ]] && echo "# Executing command line:" && { @@ -96,11 +114,14 @@ sbtjar_release_url () { } sbtjar_snapshot_url () { local ver="$sbt_version" - [[ "$sbt_version" == *-SNAPSHOT ]] && { - ver=$(sbt_snapshot_actual_version) + if [[ "$sbt_version" = *-SNAPSHOT ]]; then + ver=$(sbt_snapshot_actual_version -SNAPSHOT) echoerr "sbt snapshot is $ver" - } - + elif [[ "$sbt_version" = *-SNAPSHOT ]]; then + ver=$(sbt_snapshot_actual_version -RC) + echoerr "sbt rc is $ver" + fi + echo "${sbt_snapshot_baseurl}${ver}/sbt-launch.jar" } jar_url () { @@ -120,11 +141,11 @@ jar_file () { } sbt_artifactory_list () { + local type="$1" # -RC or -SNAPSHOT local version=${sbt_version%-SNAPSHOT} curl -s --list-only "$sbt_snapshot_baseurl" | \ grep -F $version | \ - grep -v -- '-RC' | \ perl -e 'print reverse <>' | \ perl -pe 's#^/dev/null @@ -160,7 +181,7 @@ download_url () { } acquire_sbt_jar () { - if (( $sbt_snapshot )); then + if [[ $sbt_snapshot ]]; then sbt_version=$sbt_snapshot_version elif [[ ! $sbt_version ]]; then sbt_version=$sbt_release_version @@ -185,6 +206,7 @@ Usage: $script_name [options] -sbt-dir path to global settings/plugins directory (default: ~/.sbt) -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) -ivy path to local Ivy repository (default: ~/.ivy2) + -mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) # sbt version (default: from project/build.properties if present, else latest release) -sbt-version use the specified version of sbt @@ -203,7 +225,7 @@ Usage: $script_name [options] -java-home alternate JAVA_HOME # jvm options and output control - JAVA_OPTS environment variable, if unset uses "$default_java_opts" + JAVA_OPTS environment variable, if unset uses "$java_opts" SBT_OPTS environment variable, if unset uses "$default_sbt_opts" .sbtopts if this file exists in the sbt root, it is prepended to the runner args -Dkey=val pass -Dkey=val directly to the java runtime @@ -237,6 +259,7 @@ process_args () # -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload ; shift ;; -ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;; + -mem) sbt_mem="$2"; shift 2 ;; -no-colors) addJava "-Dsbt.log.noformat=true"; shift ;; -sbt-boot) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; -sbt-dir) addJava "-Dsbt.global.base=$2"; shift 2 ;; @@ -270,7 +293,7 @@ process_args () } # if .sbtopts exists, prepend its contents to $@ so it can be processed by this runner -[[ -f "$sbt_opts" ]] && set -- $(cat $sbt_opts) "$@" +[[ -f "$sbt_opts_file" ]] && set -- $(cat "$sbt_opts_file") "$@" # process the combined args, then reset "$@" to the residuals process_args "$@" @@ -291,7 +314,7 @@ argumentCount=$# cat < Date: Wed, 14 Sep 2011 09:24:12 -0700 Subject: [PATCH 059/483] Add snapshots repo if a snapshot sbt or scala version is used. --- sbt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sbt b/sbt index 22911ddfb..0a97082df 100755 --- a/sbt +++ b/sbt @@ -248,6 +248,12 @@ addResidual () { dlog "[residual] arg = '$1'" residual_args=( "${residual_args[@]}" "$1" ) } +addResolver () { + addSbt "set resolvers += $1" +} +addSnapshotRepo () { + addResolver "ScalaToolsSnapshots" +} process_args () { @@ -267,7 +273,7 @@ process_args () -sbt-create) sbt_create=true; shift ;; -sbt-rc) sbt_version=$sbt_rc_version; shift ;; - -sbt-snapshot) sbt_version=$sbt_snapshot_version; shift ;; + -sbt-snapshot) addSnapshotRepo ; sbt_version=$sbt_snapshot_version; shift ;; -sbt-jar) sbt_jar="$2"; shift 2 ;; -sbt-version) sbt_version="$2"; shift 2 ;; -scala-version) addSbt "++ $2"; shift 2 ;; @@ -278,7 +284,7 @@ process_args () -J*) addJava "${1:2}"; shift ;; -28) addSbt "++ $latest_28"; shift ;; -29) addSbt "++ $latest_29"; shift ;; - -210) addSbt "++ $latest_210"; shift ;; + -210) addSnapshotRepo ; addSbt "++ $latest_210"; shift ;; *) addResidual "$1"; shift ;; esac From 7ffbf5374ccb6d6c3077cb119bac27aa4d9f915f Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 14 Sep 2011 09:29:59 -0700 Subject: [PATCH 060/483] Not that it fixed my issue, but ThisBuild. --- sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbt b/sbt index 0a97082df..2b2be4b0f 100755 --- a/sbt +++ b/sbt @@ -249,7 +249,7 @@ addResidual () { residual_args=( "${residual_args[@]}" "$1" ) } addResolver () { - addSbt "set resolvers += $1" + addSbt "set resolvers in ThisBuild += $1" } addSnapshotRepo () { addResolver "ScalaToolsSnapshots" From 8836f37c9c671347960ecb1b65a90f4be538cb08 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 14 Sep 2011 13:01:48 -0400 Subject: [PATCH 061/483] Modified paulp's template project to be an SBT plugin --- README.md | 23 ++++++++ build.sbt | 8 +++ project/Build.scala | 119 ------------------------------------- src/main/scala/Main.scala | 120 +++++++++++++++++++++++++++++++++++++- 4 files changed, 148 insertions(+), 122 deletions(-) create mode 100644 build.sbt delete mode 100644 project/Build.scala diff --git a/README.md b/README.md index 52dd980e4..e1075d3fd 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ project directory, the runner will figure out the versions of sbt and scala required by the project and download them if necessary. There's also a template project sbt coming together, but it's unfinished. +See below for how to pull the template project in as a plugin. However the runner is quite useful already. Here's a sample use of the runner: it creates a new project using a @@ -97,3 +98,25 @@ Current -help output: In the case of duplicated or conflicting options, the order above shows precedence: JAVA_OPTS lowest, command line options highest. + + +## Template project + +To gain access to the awesome, simply add the following /project/plugins/project/Build.scala file: + + import sbt._ + object PluginDef extends Build { + override def projects = Seq(root) + lazy val root = Project("plugins", file(".")) dependsOn(extras) + lazy val extras = uri("git://github.com/jsuereth/sbt-extras") + } + +Now to continue the amazement, simply extend the TemplateBuild trait in your project. For example, in your +/project/Build.scala file add: + + import sbt._ + import template.TemplateBuild + + object MyAwesomeBuild extends TemplateBuild {} + +The Template build isn't quite finished. There will most likely be a build.sbt DSL variant that does not require a project scala file. diff --git a/build.sbt b/build.sbt new file mode 100644 index 000000000..e227a442a --- /dev/null +++ b/build.sbt @@ -0,0 +1,8 @@ +sbtPlugin := true + +name := "sbt-extras-plugin" + +organization := "org.improving" + +version <<= (sbtVersion)("0.1.0-%s".format(_)) + diff --git a/project/Build.scala b/project/Build.scala deleted file mode 100644 index 49ca97009..000000000 --- a/project/Build.scala +++ /dev/null @@ -1,119 +0,0 @@ -import sbt._ -import Keys._ -import Load.{ BuildStructure, StructureIndex } -import scala.collection.{ mutable, immutable } - -trait SbtCreateConfig { - def name: String - def organization: String - def version: String - def scalaVersion: String -} -object SbtCreateConfig { - private def prop(propName: String, alt: String) = System.getProperty(propName) match { - case null => alt - case value => value - } - implicit def defaultProjectConfig = new SbtCreateConfig { - def name = prop("sbt-create.name", "project-name-here") - def organization = prop("sbt-create.organization", "your.organization.here") - def version = prop("sbt-create.version", "0.1-SNAPSHOT") - def scalaVersion = prop("sbt.scala.version", "2.9.0-1") - } -} - -class TemplateBuild(implicit sbtCreateConfig: SbtCreateConfig) extends Build { - // BuildStructure contains: - // units: Map[URI, LoadedBuildUnit] - // root: URI - // settings: Seq[Setting[_]] - // data: Settings[Scope] - // index: StructureIndex - // streams: Streams - // delegates: Scope => Seq[Scope] - // scopeLocal: ScopeLocal - - private val cachedExtraction = new collection.mutable.HashMap[State, WState] - private implicit def stateWrapper(state: State): WState = - cachedExtraction.getOrElseUpdate(state, new WState(state)) - private implicit def revealStructure(state: State): BuildStructure = - stateWrapper(state).structure - private implicit def revealStructureIndex(state: State): StructureIndex = - revealStructure(state).index - private implicit def revealSession(state: State): SessionSettings = - stateWrapper(state).session - - private class WState(state: State) { - val extracted = Project extract state - - def projectId = extracted.currentProject.id - def structure = extracted.structure - def session = extracted.session - def currentRef = extracted.currentRef - def rootProject = structure.rootProject - def allProjects = structure.allProjects - - def index = structure.index - def taskToKey = index.taskToKey - def keyMap = index.keyMap // Map[String, AttributeKey[_]] - def keyIndex = index.keyIndex - def currentKeys = keyIndex keys Some(currentRef) map index.keyMap - def sortedKeys = currentKeys.toSeq sortBy (_.label) - } - - private class Tap[T](target: T) { - def show(): Unit = target match { - case xs: TraversableOnce[_] => xs foreach println - case _ => println(target) - } - def tap[U](f: T => U): T = { - f(target) - target - } - } - private implicit def createTapper[T](target: T): Tap[T] = new Tap(target) - - def currentBranch = ("git status -sb".lines_! headOption) getOrElse "-" stripPrefix "## " - - val buildShellPrompt = { - (state: State) => "%s:%s>".format( - state.projectId, - currentBranch - ) - } - - lazy val testSettings = Seq( - libraryDependencies ++= Seq( - "org.scala-tools.testing" % "specs_2.9.0-1" % "1.6.8" % "test" - ), - libraryDependencies <+= (scalaVersion)(v => "org.scala-lang" % "scala-compiler" % v) - ) - - lazy val buildSettings = Seq( - resolvers += ScalaToolsSnapshots, - organization := sbtCreateConfig.organization, - version := sbtCreateConfig.version, - scalaVersion := sbtCreateConfig.scalaVersion, - // retrieveManaged := true, - shellPrompt := buildShellPrompt - // logLevel := Level.Debug, - ) - - lazy val templateConfig = Project( - id = sbtCreateConfig.name, - base = file("."), - aggregate = Nil, - dependencies = Nil, - delegates = Nil, - settings = Defaults.defaultSettings ++ buildSettings ++ testSettings ++ Seq( - commands += helpNames - ) - ) - - // A sample command definition. - def helpNames = Command.command("help-names") { (state: State) => - state tap (_.sortedKeys map (_.label) show) - } -} - -object TemplateBuild extends TemplateBuild { } diff --git a/src/main/scala/Main.scala b/src/main/scala/Main.scala index bff37c687..7727601c7 100644 --- a/src/main/scala/Main.scala +++ b/src/main/scala/Main.scala @@ -1,7 +1,121 @@ package template -object Main { - def main(args: Array[String]): Unit = { - println("Skeleton main, reporting for duty on " + util.Properties.versionString) +import sbt._ +import Keys._ +import Load.{ BuildStructure, StructureIndex } +import scala.collection.{ mutable, immutable } + +object SbtExtrasPlugin extends Plugin {} + +trait SbtCreateConfig { + def name: String + def organization: String + def version: String + def scalaVersion: String +} +object SbtCreateConfig { + private def prop(propName: String, alt: String) = System.getProperty(propName) match { + case null => alt + case value => value + } + implicit def defaultProjectConfig = new SbtCreateConfig { + def name = prop("sbt-create.name", "project-name-here") + def organization = prop("sbt-create.organization", "your.organization.here") + def version = prop("sbt-create.version", "0.1-SNAPSHOT") + def scalaVersion = prop("sbt.scala.version", "2.9.0-1") + } +} + +class TemplateBuild(implicit sbtCreateConfig: SbtCreateConfig) extends Build { + // BuildStructure contains: + // units: Map[URI, LoadedBuildUnit] + // root: URI + // settings: Seq[Setting[_]] + // data: Settings[Scope] + // index: StructureIndex + // streams: Streams + // delegates: Scope => Seq[Scope] + // scopeLocal: ScopeLocal + + private val cachedExtraction = new collection.mutable.HashMap[State, WState] + private implicit def stateWrapper(state: State): WState = + cachedExtraction.getOrElseUpdate(state, new WState(state)) + private implicit def revealStructure(state: State): BuildStructure = + stateWrapper(state).structure + private implicit def revealStructureIndex(state: State): StructureIndex = + revealStructure(state).index + private implicit def revealSession(state: State): SessionSettings = + stateWrapper(state).session + + private class WState(state: State) { + val extracted = Project extract state + + def projectId = extracted.currentProject.id + def structure = extracted.structure + def session = extracted.session + def currentRef = extracted.currentRef + def rootProject = structure.rootProject + def allProjects = structure.allProjects + + def index = structure.index + def taskToKey = index.taskToKey + def keyMap = index.keyMap // Map[String, AttributeKey[_]] + def keyIndex = index.keyIndex + def currentKeys = keyIndex keys Some(currentRef) map index.keyMap + def sortedKeys = currentKeys.toSeq sortBy (_.label) + } + + private class Tap[T](target: T) { + def show(): Unit = target match { + case xs: TraversableOnce[_] => xs foreach println + case _ => println(target) + } + def tap[U](f: T => U): T = { + f(target) + target + } + } + private implicit def createTapper[T](target: T): Tap[T] = new Tap(target) + + def currentBranch = ("git status -sb".lines_! headOption) getOrElse "-" stripPrefix "## " + + val buildShellPrompt = { + (state: State) => "%s:%s> ".format( + state.projectId, + currentBranch + ) + } + + lazy val testSettings = Seq( + libraryDependencies ++= Seq( + "org.scala-tools.testing" % "specs_2.9.0-1" % "1.6.8" % "test" + ), + libraryDependencies <+= (scalaVersion)(v => "org.scala-lang" % "scala-compiler" % v) + ) + + lazy val buildSettings = Seq( + resolvers += ScalaToolsSnapshots, + organization := sbtCreateConfig.organization, + version := sbtCreateConfig.version, + scalaVersion := sbtCreateConfig.scalaVersion, + // retrieveManaged := true, + shellPrompt := buildShellPrompt + // logLevel := Level.Debug, + ) + + lazy val templateConfig = Project( + id = sbtCreateConfig.name, + base = file("."), + aggregate = Nil, + dependencies = Nil, + delegates = Nil, + settings = Defaults.defaultSettings ++ buildSettings ++ testSettings ++ Seq( + commands += helpNames + ) + ) + + // A sample command definition. + def helpNames = Command.command("help-names") { (state: State) => + state tap (_.sortedKeys map (_.label) show) } } From c098d04c58dcae93c528bad6cf87220329c37e26 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 14 Sep 2011 10:41:11 -0700 Subject: [PATCH 062/483] Added template project. Shortened readme. --- .gitignore | 3 ++- README.md | 22 ++++++------------- template-project/project/Build.scala | 4 ++++ .../project/plugins/project/Build.scala | 7 ++++++ 4 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 template-project/project/Build.scala create mode 100644 template-project/project/plugins/project/Build.scala diff --git a/.gitignore b/.gitignore index a13d4dfa0..6c23ca894 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ target lib_managed src_managed /ext -.lib \ No newline at end of file +.lib +/template-project/project/boot \ No newline at end of file diff --git a/README.md b/README.md index e1075d3fd..7685192f0 100644 --- a/README.md +++ b/README.md @@ -100,23 +100,15 @@ Current -help output: shows precedence: JAVA_OPTS lowest, command line options highest. -## Template project +## Template project ## -To gain access to the awesome, simply add the following /project/plugins/project/Build.scala file: +To see the plugin in action, including the thrilling custom sbt command "help-names": - import sbt._ - object PluginDef extends Build { - override def projects = Seq(root) - lazy val root = Project("plugins", file(".")) dependsOn(extras) - lazy val extras = uri("git://github.com/jsuereth/sbt-extras") - } + cd template-project && ../sbt -sbt-rc help-names + +The template files are: -Now to continue the amazement, simply extend the TemplateBuild trait in your project. For example, in your -/project/Build.scala file add: - - import sbt._ - import template.TemplateBuild - - object MyAwesomeBuild extends TemplateBuild {} + project/plugins/project/Build.scala # you can use this as-is if you want + project/Build.scala # this is a starting point for your real Build.scala The Template build isn't quite finished. There will most likely be a build.sbt DSL variant that does not require a project scala file. diff --git a/template-project/project/Build.scala b/template-project/project/Build.scala new file mode 100644 index 000000000..e10479236 --- /dev/null +++ b/template-project/project/Build.scala @@ -0,0 +1,4 @@ +import sbt._ +import template.TemplateBuild + +object MyAwesomeBuild extends TemplateBuild {} diff --git a/template-project/project/plugins/project/Build.scala b/template-project/project/plugins/project/Build.scala new file mode 100644 index 000000000..3d793bec8 --- /dev/null +++ b/template-project/project/plugins/project/Build.scala @@ -0,0 +1,7 @@ +import sbt._ + +object PluginDef extends Build { + override def projects = Seq(root) + lazy val root = Project("plugins", file(".")) dependsOn(extras) + lazy val extras = uri("git://github.com/paulp/sbt-extras") +} From d72d8808cbdff15abebb10543df32ca1b63c01fc Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 14 Sep 2011 14:16:02 -0400 Subject: [PATCH 063/483] Simple task DSL for those of us who are lazy --- README.md | 20 +++- src/main/scala/Main.scala | 4 +- src/main/scala/SimpleTask.scala | 172 ++++++++++++++++++++++++++++++++ 3 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 src/main/scala/SimpleTask.scala diff --git a/README.md b/README.md index e1075d3fd..f0de17362 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ Current -help output: shows precedence: JAVA_OPTS lowest, command line options highest. -## Template project +# SBT Extra plugin To gain access to the awesome, simply add the following /project/plugins/project/Build.scala file: @@ -111,6 +111,9 @@ To gain access to the awesome, simply add the following /project/plugin lazy val extras = uri("git://github.com/jsuereth/sbt-extras") } + +## Template project + Now to continue the amazement, simply extend the TemplateBuild trait in your project. For example, in your /project/Build.scala file add: @@ -119,4 +122,17 @@ Now to continue the amazement, simply extend the TemplateBuild trait in your pro object MyAwesomeBuild extends TemplateBuild {} -The Template build isn't quite finished. There will most likely be a build.sbt DSL variant that does not require a project scala file. + +There will most likely be a variant that can be used solely from build.sbt. + +## Simple task DSL + +SBT extras defines a simplified task DSL for those who are defining simple tasks that do not need to be relied upon, or you are unsure and can refactor later. Once including the sbt-extra-plugin, all you have to do is place the following in your build.sbt to create tasks: + + simple_task("zomg") is { println("ZOMG") } + +or if you need to depend on other keys: + + simple_task("zomg2") on (name, version) is { (n,v) => println("ZOMG " + n + " = " + v + " !!!!!") } + +The DSL currently supports between 2 and 9 dependencies. The DSL does not allow defining tasks on different configurations, although this will be added shortly. diff --git a/src/main/scala/Main.scala b/src/main/scala/Main.scala index 7727601c7..22c649b04 100644 --- a/src/main/scala/Main.scala +++ b/src/main/scala/Main.scala @@ -5,7 +5,9 @@ import Keys._ import Load.{ BuildStructure, StructureIndex } import scala.collection.{ mutable, immutable } -object SbtExtrasPlugin extends Plugin {} +object SbtExtrasPlugin extends Plugin { + def simple_task(name: String) = sbt.extra.dsl.SimpleTasks.task(name) +} trait SbtCreateConfig { def name: String diff --git a/src/main/scala/SimpleTask.scala b/src/main/scala/SimpleTask.scala new file mode 100644 index 000000000..ea05eaf18 --- /dev/null +++ b/src/main/scala/SimpleTask.scala @@ -0,0 +1,172 @@ +package sbt.extra.dsl + +import sbt._ +import Scoped._ +import Project.{richInitializeTask,richInitialize} + +object SimpleTasks { + final def task(name: String) = new TaskId(name) +} + +/** Represents the new 'id' of a task to define on a project. */ +final class TaskId(name: String) { + /** Creates a Task that has no dependencies. */ + final def is[R: Manifest](f: => R) = + TaskKey[R](name) := f + /*final def on[A1](a: ScopedTaskable[A1]): TaskDepend1[A1] = + new TaskDepend1[A1](name, a)*/ + final def on[A1, A2](a1: ScopedTaskable[A1], a2: ScopedTaskable[A2]): TaskDepend2[A1, A2] = + new TaskDepend2[A1, A2](name, a1, a2) + final def on[A1, A2, A3](a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3]) = + new TaskDepend3[A1, A2, A3](name, a1, a2, a3) + final def on[A1, A2, A3, A4](a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3], + a4: ScopedTaskable[A4]) = + new TaskDepend4[A1, A2, A3, A4](name, a1, a2, a3, a4) + final def on[A1, A2, A3, A4, A5](a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3], + a4: ScopedTaskable[A4], + a5: ScopedTaskable[A5]) = + new TaskDepend5[A1, A2, A3, A4, A5](name, a1, a2, a3, a4, a5) + final def on[A1, A2, A3, A4, A5, A6](a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3], + a4: ScopedTaskable[A4], + a5: ScopedTaskable[A5], + a6: ScopedTaskable[A6]) = + new TaskDepend6[A1, A2, A3, A4, A5, A6](name, a1, a2, a3, a4, a5, a6) + final def on[A1, A2, A3, A4, A5, A6, A7](a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3], + a4: ScopedTaskable[A4], + a5: ScopedTaskable[A5], + a6: ScopedTaskable[A6], + a7: ScopedTaskable[A7]) = + new TaskDepend7[A1, A2, A3, A4, A5, A6, A7](name, a1, a2, a3, a4, a5, a6, a7) + final def on[A1, A2, A3, A4, A5, A6, A7, A8](a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3], + a4: ScopedTaskable[A4], + a5: ScopedTaskable[A5], + a6: ScopedTaskable[A6], + a7: ScopedTaskable[A7], + a8: ScopedTaskable[A8]) = + new TaskDepend8[A1, A2, A3, A4, A5, A6, A7, A8](name, a1, a2, a3, a4, a5, a6, a7, a8) + final def on[A1, A2, A3, A4, A5, A6, A7, A8, A9](a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3], + a4: ScopedTaskable[A4], + a5: ScopedTaskable[A5], + a6: ScopedTaskable[A6], + a7: ScopedTaskable[A7], + a8: ScopedTaskable[A8], + a9: ScopedTaskable[A9]) = + new TaskDepend9[A1, A2, A3, A4, A5, A6, A7, A8, A9](name, a1, a2, a3, a4, a5, a6, a7, a8, a9) +} + +/** Represents a not-yet-defined task that has one dependency */ +/*final class TaskDepend1[A1](name: String, a1: ScopedTaskable[A1]) { + final def is[R: Manifest](f: A1 => R): Setting[Task[R]] = { + TaskKey[R](name) <<= a1 map f + } +}*/ + +/** Represents a not-yet-defined task that has two dependencies */ +final class TaskDepend2[A1, A2](name: String, + a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2]) { + final def is[R: Manifest](f: (A1, A2) => R): Setting[Task[R]] = { + TaskKey[R](name) <<= (a1, a2) map f + } +} +/** Represents a not-yet-defined task that has two dependencies */ +final class TaskDepend3[A1, A2, A3](name: String, + a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3]) { + final def is[R: Manifest](f: (A1, A2, A3) => R): Setting[Task[R]] = { + TaskKey[R](name) <<= (a1, a2, a3) map f + } +} +/** Represents a not-yet-defined task that has two dependencies */ +final class TaskDepend4[A1, A2, A3, A4](name: String, + a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3], + a4: ScopedTaskable[A4]) { + final def is[R: Manifest](f: (A1, A2, A3, A4) => R): Setting[Task[R]] = { + TaskKey[R](name) <<= (a1, a2, a3, a4) map f + } +} +/** Represents a not-yet-defined task that has two dependencies */ +final class TaskDepend5[A1, A2, A3, A4, A5](name: String, + a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3], + a4: ScopedTaskable[A4], + a5: ScopedTaskable[A5]) { + final def is[R: Manifest](f: (A1, A2, A3, A4, A5) => R): Setting[Task[R]] = { + TaskKey[R](name) <<= (a1, a2, a3, a4, a5) map f + } +} +/** Represents a not-yet-defined task that has two dependencies */ +final class TaskDepend6[A1, A2, A3, A4, A5, A6](name: String, + a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3], + a4: ScopedTaskable[A4], + a5: ScopedTaskable[A5], + a6: ScopedTaskable[A6]) { + final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6) => R): Setting[Task[R]] = { + TaskKey[R](name) <<= (a1, a2, a3, a4, a5, a6) map f + } +} +/** Represents a not-yet-defined task that has two dependencies */ +final class TaskDepend7[A1, A2, A3, A4, A5, A6, A7](name: String, + a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3], + a4: ScopedTaskable[A4], + a5: ScopedTaskable[A5], + a6: ScopedTaskable[A6], + a7: ScopedTaskable[A7]) { + final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6, A7) => R): Setting[Task[R]] = { + TaskKey[R](name) <<= (a1, a2, a3, a4, a5, a6, a7) map f + } +} +/** Represents a not-yet-defined task that has two dependencies */ +final class TaskDepend8[A1, A2, A3, A4, A5, A6, A7, A8](name: String, + a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3], + a4: ScopedTaskable[A4], + a5: ScopedTaskable[A5], + a6: ScopedTaskable[A6], + a7: ScopedTaskable[A7], + a8: ScopedTaskable[A8]) { + final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6, A7, A8) => R): Setting[Task[R]] = { + TaskKey[R](name) <<= (a1, a2, a3, a4, a5, a6, a7, a8) map f + } +} +/** Represents a not-yet-defined task that has two dependencies */ +final class TaskDepend9[A1, A2, A3, A4, A5, A6, A7, A8, A9](name: String, + a1: ScopedTaskable[A1], + a2: ScopedTaskable[A2], + a3: ScopedTaskable[A3], + a4: ScopedTaskable[A4], + a5: ScopedTaskable[A5], + a6: ScopedTaskable[A6], + a7: ScopedTaskable[A7], + a8: ScopedTaskable[A8], + a9: ScopedTaskable[A9]) { + final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6, A7, A8, A9) => R): Setting[Task[R]] = { + TaskKey[R](name) <<= (a1, a2, a3, a4, a5, a6, a7, a8, a9) map f + } +} + + + From c38f8ccfc0e76ad098af71bb10975d8d5c2b3c48 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 14 Sep 2011 11:48:41 -0700 Subject: [PATCH 064/483] Added zomg and zomg2 to template-project. --- README.md | 2 +- template-project/build.sbt | 3 +++ template-project/project/Build.scala | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 template-project/build.sbt diff --git a/README.md b/README.md index 4eade7cbc..6d1a02f07 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ Current -help output: To see the plugin in action, including the thrilling custom sbt command "help-names": - cd template-project && ../sbt -sbt-rc help-names + cd template-project && ../sbt -sbt-rc help-names zomg zomg2 The template files are: diff --git a/template-project/build.sbt b/template-project/build.sbt new file mode 100644 index 000000000..38cf37011 --- /dev/null +++ b/template-project/build.sbt @@ -0,0 +1,3 @@ +simple_task("zomg") is { println("ZOMG") } + +simple_task("zomg2") on (name, version) is { (n,v) => println("ZOMG " + n + " = " + v + " !!!!!") } diff --git a/template-project/project/Build.scala b/template-project/project/Build.scala index e10479236..9e4f80e1f 100644 --- a/template-project/project/Build.scala +++ b/template-project/project/Build.scala @@ -1,4 +1,4 @@ import sbt._ import template.TemplateBuild -object MyAwesomeBuild extends TemplateBuild {} +object MyAwesomeBuild extends TemplateBuild { } From 49b3b1defb833881daf74f877d26a2f9f324e750 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 28 Sep 2011 08:52:30 -0700 Subject: [PATCH 065/483] sbt 0.11.0 --- sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbt b/sbt index 2b2be4b0f..13ecb118d 100755 --- a/sbt +++ b/sbt @@ -30,9 +30,9 @@ get_mem_opts () { } # todo - make this dynamic -declare -r sbt_release_version=0.10.1 -declare -r sbt_rc_version=0.11.0-RC1 -declare -r sbt_snapshot_version=0.11.0-SNAPSHOT +declare -r sbt_release_version=0.11.0 +declare -r sbt_rc_version= +declare -r sbt_snapshot_version=0.11.1-SNAPSHOT declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" declare -r default_java_opts="-Dfile.encoding=UTF8" From 9a42fb6f8f9bc46d64d8209d59311e73172dbdc0 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 28 Sep 2011 11:48:17 -0700 Subject: [PATCH 066/483] Added -no-share option for me and that other guy somewhere who might ever use it. --- sbt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sbt b/sbt index 13ecb118d..763ba6b81 100755 --- a/sbt +++ b/sbt @@ -38,6 +38,7 @@ declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ declare -r default_java_opts="-Dfile.encoding=UTF8" declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled" declare -r default_sbt_mem=1536 +declare -r noshare_opts="-Dsbt.global.base=project/.sbt -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" declare -r sbt_opts_file=".sbtopts" declare -r latest_28="2.8.1" declare -r latest_29="2.9.1" @@ -207,6 +208,7 @@ Usage: $script_name [options] -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) -ivy path to local Ivy repository (default: ~/.ivy2) -mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) + -no-share use all local caches; no sharing # sbt version (default: from project/build.properties if present, else latest release) -sbt-version use the specified version of sbt @@ -267,6 +269,7 @@ process_args () -ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;; -mem) sbt_mem="$2"; shift 2 ;; -no-colors) addJava "-Dsbt.log.noformat=true"; shift ;; + -no-share) addJava "$noshare_opts"; shift ;; -sbt-boot) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; -sbt-dir) addJava "-Dsbt.global.base=$2"; shift 2 ;; -debug-inc) addJava "-Dxsbt.inc.debug=true"; shift ;; From c4249308e307cb8d12d711eaaedbe602289275e4 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sat, 1 Oct 2011 22:58:54 +0200 Subject: [PATCH 067/483] Corrects the command line for wget. Without this, wget deposits the launcher in the working directory and pipes zero bytes to the intended location. --- sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbt b/sbt index 763ba6b81..855d33ebf 100755 --- a/sbt +++ b/sbt @@ -176,7 +176,7 @@ download_url () { if which curl >/dev/null; then curl --silent "$url" --output "$jar" elif which wget >/dev/null; then - wget --quiet "$url" > "$jar" + wget --quiet -O "$jar" "$url" fi } && [[ -f "$jar" ]] } From 3d4801a12ada136e5dca3ecfec99bae301e0d979 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 2 Oct 2011 13:02:00 +0200 Subject: [PATCH 068/483] -2.8 uses 2.8.2 --- sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbt b/sbt index 763ba6b81..cd9fbcb1e 100755 --- a/sbt +++ b/sbt @@ -40,7 +40,7 @@ declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled" declare -r default_sbt_mem=1536 declare -r noshare_opts="-Dsbt.global.base=project/.sbt -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" declare -r sbt_opts_file=".sbtopts" -declare -r latest_28="2.8.1" +declare -r latest_28="2.8.2" declare -r latest_29="2.9.1" declare -r latest_210="2.10.0-SNAPSHOT" From 392fba86af2c335d22166f4a5f1a599111277a5e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 3 Oct 2011 09:23:18 -0700 Subject: [PATCH 069/483] Abort if -sbt-rc is given with no RC candidate defined. --- sbt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sbt b/sbt index a9dbead17..561d0b11f 100755 --- a/sbt +++ b/sbt @@ -29,9 +29,15 @@ get_mem_opts () { echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" } +die() { + echo "Aborting: $@" + exit 1 +} + # todo - make this dynamic declare -r sbt_release_version=0.11.0 -declare -r sbt_rc_version= +unset sbt_rc_version +# declare -r sbt_rc_version= declare -r sbt_snapshot_version=0.11.1-SNAPSHOT declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" @@ -275,7 +281,7 @@ process_args () -debug-inc) addJava "-Dxsbt.inc.debug=true"; shift ;; -sbt-create) sbt_create=true; shift ;; - -sbt-rc) sbt_version=$sbt_rc_version; shift ;; + -sbt-rc) [[ -n "$sbt_rc_version" ]] || die "no sbt RC candidate defined."; sbt_version=$sbt_rc_version; shift ;; -sbt-snapshot) addSnapshotRepo ; sbt_version=$sbt_snapshot_version; shift ;; -sbt-jar) sbt_jar="$2"; shift 2 ;; -sbt-version) sbt_version="$2"; shift 2 ;; From a23e748ea70c03c6804bf479eb921eee806076ba Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Fri, 28 Oct 2011 11:21:38 -0400 Subject: [PATCH 070/483] Fixing version for sbt 0.11 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e227a442a..fe69fa2f8 100644 --- a/build.sbt +++ b/build.sbt @@ -4,5 +4,5 @@ name := "sbt-extras-plugin" organization := "org.improving" -version <<= (sbtVersion)("0.1.0-%s".format(_)) +version := "0.1.0" From 4883983afa1965775724464cef1f6afa6db446e2 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Fri, 28 Oct 2011 11:22:28 -0400 Subject: [PATCH 071/483] Adding new DSL for defining settings such they you can't use tasks in a setting definition --- src/main/scala/Main.scala | 1 + src/main/scala/SimpleDsl.scala | 10 ++ src/main/scala/SimpleSetting.scala | 169 +++++++++++++++++++++++++++++ src/main/scala/SimpleTask.scala | 4 - template-project/build.sbt | 4 + 5 files changed, 184 insertions(+), 4 deletions(-) create mode 100644 src/main/scala/SimpleDsl.scala create mode 100644 src/main/scala/SimpleSetting.scala diff --git a/src/main/scala/Main.scala b/src/main/scala/Main.scala index 22c649b04..5a4742427 100644 --- a/src/main/scala/Main.scala +++ b/src/main/scala/Main.scala @@ -7,6 +7,7 @@ import scala.collection.{ mutable, immutable } object SbtExtrasPlugin extends Plugin { def simple_task(name: String) = sbt.extra.dsl.SimpleTasks.task(name) + def simple_setting(name: String) = sbt.extra.dsl.SimpleTasks.setting(name) } trait SbtCreateConfig { diff --git a/src/main/scala/SimpleDsl.scala b/src/main/scala/SimpleDsl.scala new file mode 100644 index 000000000..273b38042 --- /dev/null +++ b/src/main/scala/SimpleDsl.scala @@ -0,0 +1,10 @@ +package sbt.extra.dsl + +import sbt._ +import Scoped._ +import Project.{richInitializeTask,richInitialize} + +object SimpleTasks { + final def task(name: String) = new TaskId(name) + final def setting(name: String) = new SettingId(name) +} diff --git a/src/main/scala/SimpleSetting.scala b/src/main/scala/SimpleSetting.scala new file mode 100644 index 000000000..3b924f6d5 --- /dev/null +++ b/src/main/scala/SimpleSetting.scala @@ -0,0 +1,169 @@ +package sbt.extra.dsl + +import sbt._ +import Scoped._ +import Project._ +import Project.Setting + +/** Represents the new 'id' of a setting to define on a project. */ +final class SettingId(name: String) { + /** Creates a Task that has no dependencies. */ + final def is[R: Manifest](f: => R) = + SettingKey[R](name) := f + final def on[A1](a: Initialize[A1]): SettingDepend1[A1] = + new SettingDepend1[A1](name, a) + final def on[A1, A2](a1: Initialize[A1], a2: Initialize[A2]): SettingDepend2[A1, A2] = + new SettingDepend2[A1, A2](name, a1, a2) + final def on[A1, A2, A3](a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3]) = + new SettingDepend3[A1, A2, A3](name, a1, a2, a3) + final def on[A1, A2, A3, A4](a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3], + a4: Initialize[A4]) = + new SettingDepend4[A1, A2, A3, A4](name, a1, a2, a3, a4) + final def on[A1, A2, A3, A4, A5](a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3], + a4: Initialize[A4], + a5: Initialize[A5]) = + new SettingDepend5[A1, A2, A3, A4, A5](name, a1, a2, a3, a4, a5) + final def on[A1, A2, A3, A4, A5, A6](a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3], + a4: Initialize[A4], + a5: Initialize[A5], + a6: Initialize[A6]) = + new SettingDepend6[A1, A2, A3, A4, A5, A6](name, a1, a2, a3, a4, a5, a6) + final def on[A1, A2, A3, A4, A5, A6, A7](a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3], + a4: Initialize[A4], + a5: Initialize[A5], + a6: Initialize[A6], + a7: Initialize[A7]) = + new SettingDepend7[A1, A2, A3, A4, A5, A6, A7](name, a1, a2, a3, a4, a5, a6, a7) + final def on[A1, A2, A3, A4, A5, A6, A7, A8](a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3], + a4: Initialize[A4], + a5: Initialize[A5], + a6: Initialize[A6], + a7: Initialize[A7], + a8: Initialize[A8]) = + new SettingDepend8[A1, A2, A3, A4, A5, A6, A7, A8](name, a1, a2, a3, a4, a5, a6, a7, a8) + final def on[A1, A2, A3, A4, A5, A6, A7, A8, A9](a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3], + a4: Initialize[A4], + a5: Initialize[A5], + a6: Initialize[A6], + a7: Initialize[A7], + a8: Initialize[A8], + a9: Initialize[A9]) = + new SettingDepend9[A1, A2, A3, A4, A5, A6, A7, A8, A9](name, a1, a2, a3, a4, a5, a6, a7, a8, a9) +} + +/** Represents a not-yet-defined Setting that has one dependency */ +final class SettingDepend1[A1](name: String, a1: Initialize[A1]) { + final def is[R: Manifest](f: A1 => R): Setting[R] = { + SettingKey[R](name) <<= a1 apply f + } +} + +/** Represents a not-yet-defined Setting that has two dependencies */ +final class SettingDepend2[A1, A2](name: String, + a1: Initialize[A1], + a2: Initialize[A2]) { + final def is[R: Manifest](f: (A1, A2) => R): Setting[R] = { + SettingKey[R](name) <<= (a1, a2) apply f + } +} +/** Represents a not-yet-defined Setting that has two dependencies */ +final class SettingDepend3[A1, A2, A3](name: String, + a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3]) { + final def is[R: Manifest](f: (A1, A2, A3) => R): Setting[R] = { + SettingKey[R](name) <<= (a1, a2, a3) apply f + } +} +/** Represents a not-yet-defined Setting that has two dependencies */ +final class SettingDepend4[A1, A2, A3, A4](name: String, + a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3], + a4: Initialize[A4]) { + final def is[R: Manifest](f: (A1, A2, A3, A4) => R): Setting[R] = { + SettingKey[R](name) <<= (a1, a2, a3, a4) apply f + } +} +/** Represents a not-yet-defined Setting that has two dependencies */ +final class SettingDepend5[A1, A2, A3, A4, A5](name: String, + a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3], + a4: Initialize[A4], + a5: Initialize[A5]) { + final def is[R: Manifest](f: (A1, A2, A3, A4, A5) => R): Setting[R] = { + SettingKey[R](name) <<= (a1, a2, a3, a4, a5) apply f + } +} +/** Represents a not-yet-defined Setting that has two dependencies */ +final class SettingDepend6[A1, A2, A3, A4, A5, A6](name: String, + a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3], + a4: Initialize[A4], + a5: Initialize[A5], + a6: Initialize[A6]) { + final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6) => R): Setting[R] = { + SettingKey[R](name) <<= (a1, a2, a3, a4, a5, a6) apply f + } +} +/** Represents a not-yet-defined Setting that has two dependencies */ +final class SettingDepend7[A1, A2, A3, A4, A5, A6, A7](name: String, + a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3], + a4: Initialize[A4], + a5: Initialize[A5], + a6: Initialize[A6], + a7: Initialize[A7]) { + final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6, A7) => R): Setting[R] = { + SettingKey[R](name) <<= (a1, a2, a3, a4, a5, a6, a7) apply f + } +} +/** Represents a not-yet-defined Setting that has two dependencies */ +final class SettingDepend8[A1, A2, A3, A4, A5, A6, A7, A8](name: String, + a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3], + a4: Initialize[A4], + a5: Initialize[A5], + a6: Initialize[A6], + a7: Initialize[A7], + a8: Initialize[A8]) { + final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6, A7, A8) => R): Setting[R] = { + SettingKey[R](name) <<= (a1, a2, a3, a4, a5, a6, a7, a8) apply f + } +} +/** Represents a not-yet-defined Setting that has two dependencies */ +final class SettingDepend9[A1, A2, A3, A4, A5, A6, A7, A8, A9](name: String, + a1: Initialize[A1], + a2: Initialize[A2], + a3: Initialize[A3], + a4: Initialize[A4], + a5: Initialize[A5], + a6: Initialize[A6], + a7: Initialize[A7], + a8: Initialize[A8], + a9: Initialize[A9]) { + final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6, A7, A8, A9) => R): Setting[R] = { + SettingKey[R](name) <<= (a1, a2, a3, a4, a5, a6, a7, a8, a9) apply f + } +} + + + diff --git a/src/main/scala/SimpleTask.scala b/src/main/scala/SimpleTask.scala index ea05eaf18..f823be3a2 100644 --- a/src/main/scala/SimpleTask.scala +++ b/src/main/scala/SimpleTask.scala @@ -4,10 +4,6 @@ import sbt._ import Scoped._ import Project.{richInitializeTask,richInitialize} -object SimpleTasks { - final def task(name: String) = new TaskId(name) -} - /** Represents the new 'id' of a task to define on a project. */ final class TaskId(name: String) { /** Creates a Task that has no dependencies. */ diff --git a/template-project/build.sbt b/template-project/build.sbt index 38cf37011..bb948043e 100644 --- a/template-project/build.sbt +++ b/template-project/build.sbt @@ -1,3 +1,7 @@ +simple_setting("name") is "test-project" + simple_task("zomg") is { println("ZOMG") } simple_task("zomg2") on (name, version) is { (n,v) => println("ZOMG " + n + " = " + v + " !!!!!") } + + From 400ca7ba30188345b7e0779bc6913647818355be Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Fri, 28 Oct 2011 11:30:24 -0400 Subject: [PATCH 072/483] Added simple setting DSL with simple task DSL --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d1a02f07..ded43f787 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ The template files are: The Template build isn't quite finished. There will most likely be a build.sbt DSL variant that does not require a project scala file. -## Simple task DSL +## Simple SBT DSL SBT extras defines a simplified task DSL for those who are defining simple tasks that do not need to be relied upon, or you are unsure and can refactor later. Once including the sbt-extra-plugin, all you have to do is place the following in your build.sbt to create tasks: @@ -124,3 +124,15 @@ or if you need to depend on other keys: simple_task("zomg2") on (name, version) is { (n,v) => println("ZOMG " + n + " = " + v + " !!!!!") } The DSL currently supports between 2 and 9 dependencies. The DSL does not allow defining tasks on different configurations, although this will be added shortly. + +### Simple Setttings + +SBT distinguishes between defining Setting and Tasks through the `apply` and `map` methods. The Simple DSL has no such distinction. Defining a setting is as easy as: + + simple_setting("name") is "project-name" + +Settings can also depend on other settings. + + simple_setting("name") on (version) is { v => "project-name" + v } + +Since a Setting can *only* be defined using other settings, attempting to use a non-setting in the on calls results in a type error. From 521cc31ab92f116115d5a4ddbe9f2381a7114d72 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Fri, 28 Oct 2011 11:40:40 -0400 Subject: [PATCH 073/483] Fixed task definition with 1 dependency --- README.md | 2 +- src/main/scala/SimpleTask.scala | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ded43f787..517ad5dca 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ or if you need to depend on other keys: simple_task("zomg2") on (name, version) is { (n,v) => println("ZOMG " + n + " = " + v + " !!!!!") } -The DSL currently supports between 2 and 9 dependencies. The DSL does not allow defining tasks on different configurations, although this will be added shortly. +The DSL currently supports between 0 and 9 dependencies. The DSL does not allow defining tasks on different configurations, although this will be added shortly. ### Simple Setttings diff --git a/src/main/scala/SimpleTask.scala b/src/main/scala/SimpleTask.scala index f823be3a2..a48e404de 100644 --- a/src/main/scala/SimpleTask.scala +++ b/src/main/scala/SimpleTask.scala @@ -2,15 +2,18 @@ package sbt.extra.dsl import sbt._ import Scoped._ -import Project.{richInitializeTask,richInitialize} +import Project._ +import Project.Setting /** Represents the new 'id' of a task to define on a project. */ final class TaskId(name: String) { /** Creates a Task that has no dependencies. */ final def is[R: Manifest](f: => R) = TaskKey[R](name) := f - /*final def on[A1](a: ScopedTaskable[A1]): TaskDepend1[A1] = - new TaskDepend1[A1](name, a)*/ + final def on[A1](a: Initialize[Task[A1]]): TaskDepend1Task[A1] = + new TaskDepend1Task[A1](name, a) + final def on[A1](a: Initialize[A1]): TaskDepend1Setting[A1] = + new TaskDepend1Setting[A1](name, a) final def on[A1, A2](a1: ScopedTaskable[A1], a2: ScopedTaskable[A2]): TaskDepend2[A1, A2] = new TaskDepend2[A1, A2](name, a1, a2) final def on[A1, A2, A3](a1: ScopedTaskable[A1], @@ -64,12 +67,17 @@ final class TaskId(name: String) { new TaskDepend9[A1, A2, A3, A4, A5, A6, A7, A8, A9](name, a1, a2, a3, a4, a5, a6, a7, a8, a9) } -/** Represents a not-yet-defined task that has one dependency */ -/*final class TaskDepend1[A1](name: String, a1: ScopedTaskable[A1]) { +final class TaskDepend1Setting[A1](name: String, a1: Initialize[A1]) { final def is[R: Manifest](f: A1 => R): Setting[Task[R]] = { TaskKey[R](name) <<= a1 map f } -}*/ +} +/** Represents a not-yet-defined task that has one dependency */ +final class TaskDepend1Task[A1](name: String, a1: Initialize[Task[A1]]) { + final def is[R: Manifest](f: A1 => R): Setting[Task[R]] = { + TaskKey[R](name) <<= a1 map f + } +} /** Represents a not-yet-defined task that has two dependencies */ final class TaskDepend2[A1, A2](name: String, From 0902f8849750250ac7d9f3e753dc17b814ce11d8 Mon Sep 17 00:00:00 2001 From: Seyi Ogunyemi Date: Wed, 9 Nov 2011 05:55:39 +0000 Subject: [PATCH 074/483] IIRC .bashrc is never read for a script unless it's explicitly told to do so & this currently causes an invalid option error on Ubuntu. --- sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbt b/sbt index 561d0b11f..1d95dff19 100755 --- a/sbt +++ b/sbt @@ -1,4 +1,4 @@ -#!/usr/bin/env bash --norc +#!/usr/bin/env bash # # A more capable sbt runner, coincidentally also called sbt. # Author: Paul Phillips From 8665ba0c5f8440632848f39a5ed355bc54782a18 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 8 Nov 2011 19:16:37 +0100 Subject: [PATCH 075/483] sbt 0.11.1 ; -offline. --- sbt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sbt b/sbt index 561d0b11f..180e2b64c 100755 --- a/sbt +++ b/sbt @@ -35,10 +35,10 @@ die() { } # todo - make this dynamic -declare -r sbt_release_version=0.11.0 +declare -r sbt_release_version=0.11.1 unset sbt_rc_version # declare -r sbt_rc_version= -declare -r sbt_snapshot_version=0.11.1-SNAPSHOT +declare -r sbt_snapshot_version=0.11.2-SNAPSHOT declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" declare -r default_java_opts="-Dfile.encoding=UTF8" @@ -215,6 +215,7 @@ Usage: $script_name [options] -ivy path to local Ivy repository (default: ~/.ivy2) -mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) -no-share use all local caches; no sharing + -offline put sbt in offline mode # sbt version (default: from project/build.properties if present, else latest release) -sbt-version use the specified version of sbt @@ -279,6 +280,7 @@ process_args () -sbt-boot) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; -sbt-dir) addJava "-Dsbt.global.base=$2"; shift 2 ;; -debug-inc) addJava "-Dxsbt.inc.debug=true"; shift ;; + -offline) addSbt "set offline := true"; shift ;; -sbt-create) sbt_create=true; shift ;; -sbt-rc) [[ -n "$sbt_rc_version" ]] || die "no sbt RC candidate defined."; sbt_version=$sbt_rc_version; shift ;; From 8cf9fa83be66a5cc26faa0c9f61a09120f0af108 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 28 Nov 2011 17:24:43 -0800 Subject: [PATCH 076/483] Tweaked java_opts, 0.11.2. --- sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbt b/sbt index 180e2b64c..80d78f91d 100755 --- a/sbt +++ b/sbt @@ -35,10 +35,10 @@ die() { } # todo - make this dynamic -declare -r sbt_release_version=0.11.1 +declare -r sbt_release_version=0.11.2 unset sbt_rc_version # declare -r sbt_rc_version= -declare -r sbt_snapshot_version=0.11.2-SNAPSHOT +declare -r sbt_snapshot_version=0.11.3-SNAPSHOT declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" declare -r default_java_opts="-Dfile.encoding=UTF8" @@ -352,9 +352,9 @@ EOM # run sbt execRunner "$java_cmd" \ - ${java_opts} \ ${SBT_OPTS:-$default_sbt_opts} \ $(get_mem_opts $sbt_mem) \ + ${java_opts} \ ${java_args[@]} \ -jar "$sbt_jar" \ "${sbt_commands[@]}" \ From afccc22f280e9a59fec0b62fff7bd660d13fe915 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 5 Dec 2011 14:24:04 -0500 Subject: [PATCH 077/483] Calling a directory .sbt in the project/ directory causes SBT to go into legacy plugin project mode and breaks version resolution. This fixes that issue by calling the directory .sbtboot instead of .sbt. Note: why are .sbtboot and .boot separate? A question for others. --- sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbt b/sbt index 80d78f91d..64bdb5995 100755 --- a/sbt +++ b/sbt @@ -44,7 +44,7 @@ declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ declare -r default_java_opts="-Dfile.encoding=UTF8" declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled" declare -r default_sbt_mem=1536 -declare -r noshare_opts="-Dsbt.global.base=project/.sbt -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" +declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" declare -r sbt_opts_file=".sbtopts" declare -r latest_28="2.8.2" declare -r latest_29="2.9.1" From 0c4df8c2d541e3da8abdb0f7b2b2ee30443bb0c1 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 6 Dec 2011 15:30:52 -0800 Subject: [PATCH 078/483] Jacked up -XX:ReservedCodeCacheSize. --- sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbt b/sbt index e5a953c25..8cf9956a8 100755 --- a/sbt +++ b/sbt @@ -24,7 +24,7 @@ get_mem_opts () { local perm=$(( $mem / 4 )) (( $perm > 256 )) || perm=256 (( $perm < 1024 )) || perm=1024 - local codecache=$(( $perm / 8 )) + local codecache=$(( $perm / 2 )) echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" } From 34fed660220104d82ad12c0c93956f8fdc436ae2 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 28 Nov 2011 18:52:47 -0500 Subject: [PATCH 079/483] First cut at debian packaging. This adds a Debian build section that will create a new .deb file for the sbt script. This includes a new src/debian and src/debian-gzipped directories for placing files that will be included in the distribution on debian. Initial cut at making debian packages --- .gitignore | 4 +- project/build.scala | 7 ++ project/debian.scala | 94 +++++++++++++++++++ .../usr/share/doc/sbt/changelog | 6 ++ .../usr/share/doc/sbt/changelog.Debian | 2 + src/debian-gzipped/usr/share/man/man1/sbt.1 | 92 ++++++++++++++++++ src/debian/usr/share/doc/sbt/copyright | 22 +++++ 7 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 project/build.scala create mode 100644 project/debian.scala create mode 100644 src/debian-gzipped/usr/share/doc/sbt/changelog create mode 100644 src/debian-gzipped/usr/share/doc/sbt/changelog.Debian create mode 100644 src/debian-gzipped/usr/share/man/man1/sbt.1 create mode 100644 src/debian/usr/share/doc/sbt/copyright diff --git a/.gitignore b/.gitignore index 6c23ca894..ebfcd37f5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ lib_managed src_managed /ext .lib -/template-project/project/boot \ No newline at end of file +/template-project/project/boot +*~ + diff --git a/project/build.scala b/project/build.scala new file mode 100644 index 000000000..22e8505c6 --- /dev/null +++ b/project/build.scala @@ -0,0 +1,7 @@ +import sbt._ +import Keys._ + +object SbtExtras extends Build { + // TODO - Detect Debian distribution and enable debian settings for the project. + val root = Project("sbt-extras", file(".")) settings(DebianPkg.settings:_*) +} diff --git a/project/debian.scala b/project/debian.scala new file mode 100644 index 000000000..cdf449ba9 --- /dev/null +++ b/project/debian.scala @@ -0,0 +1,94 @@ +import sbt._ +import Keys._ + +object DebianPkg { + val Debian = config("debian-pkg") + val makeDebianExplodedPackage = TaskKey[File]("make-debian-exploded-package") + val makeZippedPackageSource = TaskKey[Unit]("make-zipped-package-source") + val genControlFile = TaskKey[File]("generate-control-file") + val lintian = TaskKey[Unit]("lintian", "Displays lintian error messages associated with the package") + val showMan = TaskKey[Unit]("show-man", "shows the sbt program man page") + + val settings: Seq[Setting[_]] = Seq( + resourceDirectory in Debian <<= baseDirectory(_ / "src" / "debian"), + resourceDirectory in Debian in makeZippedPackageSource <<= baseDirectory(_ / "src" / "debian-gzipped"), + mappings in Debian <<= resourceDirectory in Debian map { d => (d.*** --- d) x (relativeTo(d)) }, + mappings in Debian in makeZippedPackageSource <<= resourceDirectory in Debian in makeZippedPackageSource map { d => (d.*** --- d) x (relativeTo(d)) }, + // TODO - put sbt-version into the generated sbt script. + mappings in Debian <+= baseDirectory map { dir => (dir / "sbt" -> "usr/bin/sbt") }, + name in Debian := "sbt", + version in Debian <<= (version, sbtVersion) apply { (v, sv) => + sv + "-build-" + (v split "\\." map (_.toInt) dropWhile (_ == 0) map ("%02d" format _) mkString "") + }, + target in Debian <<= (target, name in Debian, version in Debian) apply ((t,n, v) => t / (n +"-"+ v)), + genControlFile <<= (name in Debian, version in Debian, target in Debian) map { + (name, version, dir) => + val cfile = dir / "DEBIAN" / "control" + IO.writer(cfile, ControlFileContent, java.nio.charset.Charset.defaultCharset, false) { o => + val out = new java.io.PrintWriter(o) + out println ("Package: %s" format name) + out println ("Version: %s" format version) + out println ControlFileContent + } + cfile + }, + makeDebianExplodedPackage <<= (mappings in Debian, genControlFile, target in Debian) map { (files, _, dir) => + for((file, target) <- files) { + val tfile = dir / target + if(file.isDirectory) IO.createDirectory(tfile) + else IO.copyFile(file,tfile) + } + dir + }, + makeZippedPackageSource <<= (mappings in Debian in makeZippedPackageSource, target in Debian) map { (files, dir) => + for((file, target) <- files) { + val tfile = dir / target + if(file.isDirectory) IO.createDirectory(tfile) + else { + val zipped = new File(tfile.getAbsolutePath + ".gz") + IO delete zipped + IO.copyFile(file,tfile) + Process(Seq("gzip", "--best", tfile.getAbsolutePath), Some(tfile.getParentFile)).! + } + } + dir + }, + packageBin in Debian <<= (makeDebianExplodedPackage, makeZippedPackageSource, target in Debian, name in Debian, version in Debian) map { (pkgdir, _, tdir, n, v) => + // Assign appropriate permissions + val isDirectory = (_: File).isDirectory + val dirs = (tdir.***).get filter isDirectory + val bins = (tdir / "usr" / "bin" ***).get filterNot isDirectory + val data = (tdir / "usr" / "share" ***).get filterNot isDirectory + val perms = Map("0755" -> (dirs ++ bins), + "0644" -> data) + val commands = for { + (perm, files) <- perms + file <- files + p = Process("chmod " + perm + " " + file.getAbsolutePath) + } p.! + + // Make the package. We put this in fakeroot, so we can build the package with root owning files. + Process(Seq("fakeroot", "--", "dpkg-deb", "--build", pkgdir.getAbsolutePath), Some(tdir)).! + tdir.getParentFile / (n + "-" + v + ".deb") + }, + lintian <<= (packageBin in Debian) map { file => + println("lintian -c " + file.getName + " on " + file.getParentFile.getAbsolutePath) + Process(Seq("lintian", "-c", "-v", file.getName), Some(file.getParentFile)).! + }, + showMan <<= (resourceDirectory in Debian in makeZippedPackageSource) map { dir => + Process("groff -man -Tascii " + (dir / "usr" / "share" / "man" / "man1" / "sbt.1").getAbsolutePath).! + } + ) + + // TODO - Use default-jre-headless? + final val ControlFileContent = """Section: java +Priority: optional +Architecture: all +Depends: curl, java2-runtime, bash (>= 2.05a-11) +Recommends: git +Maintainer: Josh Suereth +Description: Simple Build Tool + This script provides a native way to run the Simple Build Tool, + a build tool for Scala software, also called SBT. +""" +} diff --git a/src/debian-gzipped/usr/share/doc/sbt/changelog b/src/debian-gzipped/usr/share/doc/sbt/changelog new file mode 100644 index 000000000..bc29d5d2b --- /dev/null +++ b/src/debian-gzipped/usr/share/doc/sbt/changelog @@ -0,0 +1,6 @@ + +sbt (0.11.2-build-0100) + + * First debian package release + + -- Joshua Suereth 2011-11-29 diff --git a/src/debian-gzipped/usr/share/doc/sbt/changelog.Debian b/src/debian-gzipped/usr/share/doc/sbt/changelog.Debian new file mode 100644 index 000000000..28165718b --- /dev/null +++ b/src/debian-gzipped/usr/share/doc/sbt/changelog.Debian @@ -0,0 +1,2 @@ +sbt Debian maintainer and upstream author are identical. +Therefore see also normal changelog file for Debian changes. diff --git a/src/debian-gzipped/usr/share/man/man1/sbt.1 b/src/debian-gzipped/usr/share/man/man1/sbt.1 new file mode 100644 index 000000000..9c9615c6d --- /dev/null +++ b/src/debian-gzipped/usr/share/man/man1/sbt.1 @@ -0,0 +1,92 @@ +.\" Process this file with +.\" groff -man -Tascii sbt.1 +.\" +.TH SBT 1 "NOVEMBER 2011" Linux "User Manuals" +.SH NAME +sbt \- Simple Build Tool +.SH SYNOPSIS +.B sbt [-h] [-sbt-version +.I sbt-version +.B ] +.I +.B ... +.SH DESCRIPTION +.B sbt +Runs the Simple Build Tool using the currently installed +.BR java (1) +The current directory is assumed to be the project. +.SH OPTIONS +.IP -h +Show help options. +.IP "-verbose | -v" +turn up the noise +.IP "-debug or -d" +set sbt log level to debug +.IP -no-colors +disable ANSI color codes +.IP -sbt-create +start sbt even if current directory contains no sbt project +.IP "-sbt-dir " +path to global settings/plugins directory (default: ~/.sbt) +.IP "-sbt-boot " +path to shared boot directory (default: ~/.sbt/boot in 0.11 series) +.IP "-ivy " +path to local Ivy repository (default: ~/.ivy2) +.IP "-mem " +set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) +.IP "-no-share" +use all local caches; no sharing +.IP -offline +put sbt in offline mode +.SH SBT Version Options +.IP "-sbt-version " +Use the alternate system wide +.I sbt-version +The Simple Build Tool version to use. This script will +download necessary versions using the +.BR curl (1) +tool. +.IP "-sbt-jar " +use the specified jar as the sbt launcher +.IP "-sbt-rc" +use an RC version of sbt +.IP -sbt-snapshot +use a snapshot version of sbt +.SH Scala Options +.IP -28 +use latest 2.8.x Scala release +.IP -29 +use latest 2.9.x release +.IP -210 +use latest 2.10.x release +.IP "-scala-home " +use the scala build at the specified directory +.IP "-scala-version " +use the specified version of scala +.SH Java Options +.IP "-java-home " +alternate JAVA_HOME +.IP "-Dkey=val" +pass -Dkey=val directly to the java runtime +.IP -J-X +pass option -X directly to the java runtime (-J is stripped) +.SH FILES +.I ~/.sbt +.RS +The user configuration file. +.RE +.I ".sbtopts" +.RS +If this file exists in the sbt root, it is prepended to the +runner args. +.SH ENVIRONMENT +.IP JAVAOPTS +If non-null a set of arguments passed to java. +.IP SBTOPTS +environment variable, if unset uses "$default_sbt_opts". +.SH EXAMPLES +Most users of this script will only have to call "sbt" on the command line. +.SH AUTHOR +Paul Phillips + + diff --git a/src/debian/usr/share/doc/sbt/copyright b/src/debian/usr/share/doc/sbt/copyright new file mode 100644 index 000000000..4464f3ae7 --- /dev/null +++ b/src/debian/usr/share/doc/sbt/copyright @@ -0,0 +1,22 @@ + +sbt + +Copyright: Typesafe, Inc. + +2011-11-28 + +The home page of sbt package is at: +http://github.com/paulp/sbt-extras + +The entire code base may be distributed under the terms of the BSD license, which appears immediately below. + +Copyright (c) 2011, Typesafe, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From 57dd8bc0ac0fa91031ee8efabe6128e514bccfa4 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 6 Dec 2011 22:37:02 -0500 Subject: [PATCH 080/483] Added a default config file. Added an /etc/sbt/sbtopts file that contains defaults. Added a hook to the sbt script to pull in from /etc. Allowed comments in sbtopts configuration. --- project/debian.scala | 2 +- sbt | 10 ++++++-- src/debian/etc/sbt/sbtopts | 49 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 src/debian/etc/sbt/sbtopts diff --git a/project/debian.scala b/project/debian.scala index cdf449ba9..bc41b93a3 100644 --- a/project/debian.scala +++ b/project/debian.scala @@ -84,7 +84,7 @@ object DebianPkg { final val ControlFileContent = """Section: java Priority: optional Architecture: all -Depends: curl, java2-runtime, bash (>= 2.05a-11) +Depends: curl, java2-runtime, bash, sed Recommends: git Maintainer: Josh Suereth Description: Simple Build Tool diff --git a/sbt b/sbt index 8cf9956a8..794707621 100755 --- a/sbt +++ b/sbt @@ -46,6 +46,7 @@ declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled" declare -r default_sbt_mem=1536 declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" declare -r sbt_opts_file=".sbtopts" +declare -r etc_sbt_opts_file="/etc/sbt/sbtopts" declare -r latest_28="2.8.2" declare -r latest_29="2.9.1" declare -r latest_210="2.10.0-SNAPSHOT" @@ -309,8 +310,13 @@ process_args () } } -# if .sbtopts exists, prepend its contents to $@ so it can be processed by this runner -[[ -f "$sbt_opts_file" ]] && set -- $(cat "$sbt_opts_file") "$@" +loadConfigFile() { + cat "$1" | sed '/^\#/d' +} + +# if sbtopts files exist, prepend their contents to $@ so it can be processed by this runner +[[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@" +[[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@" # process the combined args, then reset "$@" to the residuals process_args "$@" diff --git a/src/debian/etc/sbt/sbtopts b/src/debian/etc/sbt/sbtopts new file mode 100644 index 000000000..8373b437c --- /dev/null +++ b/src/debian/etc/sbt/sbtopts @@ -0,0 +1,49 @@ +# ------------------------------------------------ # +# The SBT Configuration file. # +# ------------------------------------------------ # + + +# Disable ANSI color codes +# +#-no-colors + +# Starts sbt even if the current directory contains no sbt project. +# +-sbt-create + +# Path to global settings/plugins directory (default: ~/.sbt) +# +#-sbt-dir /etc/sbt + +# Path to shared boot directory (default: ~/.sbt/boot in 0.11 series) +# +#-sbt-boot ~/.sbt/boot + +# Path to local Ivy repository (default: ~/.ivy2) +# +#-ivy ~/.ivy2 + +# set memory options +# +#-mem + +# Use local caches for projects, no sharing. +# +#-no-share + +# Put SBT in offline mode. +# +#-offline + +# Sets the SBT version to use. +#-sbt-version 0.11.2 + +# Scala version (default: latest release) +# +#-scala-home +#-scala-version + +# java version (default: java from PATH, currently $(java -version |& grep version)) +# +#-java-home + From 7574d35868d1ccbf76ba7e67eba158d00bd0dd91 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 6 Dec 2011 22:52:07 -0500 Subject: [PATCH 081/483] Moved downloads to user-owned dir. Sbt launch jars are now downloaded to ~/.sbt/.lib to ensure that the location is writeable by the user. This could still be a faulty assumption, but we'll try it anyway. --- sbt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sbt b/sbt index 794707621..b17417951 100755 --- a/sbt +++ b/sbt @@ -29,6 +29,10 @@ get_mem_opts () { echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" } +is_owned_by_user () { + [[ "$(stat --printf='%U' $1)" == "$(USER)" ]] && { echo "OK" ; return; } +} + die() { echo "Aborting: $@" exit 1 @@ -52,7 +56,11 @@ declare -r latest_29="2.9.1" declare -r latest_210="2.10.0-SNAPSHOT" declare -r script_path=$(get_script_path "$BASH_SOURCE") -declare -r script_dir="$(dirname $script_path)" +if test -z "$HOME"; then + declare -r script_dir="$(dirname $script_path)" +else + declare -r script_dir="$HOME/.sbt" +fi declare -r script_name="$(basename $script_path)" declare java_cmd=java From 211ffa3e3b5633e76972f7a6c5a3027ba0e6bc21 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 6 Dec 2011 23:00:28 -0500 Subject: [PATCH 082/483] Adding handy -jvm-debug option. -jvm-debug option enabled socket-based debugging of SBT via a specified port. This works wonders when used with the console task on a project. --- sbt | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sbt b/sbt index 8cf9956a8..0c2676589 100755 --- a/sbt +++ b/sbt @@ -205,17 +205,18 @@ usage () { cat < path to global settings/plugins directory (default: ~/.sbt) - -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) - -ivy path to local Ivy repository (default: ~/.ivy2) - -mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) - -no-share use all local caches; no sharing - -offline put sbt in offline mode + -h | -help print this message + -v | -verbose this runner is chattier + -d | -debug set sbt log level to debug + -no-colors disable ANSI color codes + -sbt-create start sbt even if current directory contains no sbt project + -sbt-dir path to global settings/plugins directory (default: ~/.sbt) + -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) + -ivy path to local Ivy repository (default: ~/.ivy2) + -mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) + -no-share use all local caches; no sharing + -offline put sbt in offline mode + -jvm-debug Turn on JVM debugging, open at the given port. # sbt version (default: from project/build.properties if present, else latest release) -sbt-version use the specified version of sbt @@ -281,6 +282,7 @@ process_args () -sbt-dir) addJava "-Dsbt.global.base=$2"; shift 2 ;; -debug-inc) addJava "-Dxsbt.inc.debug=true"; shift ;; -offline) addSbt "set offline := true"; shift ;; + -jvm-debug) addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$2"; shift 2 ;; -sbt-create) sbt_create=true; shift ;; -sbt-rc) [[ -n "$sbt_rc_version" ]] || die "no sbt RC candidate defined."; sbt_version=$sbt_rc_version; shift ;; From a4ea6b3ce82c99bf6a9c55799f8e20e43a2d6087 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 7 Dec 2011 13:15:31 -0800 Subject: [PATCH 083/483] Fighting bitrot. Updated readme, small polishings. --- README.md | 94 ++++++++++++++++++++++--------------------------------- sbt | 8 +++-- 2 files changed, 43 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 517ad5dca..6646dfc6a 100644 --- a/README.md +++ b/README.md @@ -2,76 +2,57 @@ sbt: the rebel cut ================== An alternative script for running [sbt](https://github.com/harrah/xsbt). -It works with sbt 0.7x projects as well as 0.10+. If you're in an sbt -project directory, the runner will figure out the versions of sbt -and scala required by the project and download them if necessary. +It works with sbt 0.7.x projects as well as 0.10+. If you're in an sbt +project directory, the runner will figure out the versions of sbt and +scala required by the project and download them if necessary. -There's also a template project sbt coming together, but it's unfinished. -See below for how to pull the template project in as a plugin. -However the runner is quite useful already. +Sample usage: create a new project using a snapshot version of sbt as +well as a snapshot version of scala, then run the sbt "about" command. -Here's a sample use of the runner: it creates a new project using a -snapshot version of sbt as well as a snapshot version of scala, then -runs the sbt "about" command. - - % sbt -d -sbt-snapshot -210 -sbt-create about + % sbt -v -sbt-snapshot -210 -sbt-create about + Detected sbt version 0.11.3-SNAPSHOT + sbt snapshot is 0.11.3-20111207-052114 # Executing command line: java - -Xss2m - -Xms256M - -Xmx1536M - -XX:MaxPermSize=256M -XX:+CMSClassUnloadingEnabled - -XX:MaxPermSize=512m - -Xmx2g - -Xss2m + -Xms1536m + -Xmx1536m + -XX:MaxPermSize=384m + -XX:ReservedCodeCacheSize=192m + -Dfile.encoding=UTF8 -jar - /r/sbt-extras/.lib/0.11.0-20110825-052147/sbt-launch.jar - "set logLevel in Global := Level.Debug" + /r/sbt-extras/.lib/0.11.3-SNAPSHOT/sbt-launch.jar + "set resolvers in ThisBuild += ScalaToolsSnapshots" "++ 2.10.0-SNAPSHOT" - "iflast shell" about - Getting net.java.dev.jna jna 3.2.3 ... - :: retrieving :: org.scala-tools.sbt#boot-app - confs: [default] - 1 artifacts copied, 0 already retrieved (838kB/12ms) - Getting Scala 2.9.1.RC4 (for sbt)... - :: retrieving :: org.scala-tools.sbt#boot-scala - confs: [default] - 4 artifacts copied, 0 already retrieved (19939kB/32ms) - Getting org.scala-tools.sbt sbt_2.9.1.RC4 0.11.0-20110825-052147 ... - :: retrieving :: org.scala-tools.sbt#boot-app - confs: [default] - 38 artifacts copied, 0 already retrieved (6948kB/45ms) - [info] Set current project to default-30ae78 (in build file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/) + [info] Loading global plugins from /Users/paulp/.sbt/plugins + [info] Set current project to default-71999b (in build file:/Users/paulp/Desktop/new/) [info] Reapplying settings... - [info] Set current project to default-30ae78 (in build file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/) + [info] Set current project to default-71999b (in build file:/Users/paulp/Desktop/new/) Setting version to 2.10.0-SNAPSHOT - [info] Set current project to default-30ae78 (in build file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/) - Getting Scala 2.10.0-SNAPSHOT ... - :: retrieving :: org.scala-tools.sbt#boot-scala - confs: [default] - 4 artifacts copied, 0 already retrieved (20650kB/58ms) - [info] This is sbt 0.11.0-20110825-052147 - [info] The current project is {file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/}default-30ae78 + [info] Set current project to default-71999b (in build file:/Users/paulp/Desktop/new/) + [info] This is sbt 0.11.3-20111207-052114 + [info] The current project is {file:/Users/paulp/Desktop/new/}default-71999b [info] The current project is built against Scala 2.10.0-SNAPSHOT - [info] sbt, sbt plugins, and build definitions are using Scala 2.9.1.RC4 - [info] All logging output for this session is available at /var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/sbt8625229869994477318.log - + [info] sbt, sbt plugins, and build definitions are using Scala 2.9.1 Current -help output: Usage: sbt [options] - -h | -help print this message - -v | -verbose this runner is chattier - -d | -debug set sbt log level to debug - -no-colors disable ANSI color codes - -sbt-create start sbt even if current directory contains no sbt project - -sbt-dir path to global settings/plugins directory (default: ~/.sbt) - -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) - -ivy path to local Ivy repository (default: ~/.ivy2) + -h | -help print this message + -v | -verbose this runner is chattier + -d | -debug set sbt log level to debug + -no-colors disable ANSI color codes + -sbt-create start sbt even if current directory contains no sbt project + -sbt-dir path to global settings/plugins directory (default: ~/.sbt) + -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) + -ivy path to local Ivy repository (default: ~/.ivy2) + -mem set memory options (default: 1536, which is -Xms1536m -Xmx1536m -XX:MaxPermSize=384m -XX:ReservedCodeCacheSize=192m) + -no-share use all local caches; no sharing + -offline put sbt in offline mode + -jvm-debug Turn on JVM debugging, open at the given port. # sbt version (default: from project/build.properties if present, else latest release) -sbt-version use the specified version of sbt @@ -80,18 +61,18 @@ Current -help output: -sbt-snapshot use a snapshot version of sbt # scala version (default: latest release) - -28 use 2.8.1 + -28 use 2.8.2 -29 use 2.9.1 -210 use 2.10.0-SNAPSHOT -scala-home use the scala build at the specified directory -scala-version use the specified version of scala - # java version (default: java from PATH, currently java version "1.6.0_26") + # java version (default: java from PATH, currently java version "1.6.0_29") -java-home alternate JAVA_HOME # jvm options and output control JAVA_OPTS environment variable, if unset uses "-Dfile.encoding=UTF8" - SBT_OPTS environment variable, if unset uses "-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xms1536m -Xmx1536m -Xss2m" + SBT_OPTS environment variable, if unset uses "-XX:+CMSClassUnloadingEnabled" .sbtopts if this file exists in the sbt root, it is prepended to the runner args -Dkey=val pass -Dkey=val directly to the java runtime -J-X pass option -X directly to the java runtime (-J is stripped) @@ -99,7 +80,6 @@ Current -help output: In the case of duplicated or conflicting options, the order above shows precedence: JAVA_OPTS lowest, command line options highest. - ## SBT Extra plugin To see the plugin in action, including the thrilling custom sbt command "help-names": diff --git a/sbt b/sbt index 8cf9956a8..9bea1e4a1 100755 --- a/sbt +++ b/sbt @@ -109,9 +109,12 @@ execRunner () { echoerr () { echo 1>&2 "$@" } -dlog () { +vlog () { [[ $verbose || $debug ]] && echoerr "$@" } +dlog () { + [[ $debug ]] && echoerr "$@" +} sbtjar_07_url () { echo "http://simple-build-tool.googlecode.com/files/sbt-launch-${1}.jar" @@ -260,8 +263,9 @@ addResidual () { addResolver () { addSbt "set resolvers in ThisBuild += $1" } +unset addedSnapshotRepo addSnapshotRepo () { - addResolver "ScalaToolsSnapshots" + [[ -n "$addedSnapshotRepo" ]] || addResolver "ScalaToolsSnapshots" && addedSnapshotRepo=true } process_args () From 230a729c053b5c5d4e11e8d21e8a03584968d0e8 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 7 Dec 2011 13:36:21 -0800 Subject: [PATCH 084/483] More robust against missing arguments. After watching -jvm-debug hang and scratching my head, added defense against missing mandatory args. --- sbt | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/sbt b/sbt index 7f0e0d58f..0f91c3de1 100755 --- a/sbt +++ b/sbt @@ -268,9 +268,18 @@ unset addedSnapshotRepo addSnapshotRepo () { [[ -n "$addedSnapshotRepo" ]] || addResolver "ScalaToolsSnapshots" && addedSnapshotRepo=true } +addDebugger () { + addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" +} process_args () { + require_arg () { + if [[ $1 -lt 2 ]]; then + echoerr "$2 requires argument: $3" + exit 1 + fi + } while [[ $# -gt 0 ]]; do case "$1" in -h|-help) usage; exit 1 ;; @@ -278,24 +287,24 @@ process_args () -d|-debug) debug=1; shift ;; # -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload ; shift ;; - -ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;; - -mem) sbt_mem="$2"; shift 2 ;; + -ivy) require_arg $# "$1" path && addJava "-Dsbt.ivy.home=$2"; shift 2 ;; + -mem) require_arg $# "$1" integer && sbt_mem="$2"; shift 2 ;; -no-colors) addJava "-Dsbt.log.noformat=true"; shift ;; -no-share) addJava "$noshare_opts"; shift ;; - -sbt-boot) addJava "-Dsbt.boot.directory=$2"; shift 2 ;; - -sbt-dir) addJava "-Dsbt.global.base=$2"; shift 2 ;; + -sbt-boot) require_arg $# "$1" path && addJava "-Dsbt.boot.directory=$2"; shift 2 ;; + -sbt-dir) require_arg $# "$1" path && addJava "-Dsbt.global.base=$2"; shift 2 ;; -debug-inc) addJava "-Dxsbt.inc.debug=true"; shift ;; -offline) addSbt "set offline := true"; shift ;; - -jvm-debug) addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$2"; shift 2 ;; + -jvm-debug) require_arg $# "$1" port && addDebugger $2 && shift 2 ;; -sbt-create) sbt_create=true; shift ;; -sbt-rc) [[ -n "$sbt_rc_version" ]] || die "no sbt RC candidate defined."; sbt_version=$sbt_rc_version; shift ;; -sbt-snapshot) addSnapshotRepo ; sbt_version=$sbt_snapshot_version; shift ;; - -sbt-jar) sbt_jar="$2"; shift 2 ;; - -sbt-version) sbt_version="$2"; shift 2 ;; - -scala-version) addSbt "++ $2"; shift 2 ;; - -scala-home) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; - -java-home) java_cmd="$2/bin/java"; shift 2 ;; + -sbt-jar) require_arg $# "$1" path && sbt_jar="$2"; shift 2 ;; + -sbt-version) require_arg $# "$1" version && sbt_version="$2"; shift 2 ;; + -scala-version) require_arg $# "$1" version && addSbt "++ $2"; shift 2 ;; + -scala-home) require_arg $# "$1" path && addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; + -java-home) require_arg $# "$1" path && java_cmd="$2/bin/java"; shift 2 ;; -D*) addJava "$1"; shift ;; -J*) addJava "${1:2}"; shift ;; From 7472c2f603cc9a2e19d933117c9fabc5b03ad82a Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 7 Dec 2011 13:53:15 -0800 Subject: [PATCH 085/483] Reworked argument code. --- sbt | 61 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/sbt b/sbt index 0f91c3de1..d61bafc95 100755 --- a/sbt +++ b/sbt @@ -275,44 +275,47 @@ addDebugger () { process_args () { require_arg () { - if [[ $1 -lt 2 ]]; then - echoerr "$2 requires argument: $3" - exit 1 + local type="$1" + local opt="$2" + local arg="$3" + + if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then + die "$opt requires <$type> argument" fi } while [[ $# -gt 0 ]]; do case "$1" in -h|-help) usage; exit 1 ;; - -v|-verbose) verbose=1; shift ;; - -d|-debug) debug=1; shift ;; - # -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload ; shift ;; + -v|-verbose) verbose=1 && shift ;; + -d|-debug) debug=1 && shift ;; + # -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload && shift ;; - -ivy) require_arg $# "$1" path && addJava "-Dsbt.ivy.home=$2"; shift 2 ;; - -mem) require_arg $# "$1" integer && sbt_mem="$2"; shift 2 ;; - -no-colors) addJava "-Dsbt.log.noformat=true"; shift ;; - -no-share) addJava "$noshare_opts"; shift ;; - -sbt-boot) require_arg $# "$1" path && addJava "-Dsbt.boot.directory=$2"; shift 2 ;; - -sbt-dir) require_arg $# "$1" path && addJava "-Dsbt.global.base=$2"; shift 2 ;; - -debug-inc) addJava "-Dxsbt.inc.debug=true"; shift ;; - -offline) addSbt "set offline := true"; shift ;; - -jvm-debug) require_arg $# "$1" port && addDebugger $2 && shift 2 ;; + -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; + -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; + -no-colors) addJava "-Dsbt.log.noformat=true" && shift ;; + -no-share) addJava "$noshare_opts" && shift ;; + -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; + -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;; + -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; + -offline) addSbt "set offline := true" && shift ;; + -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; - -sbt-create) sbt_create=true; shift ;; - -sbt-rc) [[ -n "$sbt_rc_version" ]] || die "no sbt RC candidate defined."; sbt_version=$sbt_rc_version; shift ;; - -sbt-snapshot) addSnapshotRepo ; sbt_version=$sbt_snapshot_version; shift ;; - -sbt-jar) require_arg $# "$1" path && sbt_jar="$2"; shift 2 ;; - -sbt-version) require_arg $# "$1" version && sbt_version="$2"; shift 2 ;; - -scala-version) require_arg $# "$1" version && addSbt "++ $2"; shift 2 ;; - -scala-home) require_arg $# "$1" path && addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;; - -java-home) require_arg $# "$1" path && java_cmd="$2/bin/java"; shift 2 ;; + -sbt-create) sbt_create=true && shift ;; + -sbt-rc) [[ -n "$sbt_rc_version" ]] || die "no sbt RC candidate defined."; sbt_version=$sbt_rc_version && shift ;; + -sbt-snapshot) addSnapshotRepo ; sbt_version=$sbt_snapshot_version && shift ;; + -sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;; + -sbt-version) require_arg version "$1" "$2" && sbt_version="$2" && shift 2 ;; + -scala-version) require_arg version "$1" "$2" && addSbt "++ $2" && shift 2 ;; + -scala-home) require_arg path "$1" "$2" && addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))" && shift 2 ;; + -java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;; - -D*) addJava "$1"; shift ;; - -J*) addJava "${1:2}"; shift ;; - -28) addSbt "++ $latest_28"; shift ;; - -29) addSbt "++ $latest_29"; shift ;; - -210) addSnapshotRepo ; addSbt "++ $latest_210"; shift ;; + -D*) addJava "$1" && shift ;; + -J*) addJava "${1:2}" && shift ;; + -28) addSbt "++ $latest_28" && shift ;; + -29) addSbt "++ $latest_29" && shift ;; + -210) addSnapshotRepo ; addSbt "++ $latest_210" && shift ;; - *) addResidual "$1"; shift ;; + *) addResidual "$1" && shift ;; esac done From 0afdf8cd48597f943ee797485ca8e6566358728e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 9 Dec 2011 23:28:09 -0800 Subject: [PATCH 086/483] Added -S option. Analogous to -J, passes an argument to scalac (by way of adding it to sbt's scalacOptions.) Example, sbt -S-Xlint . --- sbt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sbt b/sbt index d61bafc95..210f28c81 100755 --- a/sbt +++ b/sbt @@ -66,6 +66,7 @@ unset verbose debug # pull -J and -D options to give to java. declare -a residual_args declare -a java_args +declare -a scalac_args declare -a sbt_commands build_props_sbt () { @@ -243,6 +244,7 @@ Usage: $script_name [options] .sbtopts if this file exists in the sbt root, it is prepended to the runner args -Dkey=val pass -Dkey=val directly to the java runtime -J-X pass option -X directly to the java runtime (-J is stripped) + -S-X add -X to sbt's scalacOptions (-J is stripped) In the case of duplicated or conflicting options, the order above shows precedence: JAVA_OPTS lowest, command line options highest. @@ -257,6 +259,10 @@ addSbt () { dlog "[addSbt] arg = '$1'" sbt_commands=( "${sbt_commands[@]}" "$1" ) } +addScalac () { + dlog "[addScalac] arg = '$1'" + scalac_args=( "${scalac_args[@]}" "$1" ) +} addResidual () { dlog "[residual] arg = '$1'" residual_args=( "${residual_args[@]}" "$1" ) @@ -311,6 +317,7 @@ process_args () -D*) addJava "$1" && shift ;; -J*) addJava "${1:2}" && shift ;; + -S*) addScalac "${1:2}" && shift ;; -28) addSbt "++ $latest_28" && shift ;; -29) addSbt "++ $latest_29" && shift ;; -210) addSnapshotRepo ; addSbt "++ $latest_210" && shift ;; @@ -335,6 +342,9 @@ process_args "$@" set -- "${residual_args[@]}" argumentCount=$# +# set scalacOptions if we were given any -S opts +[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[@]}\"" + # figure out the version [[ "$sbt_version" ]] || sbt_version=$(build_props_sbt) [[ "$sbt_version" = *-SNAPSHOT* || "$sbt_version" = *-RC* ]] && sbt_snapshot=1 From 1776f10a5caf6eaa15f558a465ecf25f34e276f0 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 19 Dec 2011 21:15:10 -0500 Subject: [PATCH 087/483] Test migration to a dedicated packaging plugin. --- project/debian.scala | 110 +++++------------- project/project/plugins.scala | 9 ++ .../usr/share/doc/sbt/changelog.Debian | 2 - .../usr/share/doc/sbt => debian}/changelog | 0 src/linux/usr/share/doc/sbt/copyright | 22 ++++ .../usr/share/man/man1/sbt.1 | 0 6 files changed, 57 insertions(+), 86 deletions(-) create mode 100644 project/project/plugins.scala delete mode 100644 src/debian-gzipped/usr/share/doc/sbt/changelog.Debian rename src/{debian-gzipped/usr/share/doc/sbt => debian}/changelog (100%) create mode 100644 src/linux/usr/share/doc/sbt/copyright rename src/{debian-gzipped => linux}/usr/share/man/man1/sbt.1 (100%) diff --git a/project/debian.scala b/project/debian.scala index cdf449ba9..bf4ee32ac 100644 --- a/project/debian.scala +++ b/project/debian.scala @@ -1,94 +1,36 @@ import sbt._ -import Keys._ +import com.typesafe.packager.debian.DebianPlugin._ +import com.typesafe.packager.linux.{LinuxPackageMapping, LinuxFileMetaData} +import com.typesafe.packager.debian.Keys._ +import sbt.Keys.{baseDirectory,sbtVersion,sourceDirectory} object DebianPkg { - val Debian = config("debian-pkg") - val makeDebianExplodedPackage = TaskKey[File]("make-debian-exploded-package") - val makeZippedPackageSource = TaskKey[Unit]("make-zipped-package-source") - val genControlFile = TaskKey[File]("generate-control-file") - val lintian = TaskKey[Unit]("lintian", "Displays lintian error messages associated with the package") - val showMan = TaskKey[Unit]("show-man", "shows the sbt program man page") - - val settings: Seq[Setting[_]] = Seq( - resourceDirectory in Debian <<= baseDirectory(_ / "src" / "debian"), - resourceDirectory in Debian in makeZippedPackageSource <<= baseDirectory(_ / "src" / "debian-gzipped"), - mappings in Debian <<= resourceDirectory in Debian map { d => (d.*** --- d) x (relativeTo(d)) }, - mappings in Debian in makeZippedPackageSource <<= resourceDirectory in Debian in makeZippedPackageSource map { d => (d.*** --- d) x (relativeTo(d)) }, - // TODO - put sbt-version into the generated sbt script. - mappings in Debian <+= baseDirectory map { dir => (dir / "sbt" -> "usr/bin/sbt") }, + + val settings: Seq[Setting[_]] = debianSettings ++ Seq( + maintainer in Debian := "Josh Suereth ", name in Debian := "sbt", version in Debian <<= (version, sbtVersion) apply { (v, sv) => - sv + "-build-" + (v split "\\." map (_.toInt) dropWhile (_ == 0) map ("%02d" format _) mkString "") + sv + "-build-" + (v split "\\." map (_.toInt) dropWhile (_ == 0) map ("%02d" format _) mkString "") }, - target in Debian <<= (target, name in Debian, version in Debian) apply ((t,n, v) => t / (n +"-"+ v)), - genControlFile <<= (name in Debian, version in Debian, target in Debian) map { - (name, version, dir) => - val cfile = dir / "DEBIAN" / "control" - IO.writer(cfile, ControlFileContent, java.nio.charset.Charset.defaultCharset, false) { o => - val out = new java.io.PrintWriter(o) - out println ("Package: %s" format name) - out println ("Version: %s" format version) - out println ControlFileContent - } - cfile + debianPackageDependencies in Debian ++= Seq("curl", "java2-runtime", "bash (>= 2.05a-11)"), + debianPackageRecommends in Debian += "git", + packageDescription in Debian := """Simple Build Tool + This script provides a native way to run the Simple Build Tool, + a build tool for Scala software, also called SBT.""", + linuxPackageMappings in Debian <+= (baseDirectory) map { bd => + (packageForDebian((bd / "sbt") -> "usr/bin/sbt") + withUser "root" withGroup "root" withPerms "0755") }, - makeDebianExplodedPackage <<= (mappings in Debian, genControlFile, target in Debian) map { (files, _, dir) => - for((file, target) <- files) { - val tfile = dir / target - if(file.isDirectory) IO.createDirectory(tfile) - else IO.copyFile(file,tfile) - } - dir - }, - makeZippedPackageSource <<= (mappings in Debian in makeZippedPackageSource, target in Debian) map { (files, dir) => - for((file, target) <- files) { - val tfile = dir / target - if(file.isDirectory) IO.createDirectory(tfile) - else { - val zipped = new File(tfile.getAbsolutePath + ".gz") - IO delete zipped - IO.copyFile(file,tfile) - Process(Seq("gzip", "--best", tfile.getAbsolutePath), Some(tfile.getParentFile)).! - } - } - dir - }, - packageBin in Debian <<= (makeDebianExplodedPackage, makeZippedPackageSource, target in Debian, name in Debian, version in Debian) map { (pkgdir, _, tdir, n, v) => - // Assign appropriate permissions - val isDirectory = (_: File).isDirectory - val dirs = (tdir.***).get filter isDirectory - val bins = (tdir / "usr" / "bin" ***).get filterNot isDirectory - val data = (tdir / "usr" / "share" ***).get filterNot isDirectory - val perms = Map("0755" -> (dirs ++ bins), - "0644" -> data) - val commands = for { - (perm, files) <- perms - file <- files - p = Process("chmod " + perm + " " + file.getAbsolutePath) - } p.! - - // Make the package. We put this in fakeroot, so we can build the package with root owning files. - Process(Seq("fakeroot", "--", "dpkg-deb", "--build", pkgdir.getAbsolutePath), Some(tdir)).! - tdir.getParentFile / (n + "-" + v + ".deb") - }, - lintian <<= (packageBin in Debian) map { file => - println("lintian -c " + file.getName + " on " + file.getParentFile.getAbsolutePath) - Process(Seq("lintian", "-c", "-v", file.getName), Some(file.getParentFile)).! - }, - showMan <<= (resourceDirectory in Debian in makeZippedPackageSource) map { dir => - Process("groff -man -Tascii " + (dir / "usr" / "share" / "man" / "man1" / "sbt.1").getAbsolutePath).! + linuxPackageMappings in Debian <+= (sourceDirectory in Debian) map { bd => + packageForDebian( + (bd / "usr/share/doc/sbt/copyright") -> "usr/share/doc/sbt/copyright" + ) withUser "root" withGroup "root" withPerms "0644" + }, + linuxPackageMappings in Debian <+= (sourceDirectory) map { bd => + packageForDebian( + (bd / "debian/changelog") -> "usr/share/doc/sbt/changelog.gz", + (bd / "linux" / "usr/share/man/man1/sbt.1") -> "usr/share/man/man1/sbt.1.gz" + ) withUser "root" withGroup "root" withPerms "0644" gzipped } ) - - // TODO - Use default-jre-headless? - final val ControlFileContent = """Section: java -Priority: optional -Architecture: all -Depends: curl, java2-runtime, bash (>= 2.05a-11) -Recommends: git -Maintainer: Josh Suereth -Description: Simple Build Tool - This script provides a native way to run the Simple Build Tool, - a build tool for Scala software, also called SBT. -""" } diff --git a/project/project/plugins.scala b/project/project/plugins.scala new file mode 100644 index 000000000..c71e87ada --- /dev/null +++ b/project/project/plugins.scala @@ -0,0 +1,9 @@ +import sbt._ + +object PluginBuild extends Build { + override def projects = Seq(root) + + val root = Project("root", file(".")) dependsOn(packager) + + lazy val packager = RootProject(file("/home/jsuereth/projects/typesafe/sbt-native-packager")) +} diff --git a/src/debian-gzipped/usr/share/doc/sbt/changelog.Debian b/src/debian-gzipped/usr/share/doc/sbt/changelog.Debian deleted file mode 100644 index 28165718b..000000000 --- a/src/debian-gzipped/usr/share/doc/sbt/changelog.Debian +++ /dev/null @@ -1,2 +0,0 @@ -sbt Debian maintainer and upstream author are identical. -Therefore see also normal changelog file for Debian changes. diff --git a/src/debian-gzipped/usr/share/doc/sbt/changelog b/src/debian/changelog similarity index 100% rename from src/debian-gzipped/usr/share/doc/sbt/changelog rename to src/debian/changelog diff --git a/src/linux/usr/share/doc/sbt/copyright b/src/linux/usr/share/doc/sbt/copyright new file mode 100644 index 000000000..4464f3ae7 --- /dev/null +++ b/src/linux/usr/share/doc/sbt/copyright @@ -0,0 +1,22 @@ + +sbt + +Copyright: Typesafe, Inc. + +2011-11-28 + +The home page of sbt package is at: +http://github.com/paulp/sbt-extras + +The entire code base may be distributed under the terms of the BSD license, which appears immediately below. + +Copyright (c) 2011, Typesafe, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/debian-gzipped/usr/share/man/man1/sbt.1 b/src/linux/usr/share/man/man1/sbt.1 similarity index 100% rename from src/debian-gzipped/usr/share/man/man1/sbt.1 rename to src/linux/usr/share/man/man1/sbt.1 From 221667426c9d06a1d3ed7a8296d3848ed23fff5f Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 20 Dec 2011 22:25:02 -0500 Subject: [PATCH 088/483] Update build for rpm building. --- project/debian.scala | 62 +++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/project/debian.scala b/project/debian.scala index bf4ee32ac..1613dd66a 100644 --- a/project/debian.scala +++ b/project/debian.scala @@ -1,36 +1,56 @@ import sbt._ import com.typesafe.packager.debian.DebianPlugin._ -import com.typesafe.packager.linux.{LinuxPackageMapping, LinuxFileMetaData} import com.typesafe.packager.debian.Keys._ -import sbt.Keys.{baseDirectory,sbtVersion,sourceDirectory} +import com.typesafe.packager.linux.{LinuxPackageMapping, LinuxFileMetaData} +import com.typesafe.packager.rpm.RpmPlugin._ +import com.typesafe.packager.rpm.Keys._ +import sbt.Keys.{baseDirectory,sbtVersion,sourceDirectory, name,version} +import com.typesafe.packager.linux.Keys.{linuxPackageMappings,maintainer,packageDescription} object DebianPkg { - val settings: Seq[Setting[_]] = debianSettings ++ Seq( - maintainer in Debian := "Josh Suereth ", + val settings: Seq[Setting[_]] = debianSettings ++ rpmSettings ++ Seq( + + // GENERAL LINUX PACKAGING STUFFS + maintainer := "Josh Suereth ", + packageDescription := """Simple Build Tool + This script provides a native way to run the Simple Build Tool, + a build tool for Scala software, also called SBT.""", + linuxPackageMappings <+= (baseDirectory) map { bd => + (packageForDebian((bd / "sbt") -> "/usr/bin/sbt") + withUser "root" withGroup "root" withPerms "0755") + }, + linuxPackageMappings <+= (sourceDirectory) map { bd => + (packageForDebian( + (bd / "linux" / "usr/share/man/man1/sbt.1") -> "/usr/share/man/man1/sbt.1.gz" + ) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs() + }, + linuxPackageMappings <+= (sourceDirectory in Debian) map { bd => + packageForDebian( + (bd / "usr/share/doc/sbt") -> "/usr/share/doc/sbt", + (bd / "usr/share/doc/sbt/copyright") -> "/usr/share/doc/sbt/copyright" + ) withUser "root" withGroup "root" withPerms "0644" asDocs() + }, + + // DEBIAN SPECIFIC name in Debian := "sbt", version in Debian <<= (version, sbtVersion) apply { (v, sv) => sv + "-build-" + (v split "\\." map (_.toInt) dropWhile (_ == 0) map ("%02d" format _) mkString "") }, debianPackageDependencies in Debian ++= Seq("curl", "java2-runtime", "bash (>= 2.05a-11)"), debianPackageRecommends in Debian += "git", - packageDescription in Debian := """Simple Build Tool - This script provides a native way to run the Simple Build Tool, - a build tool for Scala software, also called SBT.""", - linuxPackageMappings in Debian <+= (baseDirectory) map { bd => - (packageForDebian((bd / "sbt") -> "usr/bin/sbt") - withUser "root" withGroup "root" withPerms "0755") - }, - linuxPackageMappings in Debian <+= (sourceDirectory in Debian) map { bd => - packageForDebian( - (bd / "usr/share/doc/sbt/copyright") -> "usr/share/doc/sbt/copyright" - ) withUser "root" withGroup "root" withPerms "0644" - }, linuxPackageMappings in Debian <+= (sourceDirectory) map { bd => - packageForDebian( - (bd / "debian/changelog") -> "usr/share/doc/sbt/changelog.gz", - (bd / "linux" / "usr/share/man/man1/sbt.1") -> "usr/share/man/man1/sbt.1.gz" - ) withUser "root" withGroup "root" withPerms "0644" gzipped - } + (packageForDebian( + (bd / "debian/changelog") -> "/usr/share/doc/sbt/changelog.gz" + ) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs() + }, + + // RPM SPECIFIC + name in Rpm := "sbt", + version in Rpm <<= sbtVersion.identity, + rpmRelease := "1", + rpmVendor := "Typesafe, Inc.", + rpmOs := "i386", + rpmUrl := Some("http://github.com/paulp/sbt-extras") ) } From c462aad95351b670599514336ce2af14552df73d Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 21 Dec 2011 09:34:47 -0500 Subject: [PATCH 089/483] modifications so that RPM will actually build. A few areas I thoguht optional are mandatory. --- project/debian.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/project/debian.scala b/project/debian.scala index 1613dd66a..05b3552d6 100644 --- a/project/debian.scala +++ b/project/debian.scala @@ -49,8 +49,10 @@ object DebianPkg { name in Rpm := "sbt", version in Rpm <<= sbtVersion.identity, rpmRelease := "1", - rpmVendor := "Typesafe, Inc.", + rpmVendor := "typesafe", rpmOs := "i386", - rpmUrl := Some("http://github.com/paulp/sbt-extras") + rpmUrl := Some("http://github.com/paulp/sbt-extras"), + rpmSummary := Some("Simple Build Tool for Scala-driven builds."), + rpmLicense := Some("BSD") ) } From 183ffffe2af5ad5e85a442285a11a0cf72ec332d Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 21 Dec 2011 09:52:35 -0500 Subject: [PATCH 090/483] Removed os specification. Defaults are now better in packager plugin. --- project/debian.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/project/debian.scala b/project/debian.scala index 05b3552d6..e85749f13 100644 --- a/project/debian.scala +++ b/project/debian.scala @@ -50,7 +50,6 @@ object DebianPkg { version in Rpm <<= sbtVersion.identity, rpmRelease := "1", rpmVendor := "typesafe", - rpmOs := "i386", rpmUrl := Some("http://github.com/paulp/sbt-extras"), rpmSummary := Some("Simple Build Tool for Scala-driven builds."), rpmLicense := Some("BSD") From 5ca52f63d820ee669772ac1d87a1edc2b7500b97 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 21 Dec 2011 11:21:16 -0500 Subject: [PATCH 091/483] Fix to packaging for new structure. --- project/debian.scala | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/project/debian.scala b/project/debian.scala index e85749f13..e010457c4 100644 --- a/project/debian.scala +++ b/project/debian.scala @@ -1,15 +1,11 @@ import sbt._ -import com.typesafe.packager.debian.DebianPlugin._ -import com.typesafe.packager.debian.Keys._ -import com.typesafe.packager.linux.{LinuxPackageMapping, LinuxFileMetaData} -import com.typesafe.packager.rpm.RpmPlugin._ -import com.typesafe.packager.rpm.Keys._ -import sbt.Keys.{baseDirectory,sbtVersion,sourceDirectory, name,version} -import com.typesafe.packager.linux.Keys.{linuxPackageMappings,maintainer,packageDescription} +import com.typesafe.packager.Keys._ +import sbt.Keys._ +import com.typesafe.packager.PackagerPlugin._ object DebianPkg { - val settings: Seq[Setting[_]] = debianSettings ++ rpmSettings ++ Seq( + val settings: Seq[Setting[_]] = packagerSettings ++ Seq( // GENERAL LINUX PACKAGING STUFFS maintainer := "Josh Suereth ", @@ -17,20 +13,24 @@ object DebianPkg { This script provides a native way to run the Simple Build Tool, a build tool for Scala software, also called SBT.""", linuxPackageMappings <+= (baseDirectory) map { bd => - (packageForDebian((bd / "sbt") -> "/usr/bin/sbt") + (packageMapping((bd / "sbt") -> "/usr/bin/sbt") withUser "root" withGroup "root" withPerms "0755") }, linuxPackageMappings <+= (sourceDirectory) map { bd => - (packageForDebian( + (packageMapping( (bd / "linux" / "usr/share/man/man1/sbt.1") -> "/usr/share/man/man1/sbt.1.gz" - ) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs() + ) withPerms "0644" gzipped) asDocs() }, linuxPackageMappings <+= (sourceDirectory in Debian) map { bd => - packageForDebian( - (bd / "usr/share/doc/sbt") -> "/usr/share/doc/sbt", + packageMapping( (bd / "usr/share/doc/sbt/copyright") -> "/usr/share/doc/sbt/copyright" - ) withUser "root" withGroup "root" withPerms "0644" asDocs() + ) withPerms "0644" asDocs() }, + linuxPackageMappings <+= (sourceDirectory in Debian) map { bd => + packageMapping( + (bd / "usr/share/doc/sbt") -> "/usr/share/doc/sbt" + ) asDocs() + }, // DEBIAN SPECIFIC name in Debian := "sbt", @@ -40,9 +40,9 @@ object DebianPkg { debianPackageDependencies in Debian ++= Seq("curl", "java2-runtime", "bash (>= 2.05a-11)"), debianPackageRecommends in Debian += "git", linuxPackageMappings in Debian <+= (sourceDirectory) map { bd => - (packageForDebian( + (packageMapping( (bd / "debian/changelog") -> "/usr/share/doc/sbt/changelog.gz" - ) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs() + ) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs() }, // RPM SPECIFIC @@ -52,6 +52,6 @@ object DebianPkg { rpmVendor := "typesafe", rpmUrl := Some("http://github.com/paulp/sbt-extras"), rpmSummary := Some("Simple Build Tool for Scala-driven builds."), - rpmLicense := Some("BSD") + rpmLicense := Some("BSD") ) } From 1605256c1369304bad3c29fddf81d6c9424a92a0 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 21 Dec 2011 13:52:26 -0500 Subject: [PATCH 092/483] Minor fixes. * Migrated packaging info form debian.scala to packaging.scala * Fixed issue with using sourceDirectory in Debian instead of in Linux --- project/build.scala | 4 ++-- project/{debian.scala => packaging.scala} | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) rename project/{debian.scala => packaging.scala} (92%) diff --git a/project/build.scala b/project/build.scala index 22e8505c6..a546ea1ff 100644 --- a/project/build.scala +++ b/project/build.scala @@ -2,6 +2,6 @@ import sbt._ import Keys._ object SbtExtras extends Build { - // TODO - Detect Debian distribution and enable debian settings for the project. - val root = Project("sbt-extras", file(".")) settings(DebianPkg.settings:_*) + // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. + val root = Project("sbt-extras", file(".")) settings(Packaging.settings:_*) } diff --git a/project/debian.scala b/project/packaging.scala similarity index 92% rename from project/debian.scala rename to project/packaging.scala index e010457c4..35a8fabf7 100644 --- a/project/debian.scala +++ b/project/packaging.scala @@ -3,7 +3,7 @@ import com.typesafe.packager.Keys._ import sbt.Keys._ import com.typesafe.packager.PackagerPlugin._ -object DebianPkg { +object Packaging { val settings: Seq[Setting[_]] = packagerSettings ++ Seq( @@ -21,12 +21,12 @@ object DebianPkg { (bd / "linux" / "usr/share/man/man1/sbt.1") -> "/usr/share/man/man1/sbt.1.gz" ) withPerms "0644" gzipped) asDocs() }, - linuxPackageMappings <+= (sourceDirectory in Debian) map { bd => + linuxPackageMappings <+= (sourceDirectory in Linux) map { bd => packageMapping( (bd / "usr/share/doc/sbt/copyright") -> "/usr/share/doc/sbt/copyright" ) withPerms "0644" asDocs() }, - linuxPackageMappings <+= (sourceDirectory in Debian) map { bd => + linuxPackageMappings <+= (sourceDirectory in Linux) map { bd => packageMapping( (bd / "usr/share/doc/sbt") -> "/usr/share/doc/sbt" ) asDocs() From 65d2c9dc5114f813046dc8f947098809098f9479 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 21 Dec 2011 14:39:57 -0500 Subject: [PATCH 093/483] Added support for locally installed launch jar on installation. --- project/packaging.scala | 23 +++++++++++++++++++++-- project/project/plugins.scala | 3 ++- sbt | 6 +++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/project/packaging.scala b/project/packaging.scala index af3821021..c12999fa1 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -4,9 +4,24 @@ import sbt.Keys._ import com.typesafe.packager.PackagerPlugin._ object Packaging { + + val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url") + val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") + val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") val settings: Seq[Setting[_]] = packagerSettings ++ Seq( - + sbtLaunchJarUrl <<= sbtVersion apply ("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+_+"/sbt-launch.jar"), + sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"), + sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) => + import dispatch._ + if(!file.exists) { + val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(file)) + try Http(url(uri) >>> writer) + finally writer.close() + } + // TODO - GPG Trust validation. + file + }, // GENERAL LINUX PACKAGING STUFFS maintainer := "Josh Suereth ", packageDescription := """Simple Build Tool @@ -41,7 +56,11 @@ object Packaging { (bd / "etc/sbt/sbtopts") -> "/etc/sbt/sbtopts" ) withPerms "0644" withConfig() }, - + linuxPackageMappings <+= (sbtLaunchJar, sourceDirectory in Linux, sbtVersion) map { (jar, dir, v) => + packageMapping(dir -> "/usr/lib/sbt", + dir -> ("/usr/lib/sbt/" + v), + jar -> ("/usr/lib/sbt/"+v+"/sbt-launch.jar")) withPerms "0755" + }, // DEBIAN SPECIFIC name in Debian := "sbt", version in Debian <<= (version, sbtVersion) apply { (v, sv) => diff --git a/project/project/plugins.scala b/project/project/plugins.scala index c71e87ada..a8492268a 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -1,9 +1,10 @@ import sbt._ +import Keys._ object PluginBuild extends Build { override def projects = Seq(root) - val root = Project("root", file(".")) dependsOn(packager) + val root = Project("root", file(".")) dependsOn(packager) settings(libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.6") lazy val packager = RootProject(file("/home/jsuereth/projects/typesafe/sbt-native-packager")) } diff --git a/sbt b/sbt index 220548743..09084266e 100755 --- a/sbt +++ b/sbt @@ -157,7 +157,11 @@ jar_url () { } jar_file () { - echo "$script_dir/.lib/$1/sbt-launch.jar" + if [[ -f "/usr/lib/sbt/$1/sbt-launch.jar" ]]; then + echo "/usr/lib/sbt/$1/sbt-launch.jar" + else + echo "$script_dir/.lib/$1/sbt-launch.jar" + fi } sbt_artifactory_list () { From eba16354eaece2498e4af9434846887684228cb5 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Sat, 24 Dec 2011 00:46:15 -0500 Subject: [PATCH 094/483] First attempt at a windows MSI. * Windows WIX configuration * Windows package configuration * Default lame-o bat file for SBT, until I get external contribs. --- project/packaging.scala | 10 +++++++++- src/windows/sbt.bat | 2 ++ src/windows/sbt.xml | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/windows/sbt.bat create mode 100644 src/windows/sbt.xml diff --git a/project/packaging.scala b/project/packaging.scala index c12999fa1..653ae9896 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -81,6 +81,14 @@ object Packaging { rpmVendor := "typesafe", rpmUrl := Some("http://github.com/paulp/sbt-extras"), rpmSummary := Some("Simple Build Tool for Scala-driven builds."), - rpmLicense := Some("BSD") + rpmLicense := Some("BSD"), + + + // WINDOWS SPECIFIC + name in Windows := "sbt", + wixFile <<= sourceDirectory in Windows map (_ / "sbt.xml"), + mappings in packageMsi in Windows <+= sbtLaunchJar map { f => f -> "sbt-launch.jar" }, + mappings in packageMsi in Windows <+= sourceDirectory in Windows map { d => + (d / "sbt.bat") -> "sbt.bat" } ) } diff --git a/src/windows/sbt.bat b/src/windows/sbt.bat new file mode 100644 index 000000000..92706aeeb --- /dev/null +++ b/src/windows/sbt.bat @@ -0,0 +1,2 @@ +set SCRIPT_DIR=%~dp0 +java -Xmx512M -jar "%SCRIPT_DIR%sbt-launch.jar" %* \ No newline at end of file diff --git a/src/windows/sbt.xml b/src/windows/sbt.xml new file mode 100644 index 000000000..9144dce39 --- /dev/null +++ b/src/windows/sbt.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From dea48caddd3204406404a3763a28fb83b95534ce Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 28 Dec 2011 09:45:58 -0500 Subject: [PATCH 095/483] Modified WIX xml so it *WORKS* and adds sbt to path appropriately. Requires restart for some strange reason. No help on interwebs but a few others noticed the issue. --- src/windows/sbt.xml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/windows/sbt.xml b/src/windows/sbt.xml index 9144dce39..bb0c3e020 100644 --- a/src/windows/sbt.xml +++ b/src/windows/sbt.xml @@ -1,11 +1,11 @@ - + UpgradeCode='4552fb0e-e257-4dbd-9ecb-dba9dbacf424'> - - - - + + + + + + + + \ No newline at end of file From e5a861fdd8e0a6b9a6fa6349fc4e77bb56ff3741 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 28 Dec 2011 10:14:19 -0500 Subject: [PATCH 096/483] Moved WIX xml into build so we can have dynamic parts. --- project/packaging.scala | 45 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/project/packaging.scala b/project/packaging.scala index 653ae9896..137d7acc4 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -86,7 +86,50 @@ object Packaging { // WINDOWS SPECIFIC name in Windows := "sbt", - wixFile <<= sourceDirectory in Windows map (_ / "sbt.xml"), + wixConfig <<= (sbtVersion) map { (sv) => + val version = (sv split "\\.") match { + case Array(major,minor,bugfix, _*) => Seq(major,minor,bugfix, "1") mkString "." + case Array(major,minor) => Seq(major,minor,"0","1") mkString "." + case Array(major) => Seq(major,"0","0","1") mkString "." + } + ( + + + + + + + + + + + + + + + + + + + + + + + + + +) + }, + //wixFile <<= sourceDirectory in Windows map (_ / "sbt.xml"), mappings in packageMsi in Windows <+= sbtLaunchJar map { f => f -> "sbt-launch.jar" }, mappings in packageMsi in Windows <+= sourceDirectory in Windows map { d => (d / "sbt.bat") -> "sbt.bat" } From 1c84c7fca18cc6bcecf6857ef0574d83de5a2000 Mon Sep 17 00:00:00 2001 From: "David M. Lee" Date: Thu, 5 Jan 2012 16:27:40 -0600 Subject: [PATCH 097/483] execRunner should exec. This avoids having a stray bash process that's not useful for anything. --- sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbt b/sbt index 210f28c81..f3c37922c 100755 --- a/sbt +++ b/sbt @@ -104,7 +104,7 @@ execRunner () { echo "" } - "$@" + exec "$@" } echoerr () { From 1a2435f746baddbd19c6786a18cde95112bce0d3 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 11 Jan 2012 11:50:57 -0500 Subject: [PATCH 098/483] Added UI to windows MSI. * Can now select installation directory of SBT. * Can optionally add SBT to the path, instead of required. * Displays a license agreement to the user. --- project/packaging.scala | 45 +++++++++++++++++++++++++++------------- src/windows/License.rtf | Bin 0 -> 1812 bytes 2 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 src/windows/License.rtf diff --git a/project/packaging.scala b/project/packaging.scala index 137d7acc4..1de6a1dfb 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -86,15 +86,23 @@ object Packaging { // WINDOWS SPECIFIC name in Windows := "sbt", - wixConfig <<= (sbtVersion) map { (sv) => - val version = (sv split "\\.") match { + lightOptions ++= Seq("-ext", "WixUIExtension", "-cultures:en-us"), + wixConfig <<= (sbtVersion, sourceDirectory in Windows) map makeWindowsXml, + //wixFile <<= sourceDirectory in Windows map (_ / "sbt.xml"), + mappings in packageMsi in Windows <+= sbtLaunchJar map { f => f -> "sbt-launch.jar" }, + mappings in packageMsi in Windows <+= sourceDirectory in Windows map { d => + (d / "sbt.bat") -> "sbt.bat" } + ) + + def makeWindowsXml(sbtVersion: String, sourceDir: File) = { + val version = (sbtVersion split "\\.") match { case Array(major,minor,bugfix, _*) => Seq(major,minor,bugfix, "1") mkString "." case Array(major,minor) => Seq(major,minor,"0","1") mkString "." case Array(major) => Seq(major,"0","0","1") mkString "." } ( - - - + + + + + - - - + + + + + + + + + + + + + ) - }, - //wixFile <<= sourceDirectory in Windows map (_ / "sbt.xml"), - mappings in packageMsi in Windows <+= sbtLaunchJar map { f => f -> "sbt-launch.jar" }, - mappings in packageMsi in Windows <+= sourceDirectory in Windows map { d => - (d / "sbt.bat") -> "sbt.bat" } - ) + } } diff --git a/src/windows/License.rtf b/src/windows/License.rtf new file mode 100644 index 0000000000000000000000000000000000000000..218b930464d9086391baa7a0a2c037be41af5b83 GIT binary patch literal 1812 zcmcIl-*4MC5Z-fv{tx%ob`Ub#X|{EFk|jE3AxoY}InAJl(h_YGkwt@~5(Gj1_Z=mr zN!I593ByQt-+e#M$zy5UZd!`gs{W`>`|0drR@QR2oA|R4?S48rKYuKDx^-^b;AK+o zTGf=h>L84jZUT{L)YhoWr>FPt9?M_Ly=0&%mEw z{5hQfbMj8MFmJlHehA>Jwg+tK_J;sg!ra1A7$fi(<~m^<NWtb+XrBc7Of0m zBdvgqY7V-UErJNETlhzG`~8T>I%%Xsn6>B{SRYi=sFU>)-oFc*26}=PjI`3+$@*+~ zGn_eEVVzOi&MAZyZ4I53pjxoHGnMS0Y*j1F1MIXp+5qmAI{+H#f9lQ+I7eNpovMUK z2|ySLCuxq#q1A9Q`cBn&aR=e>kciYY`d+nrsC0{2VAIIgcOIqtYe1cz!CQhB^zNBi zrE9G1tV3l^AY+d#w)##Y>KMxa0|2ddszNi}L0M=}vIlw@-phQ;41K8@p^nmwhRuE^ zgF|0=^GpWy)*V{+fAR6@AodS!wXV9OY+Y}@SMnRCqp`xkQ8;OoXzWV}eSDtU>)=O; z=V!q2O)HMl`{S!bhbeoY2k#+lrQZ*XQiE)3jUP6@3aI#~9cJDucVm`ldyUg^}1-}k+0(f8N*@ng>hWQQf zC4sQu%PfcQ-$RD4KYV~Njq&>i$hUP)7=tVyjH9b{La`5l@-XF;umETpB}Girs{rN& zhcx4m&=uua#xwj_BL2^916;O%70II|LWOghP=3=-UQnL;sSD&3!aB@3jfy19VO`|w zj3Hl?5mOc=AzhJp)JjvF4P--74s01F$!lqIf~3NELIzNj7So(W+|wU#qrx;oXOK^V ze__@nqW(g@5fmQgHvu{UQI<0DcY#It65?5r$-MImC>RL_xH#ltPXTezB&@-PdBJFJ7fm_I^J2|umVSa| zc8y*j+YtMGnlWUl4|RaTShD=a!+T$P?*q7A5`3PcCtf7aLvIk{IgNa#Kgw_@&vHHh zz37INTqX31q!IDFG7oi48To{HQRH~#as5_Zhd3Bl1&90XKz?|AruAx7(RfS~=mNrc cgFvWY=)fglbX*vG#ENJ+<}mI8{sa5vUrl~N3jhEB literal 0 HcmV?d00001 From b429b0a246f48de414600142cd4fa9b26989c296 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 11 Jan 2012 13:07:12 -0500 Subject: [PATCH 099/483] Removed echo on bat file --- src/windows/sbt.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/src/windows/sbt.bat b/src/windows/sbt.bat index 92706aeeb..51e540640 100644 --- a/src/windows/sbt.bat +++ b/src/windows/sbt.bat @@ -1,2 +1,3 @@ +@echo off set SCRIPT_DIR=%~dp0 java -Xmx512M -jar "%SCRIPT_DIR%sbt-launch.jar" %* \ No newline at end of file From 97a73b7d77bafeb24a2b08b0016e697622fdd2b4 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 11 Jan 2012 13:41:36 -0500 Subject: [PATCH 100/483] Fixed summary for SBT package. --- project/packaging.scala | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/project/packaging.scala b/project/packaging.scala index 1de6a1dfb..25bc1218c 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -24,9 +24,9 @@ object Packaging { }, // GENERAL LINUX PACKAGING STUFFS maintainer := "Josh Suereth ", - packageDescription := """Simple Build Tool - This script provides a native way to run the Simple Build Tool, - a build tool for Scala software, also called SBT.""", + packageSummary := "Simple Build Tool for Scala-driven builds.", + packageDescription := """This script provides a native way to run the Simple Build Tool, + a build tool for Scala software, also called SBT.""", linuxPackageMappings <+= (baseDirectory) map { bd => (packageMapping((bd / "sbt") -> "/usr/bin/sbt") withUser "root" withGroup "root" withPerms "0755") @@ -80,7 +80,6 @@ object Packaging { rpmRelease := "1", rpmVendor := "typesafe", rpmUrl := Some("http://github.com/paulp/sbt-extras"), - rpmSummary := Some("Simple Build Tool for Scala-driven builds."), rpmLicense := Some("BSD"), From d852b4bc067bde5ef47a2de8f366fc89c76be82a Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 11 Jan 2012 14:10:10 -0500 Subject: [PATCH 101/483] Fixed RPM warnings. --- project/packaging.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/packaging.scala b/project/packaging.scala index 25bc1218c..6ff4e2c74 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -24,7 +24,7 @@ object Packaging { }, // GENERAL LINUX PACKAGING STUFFS maintainer := "Josh Suereth ", - packageSummary := "Simple Build Tool for Scala-driven builds.", + packageSummary := "Simple Build Tool for Scala-driven builds", packageDescription := """This script provides a native way to run the Simple Build Tool, a build tool for Scala software, also called SBT.""", linuxPackageMappings <+= (baseDirectory) map { bd => @@ -54,7 +54,7 @@ object Packaging { linuxPackageMappings <+= (sourceDirectory in Linux) map { bd => packageMapping( (bd / "etc/sbt/sbtopts") -> "/etc/sbt/sbtopts" - ) withPerms "0644" withConfig() + ) withPerms "0644" withConfig("noreplace") }, linuxPackageMappings <+= (sbtLaunchJar, sourceDirectory in Linux, sbtVersion) map { (jar, dir, v) => packageMapping(dir -> "/usr/lib/sbt", From c02d473d229784bc328f5ad94cf51190096c1fcb Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 11 Jan 2012 16:10:29 -0800 Subject: [PATCH 102/483] Added -batch mode. --- sbt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sbt b/sbt index f3c37922c..1f4dd3e9b 100755 --- a/sbt +++ b/sbt @@ -221,6 +221,7 @@ Usage: $script_name [options] -no-share use all local caches; no sharing -offline put sbt in offline mode -jvm-debug Turn on JVM debugging, open at the given port. + -batch Disable interactive mode # sbt version (default: from project/build.properties if present, else latest release) -sbt-version use the specified version of sbt @@ -305,6 +306,7 @@ process_args () -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; -offline) addSbt "set offline := true" && shift ;; -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; + -batch) exec Date: Mon, 16 Jan 2012 15:06:37 -0500 Subject: [PATCH 103/483] Build no uses released packaging plugin. --- project/project/plugins.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/project/project/plugins.scala b/project/project/plugins.scala index a8492268a..a5466f04f 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -4,7 +4,9 @@ import Keys._ object PluginBuild extends Build { override def projects = Seq(root) - val root = Project("root", file(".")) dependsOn(packager) settings(libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.6") - - lazy val packager = RootProject(file("/home/jsuereth/projects/typesafe/sbt-native-packager")) + val root = Project("root", file(".")) settings( + resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), + addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.1.0"), + libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.6" + ) } From 31780795bc2565b5663c3a45151a90dd9277949a Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 16 Jan 2012 15:24:19 -0500 Subject: [PATCH 104/483] Removing plugins and focusing on launcher script. --- README.md | 40 ++----- build.sbt | 4 +- src/main/scala/Main.scala | 124 -------------------- src/main/scala/SimpleDsl.scala | 10 -- src/main/scala/SimpleSetting.scala | 169 --------------------------- src/main/scala/SimpleTask.scala | 176 ----------------------------- 6 files changed, 9 insertions(+), 514 deletions(-) delete mode 100644 src/main/scala/Main.scala delete mode 100644 src/main/scala/SimpleDsl.scala delete mode 100644 src/main/scala/SimpleSetting.scala delete mode 100644 src/main/scala/SimpleTask.scala diff --git a/README.md b/README.md index 6646dfc6a..b45b71c6d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -sbt: the rebel cut +sbt: the launcher ================== An alternative script for running [sbt](https://github.com/harrah/xsbt). @@ -80,39 +80,13 @@ Current -help output: In the case of duplicated or conflicting options, the order above shows precedence: JAVA_OPTS lowest, command line options highest. -## SBT Extra plugin -To see the plugin in action, including the thrilling custom sbt command "help-names": +## Native Packages ## - cd template-project && ../sbt -sbt-rc help-names zomg zomg2 - -The template files are: +This project also includes native packages to run SBT for + * Windows + * RedHat (rpm) + * Debian (deb) - project/plugins/project/Build.scala # you can use this as-is if you want - project/Build.scala # this is a starting point for your real Build.scala +Locations for download to be available soon. -The Template build isn't quite finished. There will most likely be a build.sbt DSL variant that does not require a project scala file. - -## Simple SBT DSL - -SBT extras defines a simplified task DSL for those who are defining simple tasks that do not need to be relied upon, or you are unsure and can refactor later. Once including the sbt-extra-plugin, all you have to do is place the following in your build.sbt to create tasks: - - simple_task("zomg") is { println("ZOMG") } - -or if you need to depend on other keys: - - simple_task("zomg2") on (name, version) is { (n,v) => println("ZOMG " + n + " = " + v + " !!!!!") } - -The DSL currently supports between 0 and 9 dependencies. The DSL does not allow defining tasks on different configurations, although this will be added shortly. - -### Simple Setttings - -SBT distinguishes between defining Setting and Tasks through the `apply` and `map` methods. The Simple DSL has no such distinction. Defining a setting is as easy as: - - simple_setting("name") is "project-name" - -Settings can also depend on other settings. - - simple_setting("name") on (version) is { v => "project-name" + v } - -Since a Setting can *only* be defined using other settings, attempting to use a non-setting in the on calls results in a type error. diff --git a/build.sbt b/build.sbt index fe69fa2f8..7e90c6c9e 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,8 @@ sbtPlugin := true -name := "sbt-extras-plugin" +name := "sbt-launcher-package" -organization := "org.improving" +organization := "org.scalasbt" version := "0.1.0" diff --git a/src/main/scala/Main.scala b/src/main/scala/Main.scala deleted file mode 100644 index 5a4742427..000000000 --- a/src/main/scala/Main.scala +++ /dev/null @@ -1,124 +0,0 @@ -package template - -import sbt._ -import Keys._ -import Load.{ BuildStructure, StructureIndex } -import scala.collection.{ mutable, immutable } - -object SbtExtrasPlugin extends Plugin { - def simple_task(name: String) = sbt.extra.dsl.SimpleTasks.task(name) - def simple_setting(name: String) = sbt.extra.dsl.SimpleTasks.setting(name) -} - -trait SbtCreateConfig { - def name: String - def organization: String - def version: String - def scalaVersion: String -} -object SbtCreateConfig { - private def prop(propName: String, alt: String) = System.getProperty(propName) match { - case null => alt - case value => value - } - implicit def defaultProjectConfig = new SbtCreateConfig { - def name = prop("sbt-create.name", "project-name-here") - def organization = prop("sbt-create.organization", "your.organization.here") - def version = prop("sbt-create.version", "0.1-SNAPSHOT") - def scalaVersion = prop("sbt.scala.version", "2.9.0-1") - } -} - -class TemplateBuild(implicit sbtCreateConfig: SbtCreateConfig) extends Build { - // BuildStructure contains: - // units: Map[URI, LoadedBuildUnit] - // root: URI - // settings: Seq[Setting[_]] - // data: Settings[Scope] - // index: StructureIndex - // streams: Streams - // delegates: Scope => Seq[Scope] - // scopeLocal: ScopeLocal - - private val cachedExtraction = new collection.mutable.HashMap[State, WState] - private implicit def stateWrapper(state: State): WState = - cachedExtraction.getOrElseUpdate(state, new WState(state)) - private implicit def revealStructure(state: State): BuildStructure = - stateWrapper(state).structure - private implicit def revealStructureIndex(state: State): StructureIndex = - revealStructure(state).index - private implicit def revealSession(state: State): SessionSettings = - stateWrapper(state).session - - private class WState(state: State) { - val extracted = Project extract state - - def projectId = extracted.currentProject.id - def structure = extracted.structure - def session = extracted.session - def currentRef = extracted.currentRef - def rootProject = structure.rootProject - def allProjects = structure.allProjects - - def index = structure.index - def taskToKey = index.taskToKey - def keyMap = index.keyMap // Map[String, AttributeKey[_]] - def keyIndex = index.keyIndex - def currentKeys = keyIndex keys Some(currentRef) map index.keyMap - def sortedKeys = currentKeys.toSeq sortBy (_.label) - } - - private class Tap[T](target: T) { - def show(): Unit = target match { - case xs: TraversableOnce[_] => xs foreach println - case _ => println(target) - } - def tap[U](f: T => U): T = { - f(target) - target - } - } - private implicit def createTapper[T](target: T): Tap[T] = new Tap(target) - - def currentBranch = ("git status -sb".lines_! headOption) getOrElse "-" stripPrefix "## " - - val buildShellPrompt = { - (state: State) => "%s:%s> ".format( - state.projectId, - currentBranch - ) - } - - lazy val testSettings = Seq( - libraryDependencies ++= Seq( - "org.scala-tools.testing" % "specs_2.9.0-1" % "1.6.8" % "test" - ), - libraryDependencies <+= (scalaVersion)(v => "org.scala-lang" % "scala-compiler" % v) - ) - - lazy val buildSettings = Seq( - resolvers += ScalaToolsSnapshots, - organization := sbtCreateConfig.organization, - version := sbtCreateConfig.version, - scalaVersion := sbtCreateConfig.scalaVersion, - // retrieveManaged := true, - shellPrompt := buildShellPrompt - // logLevel := Level.Debug, - ) - - lazy val templateConfig = Project( - id = sbtCreateConfig.name, - base = file("."), - aggregate = Nil, - dependencies = Nil, - delegates = Nil, - settings = Defaults.defaultSettings ++ buildSettings ++ testSettings ++ Seq( - commands += helpNames - ) - ) - - // A sample command definition. - def helpNames = Command.command("help-names") { (state: State) => - state tap (_.sortedKeys map (_.label) show) - } -} diff --git a/src/main/scala/SimpleDsl.scala b/src/main/scala/SimpleDsl.scala deleted file mode 100644 index 273b38042..000000000 --- a/src/main/scala/SimpleDsl.scala +++ /dev/null @@ -1,10 +0,0 @@ -package sbt.extra.dsl - -import sbt._ -import Scoped._ -import Project.{richInitializeTask,richInitialize} - -object SimpleTasks { - final def task(name: String) = new TaskId(name) - final def setting(name: String) = new SettingId(name) -} diff --git a/src/main/scala/SimpleSetting.scala b/src/main/scala/SimpleSetting.scala deleted file mode 100644 index 3b924f6d5..000000000 --- a/src/main/scala/SimpleSetting.scala +++ /dev/null @@ -1,169 +0,0 @@ -package sbt.extra.dsl - -import sbt._ -import Scoped._ -import Project._ -import Project.Setting - -/** Represents the new 'id' of a setting to define on a project. */ -final class SettingId(name: String) { - /** Creates a Task that has no dependencies. */ - final def is[R: Manifest](f: => R) = - SettingKey[R](name) := f - final def on[A1](a: Initialize[A1]): SettingDepend1[A1] = - new SettingDepend1[A1](name, a) - final def on[A1, A2](a1: Initialize[A1], a2: Initialize[A2]): SettingDepend2[A1, A2] = - new SettingDepend2[A1, A2](name, a1, a2) - final def on[A1, A2, A3](a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3]) = - new SettingDepend3[A1, A2, A3](name, a1, a2, a3) - final def on[A1, A2, A3, A4](a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3], - a4: Initialize[A4]) = - new SettingDepend4[A1, A2, A3, A4](name, a1, a2, a3, a4) - final def on[A1, A2, A3, A4, A5](a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3], - a4: Initialize[A4], - a5: Initialize[A5]) = - new SettingDepend5[A1, A2, A3, A4, A5](name, a1, a2, a3, a4, a5) - final def on[A1, A2, A3, A4, A5, A6](a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3], - a4: Initialize[A4], - a5: Initialize[A5], - a6: Initialize[A6]) = - new SettingDepend6[A1, A2, A3, A4, A5, A6](name, a1, a2, a3, a4, a5, a6) - final def on[A1, A2, A3, A4, A5, A6, A7](a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3], - a4: Initialize[A4], - a5: Initialize[A5], - a6: Initialize[A6], - a7: Initialize[A7]) = - new SettingDepend7[A1, A2, A3, A4, A5, A6, A7](name, a1, a2, a3, a4, a5, a6, a7) - final def on[A1, A2, A3, A4, A5, A6, A7, A8](a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3], - a4: Initialize[A4], - a5: Initialize[A5], - a6: Initialize[A6], - a7: Initialize[A7], - a8: Initialize[A8]) = - new SettingDepend8[A1, A2, A3, A4, A5, A6, A7, A8](name, a1, a2, a3, a4, a5, a6, a7, a8) - final def on[A1, A2, A3, A4, A5, A6, A7, A8, A9](a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3], - a4: Initialize[A4], - a5: Initialize[A5], - a6: Initialize[A6], - a7: Initialize[A7], - a8: Initialize[A8], - a9: Initialize[A9]) = - new SettingDepend9[A1, A2, A3, A4, A5, A6, A7, A8, A9](name, a1, a2, a3, a4, a5, a6, a7, a8, a9) -} - -/** Represents a not-yet-defined Setting that has one dependency */ -final class SettingDepend1[A1](name: String, a1: Initialize[A1]) { - final def is[R: Manifest](f: A1 => R): Setting[R] = { - SettingKey[R](name) <<= a1 apply f - } -} - -/** Represents a not-yet-defined Setting that has two dependencies */ -final class SettingDepend2[A1, A2](name: String, - a1: Initialize[A1], - a2: Initialize[A2]) { - final def is[R: Manifest](f: (A1, A2) => R): Setting[R] = { - SettingKey[R](name) <<= (a1, a2) apply f - } -} -/** Represents a not-yet-defined Setting that has two dependencies */ -final class SettingDepend3[A1, A2, A3](name: String, - a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3]) { - final def is[R: Manifest](f: (A1, A2, A3) => R): Setting[R] = { - SettingKey[R](name) <<= (a1, a2, a3) apply f - } -} -/** Represents a not-yet-defined Setting that has two dependencies */ -final class SettingDepend4[A1, A2, A3, A4](name: String, - a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3], - a4: Initialize[A4]) { - final def is[R: Manifest](f: (A1, A2, A3, A4) => R): Setting[R] = { - SettingKey[R](name) <<= (a1, a2, a3, a4) apply f - } -} -/** Represents a not-yet-defined Setting that has two dependencies */ -final class SettingDepend5[A1, A2, A3, A4, A5](name: String, - a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3], - a4: Initialize[A4], - a5: Initialize[A5]) { - final def is[R: Manifest](f: (A1, A2, A3, A4, A5) => R): Setting[R] = { - SettingKey[R](name) <<= (a1, a2, a3, a4, a5) apply f - } -} -/** Represents a not-yet-defined Setting that has two dependencies */ -final class SettingDepend6[A1, A2, A3, A4, A5, A6](name: String, - a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3], - a4: Initialize[A4], - a5: Initialize[A5], - a6: Initialize[A6]) { - final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6) => R): Setting[R] = { - SettingKey[R](name) <<= (a1, a2, a3, a4, a5, a6) apply f - } -} -/** Represents a not-yet-defined Setting that has two dependencies */ -final class SettingDepend7[A1, A2, A3, A4, A5, A6, A7](name: String, - a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3], - a4: Initialize[A4], - a5: Initialize[A5], - a6: Initialize[A6], - a7: Initialize[A7]) { - final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6, A7) => R): Setting[R] = { - SettingKey[R](name) <<= (a1, a2, a3, a4, a5, a6, a7) apply f - } -} -/** Represents a not-yet-defined Setting that has two dependencies */ -final class SettingDepend8[A1, A2, A3, A4, A5, A6, A7, A8](name: String, - a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3], - a4: Initialize[A4], - a5: Initialize[A5], - a6: Initialize[A6], - a7: Initialize[A7], - a8: Initialize[A8]) { - final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6, A7, A8) => R): Setting[R] = { - SettingKey[R](name) <<= (a1, a2, a3, a4, a5, a6, a7, a8) apply f - } -} -/** Represents a not-yet-defined Setting that has two dependencies */ -final class SettingDepend9[A1, A2, A3, A4, A5, A6, A7, A8, A9](name: String, - a1: Initialize[A1], - a2: Initialize[A2], - a3: Initialize[A3], - a4: Initialize[A4], - a5: Initialize[A5], - a6: Initialize[A6], - a7: Initialize[A7], - a8: Initialize[A8], - a9: Initialize[A9]) { - final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6, A7, A8, A9) => R): Setting[R] = { - SettingKey[R](name) <<= (a1, a2, a3, a4, a5, a6, a7, a8, a9) apply f - } -} - - - diff --git a/src/main/scala/SimpleTask.scala b/src/main/scala/SimpleTask.scala deleted file mode 100644 index a48e404de..000000000 --- a/src/main/scala/SimpleTask.scala +++ /dev/null @@ -1,176 +0,0 @@ -package sbt.extra.dsl - -import sbt._ -import Scoped._ -import Project._ -import Project.Setting - -/** Represents the new 'id' of a task to define on a project. */ -final class TaskId(name: String) { - /** Creates a Task that has no dependencies. */ - final def is[R: Manifest](f: => R) = - TaskKey[R](name) := f - final def on[A1](a: Initialize[Task[A1]]): TaskDepend1Task[A1] = - new TaskDepend1Task[A1](name, a) - final def on[A1](a: Initialize[A1]): TaskDepend1Setting[A1] = - new TaskDepend1Setting[A1](name, a) - final def on[A1, A2](a1: ScopedTaskable[A1], a2: ScopedTaskable[A2]): TaskDepend2[A1, A2] = - new TaskDepend2[A1, A2](name, a1, a2) - final def on[A1, A2, A3](a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3]) = - new TaskDepend3[A1, A2, A3](name, a1, a2, a3) - final def on[A1, A2, A3, A4](a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3], - a4: ScopedTaskable[A4]) = - new TaskDepend4[A1, A2, A3, A4](name, a1, a2, a3, a4) - final def on[A1, A2, A3, A4, A5](a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3], - a4: ScopedTaskable[A4], - a5: ScopedTaskable[A5]) = - new TaskDepend5[A1, A2, A3, A4, A5](name, a1, a2, a3, a4, a5) - final def on[A1, A2, A3, A4, A5, A6](a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3], - a4: ScopedTaskable[A4], - a5: ScopedTaskable[A5], - a6: ScopedTaskable[A6]) = - new TaskDepend6[A1, A2, A3, A4, A5, A6](name, a1, a2, a3, a4, a5, a6) - final def on[A1, A2, A3, A4, A5, A6, A7](a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3], - a4: ScopedTaskable[A4], - a5: ScopedTaskable[A5], - a6: ScopedTaskable[A6], - a7: ScopedTaskable[A7]) = - new TaskDepend7[A1, A2, A3, A4, A5, A6, A7](name, a1, a2, a3, a4, a5, a6, a7) - final def on[A1, A2, A3, A4, A5, A6, A7, A8](a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3], - a4: ScopedTaskable[A4], - a5: ScopedTaskable[A5], - a6: ScopedTaskable[A6], - a7: ScopedTaskable[A7], - a8: ScopedTaskable[A8]) = - new TaskDepend8[A1, A2, A3, A4, A5, A6, A7, A8](name, a1, a2, a3, a4, a5, a6, a7, a8) - final def on[A1, A2, A3, A4, A5, A6, A7, A8, A9](a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3], - a4: ScopedTaskable[A4], - a5: ScopedTaskable[A5], - a6: ScopedTaskable[A6], - a7: ScopedTaskable[A7], - a8: ScopedTaskable[A8], - a9: ScopedTaskable[A9]) = - new TaskDepend9[A1, A2, A3, A4, A5, A6, A7, A8, A9](name, a1, a2, a3, a4, a5, a6, a7, a8, a9) -} - -final class TaskDepend1Setting[A1](name: String, a1: Initialize[A1]) { - final def is[R: Manifest](f: A1 => R): Setting[Task[R]] = { - TaskKey[R](name) <<= a1 map f - } -} -/** Represents a not-yet-defined task that has one dependency */ -final class TaskDepend1Task[A1](name: String, a1: Initialize[Task[A1]]) { - final def is[R: Manifest](f: A1 => R): Setting[Task[R]] = { - TaskKey[R](name) <<= a1 map f - } -} - -/** Represents a not-yet-defined task that has two dependencies */ -final class TaskDepend2[A1, A2](name: String, - a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2]) { - final def is[R: Manifest](f: (A1, A2) => R): Setting[Task[R]] = { - TaskKey[R](name) <<= (a1, a2) map f - } -} -/** Represents a not-yet-defined task that has two dependencies */ -final class TaskDepend3[A1, A2, A3](name: String, - a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3]) { - final def is[R: Manifest](f: (A1, A2, A3) => R): Setting[Task[R]] = { - TaskKey[R](name) <<= (a1, a2, a3) map f - } -} -/** Represents a not-yet-defined task that has two dependencies */ -final class TaskDepend4[A1, A2, A3, A4](name: String, - a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3], - a4: ScopedTaskable[A4]) { - final def is[R: Manifest](f: (A1, A2, A3, A4) => R): Setting[Task[R]] = { - TaskKey[R](name) <<= (a1, a2, a3, a4) map f - } -} -/** Represents a not-yet-defined task that has two dependencies */ -final class TaskDepend5[A1, A2, A3, A4, A5](name: String, - a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3], - a4: ScopedTaskable[A4], - a5: ScopedTaskable[A5]) { - final def is[R: Manifest](f: (A1, A2, A3, A4, A5) => R): Setting[Task[R]] = { - TaskKey[R](name) <<= (a1, a2, a3, a4, a5) map f - } -} -/** Represents a not-yet-defined task that has two dependencies */ -final class TaskDepend6[A1, A2, A3, A4, A5, A6](name: String, - a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3], - a4: ScopedTaskable[A4], - a5: ScopedTaskable[A5], - a6: ScopedTaskable[A6]) { - final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6) => R): Setting[Task[R]] = { - TaskKey[R](name) <<= (a1, a2, a3, a4, a5, a6) map f - } -} -/** Represents a not-yet-defined task that has two dependencies */ -final class TaskDepend7[A1, A2, A3, A4, A5, A6, A7](name: String, - a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3], - a4: ScopedTaskable[A4], - a5: ScopedTaskable[A5], - a6: ScopedTaskable[A6], - a7: ScopedTaskable[A7]) { - final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6, A7) => R): Setting[Task[R]] = { - TaskKey[R](name) <<= (a1, a2, a3, a4, a5, a6, a7) map f - } -} -/** Represents a not-yet-defined task that has two dependencies */ -final class TaskDepend8[A1, A2, A3, A4, A5, A6, A7, A8](name: String, - a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3], - a4: ScopedTaskable[A4], - a5: ScopedTaskable[A5], - a6: ScopedTaskable[A6], - a7: ScopedTaskable[A7], - a8: ScopedTaskable[A8]) { - final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6, A7, A8) => R): Setting[Task[R]] = { - TaskKey[R](name) <<= (a1, a2, a3, a4, a5, a6, a7, a8) map f - } -} -/** Represents a not-yet-defined task that has two dependencies */ -final class TaskDepend9[A1, A2, A3, A4, A5, A6, A7, A8, A9](name: String, - a1: ScopedTaskable[A1], - a2: ScopedTaskable[A2], - a3: ScopedTaskable[A3], - a4: ScopedTaskable[A4], - a5: ScopedTaskable[A5], - a6: ScopedTaskable[A6], - a7: ScopedTaskable[A7], - a8: ScopedTaskable[A8], - a9: ScopedTaskable[A9]) { - final def is[R: Manifest](f: (A1, A2, A3, A4, A5, A6, A7, A8, A9) => R): Setting[Task[R]] = { - TaskKey[R](name) <<= (a1, a2, a3, a4, a5, a6, a7, a8, a9) map f - } -} - - - From 2422381927d0178864ac9829576f0a13ce00393b Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 16 Jan 2012 15:25:15 -0500 Subject: [PATCH 105/483] Fixing markdown issues --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b45b71c6d..8d55860a2 100644 --- a/README.md +++ b/README.md @@ -84,9 +84,11 @@ Current -help output: ## Native Packages ## This project also includes native packages to run SBT for - * Windows - * RedHat (rpm) - * Debian (deb) + +* Windows +* RedHat (rpm) +* Debian (deb) +* Homebrew (coming soon!) Locations for download to be available soon. From 0739ba0b559f316c69d90c2990073a79befbc4ad Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 17 Jan 2012 09:32:44 -0500 Subject: [PATCH 106/483] Adding publishing to the windows MSI generation. --- project/packaging.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/project/packaging.scala b/project/packaging.scala index 6ff4e2c74..2c055b885 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -8,6 +8,10 @@ object Packaging { val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url") val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") + + val winowsReleaseUrl = "http://typesafe.artifactoryonline.com/typesafe/windows-releases" + + def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]" val settings: Seq[Setting[_]] = packagerSettings ++ Seq( sbtLaunchJarUrl <<= sbtVersion apply ("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+_+"/sbt-launch.jar"), @@ -91,6 +95,13 @@ object Packaging { mappings in packageMsi in Windows <+= sbtLaunchJar map { f => f -> "sbt-launch.jar" }, mappings in packageMsi in Windows <+= sourceDirectory in Windows map { d => (d / "sbt.bat") -> "sbt.bat" } + // WINDOWS MSI Publishing + ) ++ inConfig(Windows)(Classpaths.publishSettings) ++ Seq( + packagedArtifacts in Windows <<= (packageMsi in Windows, name in Windows) map { (msi, name) => + val artifact = Artifact(name, "msi", "msi", classifier = None, configurations = Iterable.empty, url = None, extraAttributes = Map.empty) + Map(artifact -> msi) + }, + publishTo in Windows := Some(Resolver.url("windows-releases", new URL(winowsReleaseUrl))(Patterns(localWindowsPattern))) ) def makeWindowsXml(sbtVersion: String, sourceDir: File) = { From 2f19508ae5fa4d83506affe9541f6fc7227b7584 Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Tue, 17 Jan 2012 18:03:26 +0100 Subject: [PATCH 107/483] Package Jansi plus a bootstrap launcher in the MSI installer --- project/packaging.scala | 36 +++++++++++++++++++++++++++++-- src/main/java/SbtJansiLaunch.java | 6 ++++++ src/windows/sbt.bat | 4 ++-- 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 src/main/java/SbtJansiLaunch.java diff --git a/project/packaging.scala b/project/packaging.scala index 2c055b885..ede231104 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -9,6 +9,10 @@ object Packaging { val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") + val jansiJarUrl = SettingKey[String]("jansi-jar-url") + val jansiJarLocation = SettingKey[File]("jansi-jar-location") + val jansiJar = TaskKey[File]("jansi-jar", "Resolves Jansi jar") + val winowsReleaseUrl = "http://typesafe.artifactoryonline.com/typesafe/windows-releases" def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]" @@ -26,6 +30,18 @@ object Packaging { // TODO - GPG Trust validation. file }, + jansiJarUrl := "http://repo.fusesource.com/nexus/content/groups/public/org/fusesource/jansi/jansi/1.7/jansi-1.7.jar", + jansiJarLocation <<= target apply (_ / "jansi-1.7.jar"), + jansiJar <<= (jansiJarUrl, jansiJarLocation) map { (uri, file) => + import dispatch._ + if(!file.exists) { + val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(file)) + try Http(url(uri) >>> writer) + finally writer.close() + } + // TODO - GPG Trust validation. + file + }, // GENERAL LINUX PACKAGING STUFFS maintainer := "Josh Suereth ", packageSummary := "Simple Build Tool for Scala-driven builds", @@ -93,15 +109,21 @@ object Packaging { wixConfig <<= (sbtVersion, sourceDirectory in Windows) map makeWindowsXml, //wixFile <<= sourceDirectory in Windows map (_ / "sbt.xml"), mappings in packageMsi in Windows <+= sbtLaunchJar map { f => f -> "sbt-launch.jar" }, + mappings in packageMsi in Windows <+= jansiJar map { f => f -> "jansi.jar" }, mappings in packageMsi in Windows <+= sourceDirectory in Windows map { d => - (d / "sbt.bat") -> "sbt.bat" } + (d / "sbt.bat") -> "sbt.bat" }, + mappings in packageMsi in Windows <+= (compile in Compile, classDirectory in Compile) map { (c, d) => + compile; (d / "SbtJansiLaunch.class") -> "SbtJansiLaunch.class" } // WINDOWS MSI Publishing ) ++ inConfig(Windows)(Classpaths.publishSettings) ++ Seq( packagedArtifacts in Windows <<= (packageMsi in Windows, name in Windows) map { (msi, name) => val artifact = Artifact(name, "msi", "msi", classifier = None, configurations = Iterable.empty, url = None, extraAttributes = Map.empty) Map(artifact -> msi) }, - publishTo in Windows := Some(Resolver.url("windows-releases", new URL(winowsReleaseUrl))(Patterns(localWindowsPattern))) + publishTo in Windows := Some(Resolver.url("windows-releases", new URL(winowsReleaseUrl))(Patterns(localWindowsPattern))), + javacOptions := Seq("-source", "1.5", "-target", "1.5"), + unmanagedJars in Compile <+= sbtLaunchJar map identity, + unmanagedJars in Compile <+= jansiJar map identity ) def makeWindowsXml(sbtVersion: String, sourceDir: File) = { @@ -129,9 +151,17 @@ object Packaging { + + + + + + + + @@ -148,6 +178,8 @@ object Packaging { + + diff --git a/src/main/java/SbtJansiLaunch.java b/src/main/java/SbtJansiLaunch.java new file mode 100644 index 000000000..f9790ef9f --- /dev/null +++ b/src/main/java/SbtJansiLaunch.java @@ -0,0 +1,6 @@ +class SbtJansiLaunch { + public static void main(String[] args) { + org.fusesource.jansi.AnsiConsole.systemInstall(); + xsbt.boot.Boot.main(args); + } +} diff --git a/src/windows/sbt.bat b/src/windows/sbt.bat index 51e540640..70ccb8de0 100644 --- a/src/windows/sbt.bat +++ b/src/windows/sbt.bat @@ -1,3 +1,3 @@ @echo off -set SCRIPT_DIR=%~dp0 -java -Xmx512M -jar "%SCRIPT_DIR%sbt-launch.jar" %* \ No newline at end of file +set SBT_HOME=%~dp0 +java -Xmx512M -Dsbt.log.format=true -cp "%SBT_HOME%jansi.jar;%SBT_HOME%sbt-launch.jar;%SBT_HOME%classes" SbtJansiLaunch %* From b0deb8c2aee9821e6eb26cff3b0da5b4f2c81a2c Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 17 Jan 2012 12:56:30 -0500 Subject: [PATCH 108/483] Fixes to MSI from szeiger, as well as trying to get publishing working. --- project/packaging.scala | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/project/packaging.scala b/project/packaging.scala index 2c055b885..4d07b102f 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -96,13 +96,24 @@ object Packaging { mappings in packageMsi in Windows <+= sourceDirectory in Windows map { d => (d / "sbt.bat") -> "sbt.bat" } // WINDOWS MSI Publishing - ) ++ inConfig(Windows)(Classpaths.publishSettings) ++ Seq( - packagedArtifacts in Windows <<= (packageMsi in Windows, name in Windows) map { (msi, name) => + ) ++ (inConfig(Windows)(Classpaths.publishSettings)) ++ (inConfig(Windows)(Seq( + packagedArtifacts <<= (packageMsi, name) map { (msi, name) => val artifact = Artifact(name, "msi", "msi", classifier = None, configurations = Iterable.empty, url = None, extraAttributes = Map.empty) Map(artifact -> msi) }, - publishTo in Windows := Some(Resolver.url("windows-releases", new URL(winowsReleaseUrl))(Patterns(localWindowsPattern))) - ) + publishMavenStyle := true, + projectID <<= (organization, name, sbtVersion) apply { (o,n,v) => ModuleID(o,n,v) }, + moduleSettings <<= Classpaths.moduleSettings0, + deliverLocalConfiguration <<= (crossTarget, ivyLoggingLevel) map { (outDir, level) => Classpaths.deliverConfig(outDir, logging = level) }, + deliverConfiguration <<= deliverLocalConfiguration, + publishTo := Some(Resolver.url("windows-releases", new URL(winowsReleaseUrl))(Patterns(localWindowsPattern))), + publishConfiguration <<= (packagedArtifacts, publishTo, publishMavenStyle, deliver, checksums in publish, ivyLoggingLevel) map { (arts, publishTo, mavenStyle, ivyFile, checks, level) => + Classpaths.publishConfig(arts, if(mavenStyle) None else Some(ivyFile), resolverName = Classpaths.getPublishTo(publishTo).name, checksums = checks, logging = level) + }, + publishLocalConfiguration <<= (packagedArtifacts, deliverLocal, checksums in publishLocal, ivyLoggingLevel) map { + (arts, ivyFile, checks, level) => Classpaths.publishConfig(arts, Some(ivyFile), checks, logging = level ) + } + ))) def makeWindowsXml(sbtVersion: String, sourceDir: File) = { val version = (sbtVersion split "\\.") match { @@ -145,7 +156,7 @@ object Packaging { - + @@ -153,11 +164,25 @@ object Packaging { - - + + + + + + + + + ) } From e4f0d94b43ddbe7ea5459cea49b24fc386d425a5 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 17 Jan 2012 14:15:00 -0500 Subject: [PATCH 109/483] Project can now deploy to MSI repository. --- build.sbt | 2 ++ project/packaging.scala | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index 7e90c6c9e..692ad3837 100644 --- a/build.sbt +++ b/build.sbt @@ -6,3 +6,5 @@ organization := "org.scalasbt" version := "0.1.0" +crossTarget <<= target + diff --git a/project/packaging.scala b/project/packaging.scala index 3886f2b52..a2fa89053 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -118,8 +118,9 @@ object Packaging { }, javacOptions := Seq("-source", "1.5", "-target", "1.5"), unmanagedJars in Compile <+= sbtLaunchJar map identity, - unmanagedJars in Compile <+= jansiJar map identity + unmanagedJars in Compile <+= jansiJar map identity, // WINDOWS MSI Publishing + resolvers += Resolver.url("windows-releases", new URL(winowsReleaseUrl))(Patterns(localWindowsPattern)) ) ++ (inConfig(Windows)(Classpaths.publishSettings)) ++ (inConfig(Windows)(Seq( packagedArtifacts <<= (packageMsi, name) map { (msi, name) => val artifact = Artifact(name, "msi", "msi", classifier = None, configurations = Iterable.empty, url = None, extraAttributes = Map.empty) @@ -127,15 +128,26 @@ object Packaging { }, publishMavenStyle := true, projectID <<= (organization, name, sbtVersion) apply { (o,n,v) => ModuleID(o,n,v) }, - moduleSettings <<= Classpaths.moduleSettings0, + moduleSettings <<= (projectID, projectInfo) map { (pid, pinfo) => + InlineConfiguration(pid, pinfo, Seq.empty) + }, + ivyModule <<= (ivySbt, moduleSettings) map { (i, s) => new i.Module(s) }, deliverLocalConfiguration <<= (crossTarget, ivyLoggingLevel) map { (outDir, level) => Classpaths.deliverConfig(outDir, logging = level) }, deliverConfiguration <<= deliverLocalConfiguration, publishTo := Some(Resolver.url("windows-releases", new URL(winowsReleaseUrl))(Patterns(localWindowsPattern))), - publishConfiguration <<= (packagedArtifacts, publishTo, publishMavenStyle, deliver, checksums in publish, ivyLoggingLevel) map { (arts, publishTo, mavenStyle, ivyFile, checks, level) => - Classpaths.publishConfig(arts, if(mavenStyle) None else Some(ivyFile), resolverName = Classpaths.getPublishTo(publishTo).name, checksums = checks, logging = level) + publishConfiguration <<= (packagedArtifacts, checksums, publishTo) map { (as, checks, publishTo) => + new PublishConfiguration(ivyFile = None, + resolverName = Classpaths.getPublishTo(publishTo).name, + artifacts = as, + checksums = checks, + logging = UpdateLogging.DownloadOnly) }, - publishLocalConfiguration <<= (packagedArtifacts, deliverLocal, checksums in publishLocal, ivyLoggingLevel) map { - (arts, ivyFile, checks, level) => Classpaths.publishConfig(arts, Some(ivyFile), checks, logging = level ) + publishLocalConfiguration <<= (packagedArtifacts, checksums) map { (as, checks) => + new PublishConfiguration(ivyFile = None, + resolverName = "local", + artifacts = as, + checksums = checks, + logging = UpdateLogging.DownloadOnly) } ))) From 4d490ccfd10da1c760cf267e6439c8d66ab94c4d Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 18 Jan 2012 09:49:00 -0500 Subject: [PATCH 110/483] Added no-global option. Added -no-global option to point -sbt-dir at local location. Helps deal with bad global plugins. --- sbt | 2 ++ src/linux/usr/share/man/man1/sbt.1 | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sbt b/sbt index 221ccd6ef..5c82961c0 100755 --- a/sbt +++ b/sbt @@ -232,6 +232,7 @@ Usage: $script_name [options] -ivy path to local Ivy repository (default: ~/.ivy2) -mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) -no-share use all local caches; no sharing + -no-global uses global caches, but does not use global ~/.sbt directory. -offline put sbt in offline mode -jvm-debug Turn on JVM debugging, open at the given port. -batch Disable interactive mode @@ -314,6 +315,7 @@ process_args () -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; -no-colors) addJava "-Dsbt.log.noformat=true" && shift ;; -no-share) addJava "$noshare_opts" && shift ;; + -no-global) addJava "-Dsbt.global.base=project/.sbtboot" && shift ;; -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;; -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; diff --git a/src/linux/usr/share/man/man1/sbt.1 b/src/linux/usr/share/man/man1/sbt.1 index 9c9615c6d..cb9f6c580 100644 --- a/src/linux/usr/share/man/man1/sbt.1 +++ b/src/linux/usr/share/man/man1/sbt.1 @@ -36,6 +36,8 @@ path to local Ivy repository (default: ~/.ivy2) set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) .IP "-no-share" use all local caches; no sharing +.IP "-no-global" +uses global caches, but does not use global ~/.sbt directory. .IP -offline put sbt in offline mode .SH SBT Version Options From cf14e6ba7b41b8056bd113457b6912782b3d0238 Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Wed, 18 Jan 2012 16:50:17 +0100 Subject: [PATCH 111/483] Add Jansi license file (because it is not contained in jansi.jar) --- project/packaging.scala | 9 +- src/windows/jansi-license.txt | 202 ++++++++++++++++++++++++++++++++++ 2 files changed, 208 insertions(+), 3 deletions(-) create mode 100644 src/windows/jansi-license.txt diff --git a/project/packaging.scala b/project/packaging.scala index 3886f2b52..315c22fce 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -110,8 +110,10 @@ object Packaging { //wixFile <<= sourceDirectory in Windows map (_ / "sbt.xml"), mappings in packageMsi in Windows <+= sbtLaunchJar map { f => f -> "sbt-launch.jar" }, mappings in packageMsi in Windows <+= jansiJar map { f => f -> "jansi.jar" }, - mappings in packageMsi in Windows <+= sourceDirectory in Windows map { d => - (d / "sbt.bat") -> "sbt.bat" }, + mappings in packageMsi in Windows <++= sourceDirectory in Windows map { d => Seq( + (d / "sbt.bat") -> "sbt.bat", + (d / "jansi-license.txt") -> "jansi-license.txt" + )}, mappings in packageMsi in Windows <+= (compile in Compile, classDirectory in Compile) map { (c, d) => compile; (d / "SbtJansiLaunch.class") -> "SbtJansiLaunch.class" @@ -172,8 +174,9 @@ object Packaging { - + + diff --git a/src/windows/jansi-license.txt b/src/windows/jansi-license.txt new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/src/windows/jansi-license.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From f889a92c340c31cd076160520d06d568282690dd Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Wed, 18 Jan 2012 16:57:48 +0100 Subject: [PATCH 112/483] Reflow License.rtf to make it more readable in the Windows installer --- src/windows/License.rtf | Bin 1812 -> 1724 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/windows/License.rtf b/src/windows/License.rtf index 218b930464d9086391baa7a0a2c037be41af5b83..4f90c8da4330e1b2820ec9f9e5c134b258983d9e 100644 GIT binary patch delta 89 zcmbQjw}*Gb21Z7O$=ev6faE_$|H+|D9h09jxlA@>o;>*sv(IEX78jsQ28$<<+|JSq kB)wQYCU>z2PF}%k3FJLzbp?_}Y|cQkn#}`9o@Da|03NLyX8-^I delta 177 zcmdnPJB4q<21d4+g2W>V0O!Nt>GmNRh23K3i<_!QjJTnXc From bc12a127ee24c9e0be0f3c6be3038780b04b3cc2 Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Wed, 18 Jan 2012 16:58:30 +0100 Subject: [PATCH 113/483] Add sbt launcher script for Cygwin and MSYS to Windows installer --- project/packaging.scala | 12 +++++++++--- src/windows/sbt | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 src/windows/sbt diff --git a/project/packaging.scala b/project/packaging.scala index 315c22fce..bb1321e0c 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -112,6 +112,7 @@ object Packaging { mappings in packageMsi in Windows <+= jansiJar map { f => f -> "jansi.jar" }, mappings in packageMsi in Windows <++= sourceDirectory in Windows map { d => Seq( (d / "sbt.bat") -> "sbt.bat", + (d / "sbt") -> "sbt", (d / "jansi-license.txt") -> "jansi-license.txt" )}, mappings in packageMsi in Windows <+= (compile in Compile, classDirectory in Compile) map { (c, d) => @@ -148,7 +149,7 @@ object Packaging { case Array(major) => Seq(major,"0","0","1") mkString "." } ( - + - - + + + + + + + diff --git a/src/windows/sbt b/src/windows/sbt new file mode 100644 index 000000000..f607847c5 --- /dev/null +++ b/src/windows/sbt @@ -0,0 +1,20 @@ +#!/bin/sh + +# sbt launcher script for Cygwin and MSYS + +UDIR=`dirname "$0"` +if [ -z "$MSYSTEM" ]; then + WDIR=`cygpath -alm "$UDIR"` +else + WDIR=`echo "$UDIR" | sed -e 's~^/\([^/]*\)/~\1:/~'` +fi + +if [ "_$TERM" = "_xterm" ]; then + # Let the terminal handle ANSI sequences + LAUNCHER=xsbt.boot.Boot +else + # Use Jansi to intercept ANSI sequences + LAUNCHER=SbtJansiLaunch +fi + +java -Xmx512M -Dsbt.log.format=true -cp "$WDIR/jansi.jar;$WDIR/sbt-launch.jar;$WDIR/classes" $LAUNCHER $@ From 7e5b93fbf8ba37281445c665ef7817437b16ed09 Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Wed, 18 Jan 2012 17:32:39 +0100 Subject: [PATCH 114/483] Make sbt/jline work properly in Cygwin's MinTTY terminal --- src/windows/sbt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/windows/sbt b/src/windows/sbt index f607847c5..e2fbdb5e6 100644 --- a/src/windows/sbt +++ b/src/windows/sbt @@ -1,7 +1,9 @@ #!/bin/sh - # sbt launcher script for Cygwin and MSYS +JAVA_CMD=java +JAVA_OPTS=-Xmx512M + UDIR=`dirname "$0"` if [ -z "$MSYSTEM" ]; then WDIR=`cygpath -alm "$UDIR"` @@ -11,10 +13,10 @@ fi if [ "_$TERM" = "_xterm" ]; then # Let the terminal handle ANSI sequences - LAUNCHER=xsbt.boot.Boot + stty -icanon min 1 -echo > /dev/null 2>&1 + $JAVA_CMD $JAVA_OPTS -Djline.terminal=jline.UnixTerminal -jar "$WDIR/sbt-launch.jar" $@ + stty icanon echo > /dev/null 2>&1 else # Use Jansi to intercept ANSI sequences - LAUNCHER=SbtJansiLaunch + $JAVA_CMD $JAVA_OPTS -Dsbt.log.format=true -cp "$WDIR/jansi.jar;$WDIR/sbt-launch.jar;$WDIR/classes" SbtJansiLaunch $@ fi - -java -Xmx512M -Dsbt.log.format=true -cp "$WDIR/jansi.jar;$WDIR/sbt-launch.jar;$WDIR/classes" $LAUNCHER $@ From dbd24d135807a246b4a9545a5b164e92f9ac8994 Mon Sep 17 00:00:00 2001 From: Bart Schuller Date: Tue, 24 Jan 2012 10:10:39 +0100 Subject: [PATCH 115/483] Fix stderr redirect shell syntax To prevent the following error (MacOS X 10.7): ./sbt: command substitution: line 222: syntax error near unexpected token `&' ./sbt: command substitution: line 222: `java -version |& grep version' --- sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbt b/sbt index 5c82961c0..7930e53f9 100755 --- a/sbt +++ b/sbt @@ -250,7 +250,7 @@ Usage: $script_name [options] -scala-home use the scala build at the specified directory -scala-version use the specified version of scala - # java version (default: java from PATH, currently $(java -version |& grep version)) + # java version (default: java from PATH, currently $(java -version 2>&1 | grep version)) -java-home alternate JAVA_HOME # jvm options and output control From fd13ebac8d954c48c342429d8614a2d92dc91c5c Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 2 Feb 2012 12:09:03 -0500 Subject: [PATCH 116/483] Fixed help documentation of sbtopts files. --- sbt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sbt b/sbt index 7930e53f9..e2db67998 100755 --- a/sbt +++ b/sbt @@ -254,12 +254,15 @@ Usage: $script_name [options] -java-home alternate JAVA_HOME # jvm options and output control - JAVA_OPTS environment variable, if unset uses "$java_opts" - SBT_OPTS environment variable, if unset uses "$default_sbt_opts" - .sbtopts if this file exists in the sbt root, it is prepended to the runner args - -Dkey=val pass -Dkey=val directly to the java runtime - -J-X pass option -X directly to the java runtime (-J is stripped) - -S-X add -X to sbt's scalacOptions (-J is stripped) + JAVA_OPTS environment variable, if unset uses "$java_opts" + SBT_OPTS environment variable, if unset uses "$default_sbt_opts" + .sbtopts if this file exists in the current directory, it is + prepended to the runner args + /etc/sbt/sbtopts if this file exists, it is prepended to the runner args + -Dkey=val pass -Dkey=val directly to the java runtime + -J-X pass option -X directly to the java runtime + (-J is stripped) + -S-X add -X to sbt's scalacOptions (-J is stripped) In the case of duplicated or conflicting options, the order above shows precedence: JAVA_OPTS lowest, command line options highest. From cea72e8ca7efc2a92b16b21b5253d3017ff7643e Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 1 Feb 2012 09:42:40 -0500 Subject: [PATCH 117/483] Adding a library for launcher scripts. * Moved sbt into src/linux (for now, to disambiguate from windows) * Created sbt-launch-lib.bash to help scripts which want to use the SBT Launcher but are not SBT, e.g. g8 or cs. --- project/packaging.scala | 5 +- sbt => src/linux/sbt | 14 +-- src/linux/sbt-launch-lib.bash | 201 ++++++++++++++++++++++++++++++++++ 3 files changed, 211 insertions(+), 9 deletions(-) rename sbt => src/linux/sbt (99%) create mode 100644 src/linux/sbt-launch-lib.bash diff --git a/project/packaging.scala b/project/packaging.scala index bb1321e0c..1698e3ff3 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -47,8 +47,9 @@ object Packaging { packageSummary := "Simple Build Tool for Scala-driven builds", packageDescription := """This script provides a native way to run the Simple Build Tool, a build tool for Scala software, also called SBT.""", - linuxPackageMappings <+= (baseDirectory) map { bd => - (packageMapping((bd / "sbt") -> "/usr/bin/sbt") + linuxPackageMappings <+= (sourceDirectory in Linux) map { bd => + (packageMapping((bd / "sbt") -> "/usr/bin/sbt", + (bd / "sbt-launch-lib.sh") -> "/usr/share/sbt/sbt-launch-lib.sh") withUser "root" withGroup "root" withPerms "0755") }, linuxPackageMappings <+= (sourceDirectory) map { bd => diff --git a/sbt b/src/linux/sbt similarity index 99% rename from sbt rename to src/linux/sbt index e2db67998..29c83f0e1 100755 --- a/sbt +++ b/src/linux/sbt @@ -25,7 +25,7 @@ get_mem_opts () { (( $perm > 256 )) || perm=256 (( $perm < 1024 )) || perm=1024 local codecache=$(( $perm / 2 )) - + echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" } @@ -167,7 +167,7 @@ jar_file () { sbt_artifactory_list () { local type="$1" # -RC or -SNAPSHOT local version=${sbt_version%-SNAPSHOT} - + curl -s --list-only "$sbt_snapshot_baseurl" | \ grep -F $version | \ perl -e 'print reverse <>' | \ @@ -190,7 +190,7 @@ sbt_snapshot_actual_version () { download_url () { local url="$1" local jar="$2" - + echo "Downloading sbt launcher $sbt_version:" echo " From $url" echo " To $jar" @@ -210,7 +210,7 @@ acquire_sbt_jar () { elif [[ ! $sbt_version ]]; then sbt_version=$sbt_release_version fi - + sbt_url="$(jar_url)" sbt_jar="$(jar_file $sbt_version)" @@ -302,7 +302,7 @@ process_args () local type="$1" local opt="$2" local arg="$3" - + if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then die "$opt requires <$type> argument" fi @@ -345,10 +345,10 @@ process_args () *) addResidual "$1" && shift ;; esac done - + [[ $debug ]] && { case "$sbt_version" in - 0.7*) addSbt "debug" ;; + 0.7*) addSbt "debug" ;; *) addSbt "set logLevel in Global := Level.Debug" ;; esac } diff --git a/src/linux/sbt-launch-lib.bash b/src/linux/sbt-launch-lib.bash new file mode 100644 index 000000000..7be2589df --- /dev/null +++ b/src/linux/sbt-launch-lib.bash @@ -0,0 +1,201 @@ +#!/usr/bin/env bash +# + +# A library to simplify using the SBT launcher from other packages. +# Note: This should be used by tools like giter8/conscript etc. + +# TODO - Should we merge the main SBT script with this library? + +# TODO - Don't hardcode this. +declare sbt_version="0.11.2" +declare -r sbt_release_version=0.11.2 +declare -r sbt_snapshot_version=0.11.3-SNAPSHOT + +if test -z "$HOME"; then + declare -r script_dir="$(dirname $script_path)" +else + declare -r script_dir="$HOME/.sbt" +fi + +declare -a residual_args +declare -a java_args +declare -a scalac_args +declare -a sbt_commands +declare java_cmd=java + +echoerr () { + echo 1>&2 "$@" +} +vlog () { + [[ $verbose || $debug ]] && echoerr "$@" +} +dlog () { + [[ $debug ]] && echoerr "$@" +} + +sbtjar_release_url () { + echo "http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/$sbt_version/sbt-launch.jar" +} + +sbtjar_snapshot_url () { + local ver="$sbt_version" + if [[ "$sbt_version" = *-SNAPSHOT ]]; then + ver=$(sbt_snapshot_actual_version -SNAPSHOT) + echoerr "sbt snapshot is $ver" + elif [[ "$sbt_version" = *-SNAPSHOT ]]; then + ver=$(sbt_snapshot_actual_version -RC) + echoerr "sbt rc is $ver" + fi + + echo "${sbt_snapshot_baseurl}${ver}/sbt-launch.jar" +} + +jar_url () { + case $sbt_version in + *-SNAPSHOT*) sbtjar_snapshot_url ;; + *-RC*) sbtjar_snapshot_url ;; + *) sbtjar_release_url ;; + esac +} + +jar_file () { + if [[ -f "/usr/lib/sbt/$1/sbt-launch.jar" ]]; then + echo "/usr/lib/sbt/$1/sbt-launch.jar" + else + echo "$script_dir/.lib/$1/sbt-launch.jar" + fi +} + +download_url () { + local url="$1" + local jar="$2" + + echo "Downloading sbt launcher $sbt_version:" + echo " From $url" + echo " To $jar" + + mkdir -p $(dirname "$jar") && { + if which curl >/dev/null; then + curl --silent "$url" --output "$jar" + elif which wget >/dev/null; then + wget --quiet -O "$jar" "$url" + fi + } && [[ -f "$jar" ]] +} + +acquire_sbt_jar () { + local sbt_version="$1" + + sbt_url="$(jar_url)" + sbt_jar="$(jar_file $sbt_version)" + + [[ -f "$sbt_jar" ]] || download_url "$sbt_url" "$sbt_jar" +} + +execRunner () { + # print the arguments one to a line, quoting any containing spaces + [[ $verbose || $debug ]] && echo "# Executing command line:" && { + for arg; do + if printf "%s\n" "$arg" | grep -q ' '; then + printf "\"%s\"\n" "$arg" + else + printf "%s\n" "$arg" + fi + done + echo "" + } + + exec "$@" +} + +addJava () { + dlog "[addJava] arg = '$1'" + java_args=( "${java_args[@]}" "$1" ) +} +addSbt () { + dlog "[addSbt] arg = '$1'" + sbt_commands=( "${sbt_commands[@]}" "$1" ) +} +addResidual () { + dlog "[residual] arg = '$1'" + residual_args=( "${residual_args[@]}" "$1" ) +} +addDebugger () { + addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" +} + +# a ham-fisted attempt to move some memory settings in concert +# so they need not be dicked around with individually. +get_mem_opts () { + local mem=${1:-1536} + local perm=$(( $mem / 4 )) + (( $perm > 256 )) || perm=256 + (( $perm < 1024 )) || perm=1024 + local codecache=$(( $perm / 2 )) + + echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" +} + +process_args () { + require_arg () { + local type="$1" + local opt="$2" + local arg="$3" + + if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then + die "$opt requires <$type> argument" + fi + } + while [[ $# -gt 0 ]]; do + case "$1" in + -h|-help) usage; exit 1 ;; + -v|-verbose) verbose=1 && shift ;; + -d|-debug) debug=1 && shift ;; + # -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload && shift ;; + + -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; + -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; + -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; + -batch) exec Date: Thu, 2 Feb 2012 12:28:40 -0500 Subject: [PATCH 118/483] Added sbt-launch script helper --- project/packaging.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/packaging.scala b/project/packaging.scala index 1698e3ff3..56b98dd5b 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -49,7 +49,7 @@ object Packaging { a build tool for Scala software, also called SBT.""", linuxPackageMappings <+= (sourceDirectory in Linux) map { bd => (packageMapping((bd / "sbt") -> "/usr/bin/sbt", - (bd / "sbt-launch-lib.sh") -> "/usr/share/sbt/sbt-launch-lib.sh") + (bd / "sbt-launch-lib.bash") -> "/usr/share/sbt/sbt-launch-lib.bash") withUser "root" withGroup "root" withPerms "0755") }, linuxPackageMappings <+= (sourceDirectory) map { bd => From 531f728ac5a80d41f9c881cf4765a81f5cf62b55 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 2 Feb 2012 13:03:52 -0500 Subject: [PATCH 119/483] Quick fix for generating RPMs with owned directory for /usr/share/sbt --- project/packaging.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/project/packaging.scala b/project/packaging.scala index 56b98dd5b..0a1716703 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -49,6 +49,7 @@ object Packaging { a build tool for Scala software, also called SBT.""", linuxPackageMappings <+= (sourceDirectory in Linux) map { bd => (packageMapping((bd / "sbt") -> "/usr/bin/sbt", + bd -> "/usr/share/sbt", (bd / "sbt-launch-lib.bash") -> "/usr/share/sbt/sbt-launch-lib.bash") withUser "root" withGroup "root" withPerms "0755") }, From 0271bf92e267fe4b7cb496d848b8e5f0b4a65001 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 2 Feb 2012 15:35:38 -0500 Subject: [PATCH 120/483] Improvements to sbt.bat suggested by @retronym --- project/packaging.scala | 1 + src/windows/sbt.bat | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/project/packaging.scala b/project/packaging.scala index 6f8b7dcf5..2af79e724 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -173,6 +173,7 @@ object Packaging { diff --git a/src/windows/sbt.bat b/src/windows/sbt.bat index 70ccb8de0..84881fdb4 100644 --- a/src/windows/sbt.bat +++ b/src/windows/sbt.bat @@ -1,3 +1,42 @@ +@REM SBT launcher script +@REM +@REM Envioronment: +@REM JAVA_HOME - location of a JDK home dir (mandatory) +@REM SBT_OPTS - JVM options (optional) + + +@setlocal + @echo off set SBT_HOME=%~dp0 -java -Xmx512M -Dsbt.log.format=true -cp "%SBT_HOME%jansi.jar;%SBT_HOME%sbt-launch.jar;%SBT_HOME%classes" SbtJansiLaunch %* +set ERROR_CODE=0 + +rem We use the value of the JAVACMD environment variable if defined +set _JAVACMD=%JAVACMD% + +if "%_JAVACMD%"=="" ( + if not "%JAVA_HOME%"=="" ( + if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe" + ) +) + +if "%_JAVACMD%"=="" set _JAVACMD=java + +rem We use the value of the JAVA_OPTS environment variable if defined +set _JAVA_OPTS=%JAVA_OPTS% +if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=-Xmx512M -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=128m -Dsbt.log.format=true + +:run + +"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%jansi.jar;%SBT_HOME%sbt-launch.jar;%SBT_HOME%classes" SbtJansiLaunch %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end + +@endlocal + +exit /B %ERROR_CODE% \ No newline at end of file From f529e2a63e72c3c24923128b04a673d1da8bfc3a Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 2 Feb 2012 21:10:37 -0500 Subject: [PATCH 121/483] Added SBT_HOME environment variable for other windows packages. --- project/packaging.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/project/packaging.scala b/project/packaging.scala index 2af79e724..66a3d7eee 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -205,6 +205,7 @@ object Packaging { + From d1298a8d36a282180f257e8625f7c405de61c465 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 15 Feb 2012 07:05:52 -0500 Subject: [PATCH 122/483] Removed 32-bit java version check for 64-bit support --- project/packaging.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/packaging.scala b/project/packaging.scala index 66a3d7eee..180f641c4 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -223,7 +223,7 @@ object Packaging { - + Date: Thu, 15 Mar 2012 14:22:10 -0400 Subject: [PATCH 123/483] updated to latest native packager, added universal 'zip' generation to the build. --- project/packaging.scala | 44 +-- project/project/plugins.scala | 2 +- src/universal/bin/sbt | 406 ++++++++++++++++++++++++++ src/universal/bin/sbt-launch-lib.bash | 201 +++++++++++++ 4 files changed, 622 insertions(+), 31 deletions(-) create mode 100755 src/universal/bin/sbt create mode 100755 src/universal/bin/sbt-launch-lib.bash diff --git a/project/packaging.scala b/project/packaging.scala index 180f641c4..120eaee8c 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -124,37 +124,21 @@ object Packaging { javacOptions := Seq("-source", "1.5", "-target", "1.5"), unmanagedJars in Compile <+= sbtLaunchJar map identity, unmanagedJars in Compile <+= jansiJar map identity, - // WINDOWS MSI Publishing - resolvers += Resolver.url("windows-releases", new URL(winowsReleaseUrl))(Patterns(localWindowsPattern)) - ) ++ (inConfig(Windows)(Classpaths.publishSettings)) ++ (inConfig(Windows)(Seq( - packagedArtifacts <<= (packageMsi, name) map { (msi, name) => - val artifact = Artifact(name, "msi", "msi", classifier = None, configurations = Iterable.empty, url = None, extraAttributes = Map.empty) - Map(artifact -> msi) - }, - publishMavenStyle := true, - projectID <<= (organization, name, sbtVersion) apply { (o,n,v) => ModuleID(o,n,v) }, - moduleSettings <<= (projectID, projectInfo) map { (pid, pinfo) => - InlineConfiguration(pid, pinfo, Seq.empty) - }, - ivyModule <<= (ivySbt, moduleSettings) map { (i, s) => new i.Module(s) }, - deliverLocalConfiguration <<= (crossTarget, ivyLoggingLevel) map { (outDir, level) => Classpaths.deliverConfig(outDir, logging = level) }, - deliverConfiguration <<= deliverLocalConfiguration, - publishTo := Some(Resolver.url("windows-releases", new URL(winowsReleaseUrl))(Patterns(localWindowsPattern))), - publishConfiguration <<= (packagedArtifacts, checksums, publishTo) map { (as, checks, publishTo) => - new PublishConfiguration(ivyFile = None, - resolverName = Classpaths.getPublishTo(publishTo).name, - artifacts = as, - checksums = checks, - logging = UpdateLogging.DownloadOnly) - }, - publishLocalConfiguration <<= (packagedArtifacts, checksums) map { (as, checks) => - new PublishConfiguration(ivyFile = None, - resolverName = "local", - artifacts = as, - checksums = checks, - logging = UpdateLogging.DownloadOnly) + + // Universal ZIP download install. TODO - Share the above windows code, here.... + mappings in Universal <+= sbtLaunchJar map { f => f -> "bin/sbt-launch.jar" }, + mappings in Universal <+= jansiJar map { f => f -> "bin/jansi.jar" }, + mappings in Universal <++= sourceDirectory in Windows map { d => Seq( + (d / "sbt.bat") -> "bin/sbt.bat", + (d / "sbt") -> "bin/win-sbt", + (d / "jansi-license.txt") -> "jansi-license.txt" + )}, + mappings in Universal <+= (compile in Compile, classDirectory in Compile) map { (c, d) => + compile; + (d / "SbtJansiLaunch.class") -> "bin/SbtJansiLaunch.class" } - ))) + // TODO - Adapt global `sbt`/`sbt-launch-lib` scripts for universal install... + ) def makeWindowsXml(sbtVersion: String, sourceDir: File): scala.xml.Node = { val version = (sbtVersion split "\\.") match { diff --git a/project/project/plugins.scala b/project/project/plugins.scala index a5466f04f..1a76e31f8 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -6,7 +6,7 @@ object PluginBuild extends Build { val root = Project("root", file(".")) settings( resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), - addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.1.0"), + addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.3.0"), libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.6" ) } diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt new file mode 100755 index 000000000..28357cf0b --- /dev/null +++ b/src/universal/bin/sbt @@ -0,0 +1,406 @@ +#!/usr/bin/env bash +# +# A more capable sbt runner, coincidentally also called sbt. +# Author: Paul Phillips + +# this seems to cover the bases on OSX, and someone will +# have to tell me about the others. +get_script_path () { + local path="$1" + [[ -L "$path" ]] || { echo "$path" ; return; } + + local target=$(readlink "$path") + if [[ "${target:0:1}" == "/" ]]; then + echo "$target" + else + echo "$path/$target" + fi +} + +# a ham-fisted attempt to move some memory settings in concert +# so they need not be dicked around with individually. +get_mem_opts () { + local mem=${1:-1536} + local perm=$(( $mem / 4 )) + (( $perm > 256 )) || perm=256 + (( $perm < 1024 )) || perm=1024 + local codecache=$(( $perm / 2 )) + + echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" +} + +is_owned_by_user () { + [[ "$(stat --printf='%U' $1)" == "$(USER)" ]] && { echo "OK" ; return; } +} + +die() { + echo "Aborting: $@" + exit 1 +} + +# todo - make this dynamic +declare -r sbt_release_version=0.11.2 +unset sbt_rc_version +# declare -r sbt_rc_version= +declare -r sbt_snapshot_version=0.11.3-SNAPSHOT +declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" + +declare -r default_java_opts="-Dfile.encoding=UTF8" +declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled" +declare -r default_sbt_mem=1536 +declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" +declare -r sbt_opts_file=".sbtopts" +declare -r etc_sbt_opts_file="/etc/sbt/sbtopts" +declare -r latest_28="2.8.2" +declare -r latest_29="2.9.1" +declare -r latest_210="2.10.0-SNAPSHOT" + +declare -r script_path=$(get_script_path "$BASH_SOURCE") +if test -z "$HOME"; then + declare -r script_dir="$(dirname $script_path)" +else + declare -r script_dir="$HOME/.sbt" +fi +declare -r script_name="$(basename $script_path)" + +declare java_cmd=java +declare sbt_mem=$default_sbt_mem +declare java_opts="${JAVA_OPTS:-$default_java_opts}" + +unset sbt_jar sbt_create sbt_version sbt_snapshot +unset scala_version +unset java_home +unset verbose debug + +# pull -J and -D options to give to java. +declare -a residual_args +declare -a java_args +declare -a scalac_args +declare -a sbt_commands + +build_props_sbt () { + if [[ -f project/build.properties ]]; then + versionLine=$(grep ^sbt.version project/build.properties) + versionString=${versionLine##sbt.version=} + echo "$versionString" + fi +} +build_props_scala () { + if [[ -f project/build.properties ]]; then + versionLine=$(grep ^build.scala.versions project/build.properties) + versionString=${versionLine##build.scala.versions=} + echo ${versionString%% .*} + fi +} + +isSnapshot () { + [[ "$sbt_version" = *-SNAPSHOT* ]] +} +isRC () { + [[ "$sbt_version" = *-RC* ]] +} + +execRunner () { + # print the arguments one to a line, quoting any containing spaces + [[ $verbose || $debug ]] && echo "# Executing command line:" && { + for arg; do + if printf "%s\n" "$arg" | grep -q ' '; then + printf "\"%s\"\n" "$arg" + else + printf "%s\n" "$arg" + fi + done + echo "" + } + + exec "$@" +} + +echoerr () { + echo 1>&2 "$@" +} +vlog () { + [[ $verbose || $debug ]] && echoerr "$@" +} +dlog () { + [[ $debug ]] && echoerr "$@" +} + +sbtjar_07_url () { + echo "http://simple-build-tool.googlecode.com/files/sbt-launch-${1}.jar" +} +sbtjar_release_url () { + echo "http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/$sbt_version/sbt-launch.jar" +} +sbtjar_snapshot_url () { + local ver="$sbt_version" + if [[ "$sbt_version" = *-SNAPSHOT ]]; then + ver=$(sbt_snapshot_actual_version -SNAPSHOT) + echoerr "sbt snapshot is $ver" + elif [[ "$sbt_version" = *-SNAPSHOT ]]; then + ver=$(sbt_snapshot_actual_version -RC) + echoerr "sbt rc is $ver" + fi + + echo "${sbt_snapshot_baseurl}${ver}/sbt-launch.jar" +} +jar_url () { + case $sbt_version in + 0.7.4*) sbtjar_07_url 0.7.4 ;; + 0.7.5*) sbtjar_07_url 0.7.5 ;; + 0.7.7*) sbtjar_07_url 0.7.7 ;; + 0.7.*) sbtjar_07_url 0.7.7 ;; + *-SNAPSHOT*) sbtjar_snapshot_url ;; + *-RC*) sbtjar_snapshot_url ;; + *) sbtjar_release_url ;; + esac +} + +jar_file () { + # TODO - Allow alternative versions, maybe... + if [[ -f "$(dirname $0)/sbt-launch.jar" ]]; then + echo "$(dirname $0)/sbt-launch.jar" + else + echo "$script_dir/.lib/$1/sbt-launch.jar" + fi +} + +sbt_artifactory_list () { + local type="$1" # -RC or -SNAPSHOT + local version=${sbt_version%-SNAPSHOT} + + curl -s --list-only "$sbt_snapshot_baseurl" | \ + grep -F $version | \ + perl -e 'print reverse <>' | \ + perl -pe 's#^/dev/null + dlog "curl returned: $?" + echo "$ver" + return + done +} + +download_url () { + local url="$1" + local jar="$2" + + echo "Downloading sbt launcher $sbt_version:" + echo " From $url" + echo " To $jar" + + mkdir -p $(dirname "$jar") && { + if which curl >/dev/null; then + curl --silent "$url" --output "$jar" + elif which wget >/dev/null; then + wget --quiet -O "$jar" "$url" + fi + } && [[ -f "$jar" ]] +} + +acquire_sbt_jar () { + if [[ $sbt_snapshot ]]; then + sbt_version=$sbt_snapshot_version + elif [[ ! $sbt_version ]]; then + sbt_version=$sbt_release_version + fi + + sbt_url="$(jar_url)" + sbt_jar="$(jar_file $sbt_version)" + + [[ -f "$sbt_jar" ]] || download_url "$sbt_url" "$sbt_jar" +} + + +usage () { + cat < path to global settings/plugins directory (default: ~/.sbt) + -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) + -ivy path to local Ivy repository (default: ~/.ivy2) + -mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) + -no-share use all local caches; no sharing + -no-global uses global caches, but does not use global ~/.sbt directory. + -offline put sbt in offline mode + -jvm-debug Turn on JVM debugging, open at the given port. + -batch Disable interactive mode + + # scala version (default: latest release) + -28 use $latest_28 + -29 use $latest_29 + -210 use $latest_210 + -scala-home use the scala build at the specified directory + -scala-version use the specified version of scala + + # java version (default: java from PATH, currently $(java -version 2>&1 | grep version)) + -java-home alternate JAVA_HOME + + # jvm options and output control + JAVA_OPTS environment variable, if unset uses "$java_opts" + SBT_OPTS environment variable, if unset uses "$default_sbt_opts" + .sbtopts if this file exists in the current directory, it is + prepended to the runner args + /etc/sbt/sbtopts if this file exists, it is prepended to the runner args + -Dkey=val pass -Dkey=val directly to the java runtime + -J-X pass option -X directly to the java runtime + (-J is stripped) + -S-X add -X to sbt's scalacOptions (-J is stripped) + +In the case of duplicated or conflicting options, the order above +shows precedence: JAVA_OPTS lowest, command line options highest. +EOM +} + +addJava () { + dlog "[addJava] arg = '$1'" + java_args=( "${java_args[@]}" "$1" ) +} +addSbt () { + dlog "[addSbt] arg = '$1'" + sbt_commands=( "${sbt_commands[@]}" "$1" ) +} +addScalac () { + dlog "[addScalac] arg = '$1'" + scalac_args=( "${scalac_args[@]}" "$1" ) +} +addResidual () { + dlog "[residual] arg = '$1'" + residual_args=( "${residual_args[@]}" "$1" ) +} +addResolver () { + addSbt "set resolvers in ThisBuild += $1" +} +unset addedSnapshotRepo +addSnapshotRepo () { + [[ -n "$addedSnapshotRepo" ]] || addResolver "ScalaToolsSnapshots" && addedSnapshotRepo=true +} +addDebugger () { + addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" +} + +process_args () +{ + require_arg () { + local type="$1" + local opt="$2" + local arg="$3" + + if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then + die "$opt requires <$type> argument" + fi + } + while [[ $# -gt 0 ]]; do + case "$1" in + -h|-help) usage; exit 1 ;; + -v|-verbose) verbose=1 && shift ;; + -d|-debug) debug=1 && shift ;; + # -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload && shift ;; + + -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; + -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; + -no-colors) addJava "-Dsbt.log.noformat=true" && shift ;; + -no-share) addJava "$noshare_opts" && shift ;; + -no-global) addJava "-Dsbt.global.base=project/.sbtboot" && shift ;; + -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; + -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;; + -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; + -offline) addSbt "set offline := true" && shift ;; + -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; + -batch) exec 0 )) || echo "Starting $script_name: invoke with -help for other options" + +# verify this is an sbt dir or -create was given +[[ -f ./build.sbt || -d ./project || -n "$sbt_create" ]] || { + cat <&2 "$@" +} +vlog () { + [[ $verbose || $debug ]] && echoerr "$@" +} +dlog () { + [[ $debug ]] && echoerr "$@" +} + +sbtjar_release_url () { + echo "http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/$sbt_version/sbt-launch.jar" +} + +sbtjar_snapshot_url () { + local ver="$sbt_version" + if [[ "$sbt_version" = *-SNAPSHOT ]]; then + ver=$(sbt_snapshot_actual_version -SNAPSHOT) + echoerr "sbt snapshot is $ver" + elif [[ "$sbt_version" = *-SNAPSHOT ]]; then + ver=$(sbt_snapshot_actual_version -RC) + echoerr "sbt rc is $ver" + fi + + echo "${sbt_snapshot_baseurl}${ver}/sbt-launch.jar" +} + +jar_url () { + case $sbt_version in + *-SNAPSHOT*) sbtjar_snapshot_url ;; + *-RC*) sbtjar_snapshot_url ;; + *) sbtjar_release_url ;; + esac +} + +jar_file () { + if [[ -f "$(dirname $0)/sbt-launch.jar" ]]; then + echo "$(dirname $0)/sbt-launch.jar" + else + echo "$script_dir/.lib/$1/sbt-launch.jar" + fi +} + +download_url () { + local url="$1" + local jar="$2" + + echo "Downloading sbt launcher $sbt_version:" + echo " From $url" + echo " To $jar" + + mkdir -p $(dirname "$jar") && { + if which curl >/dev/null; then + curl --silent "$url" --output "$jar" + elif which wget >/dev/null; then + wget --quiet -O "$jar" "$url" + fi + } && [[ -f "$jar" ]] +} + +acquire_sbt_jar () { + local sbt_version="$1" + + sbt_url="$(jar_url)" + sbt_jar="$(jar_file $sbt_version)" + + [[ -f "$sbt_jar" ]] || download_url "$sbt_url" "$sbt_jar" +} + +execRunner () { + # print the arguments one to a line, quoting any containing spaces + [[ $verbose || $debug ]] && echo "# Executing command line:" && { + for arg; do + if printf "%s\n" "$arg" | grep -q ' '; then + printf "\"%s\"\n" "$arg" + else + printf "%s\n" "$arg" + fi + done + echo "" + } + + exec "$@" +} + +addJava () { + dlog "[addJava] arg = '$1'" + java_args=( "${java_args[@]}" "$1" ) +} +addSbt () { + dlog "[addSbt] arg = '$1'" + sbt_commands=( "${sbt_commands[@]}" "$1" ) +} +addResidual () { + dlog "[residual] arg = '$1'" + residual_args=( "${residual_args[@]}" "$1" ) +} +addDebugger () { + addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" +} + +# a ham-fisted attempt to move some memory settings in concert +# so they need not be dicked around with individually. +get_mem_opts () { + local mem=${1:-1536} + local perm=$(( $mem / 4 )) + (( $perm > 256 )) || perm=256 + (( $perm < 1024 )) || perm=1024 + local codecache=$(( $perm / 2 )) + + echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" +} + +process_args () { + require_arg () { + local type="$1" + local opt="$2" + local arg="$3" + + if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then + die "$opt requires <$type> argument" + fi + } + while [[ $# -gt 0 ]]; do + case "$1" in + -h|-help) usage; exit 1 ;; + -v|-verbose) verbose=1 && shift ;; + -d|-debug) debug=1 && shift ;; + # -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload && shift ;; + + -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; + -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; + -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; + -batch) exec Date: Thu, 15 Mar 2012 14:31:10 -0400 Subject: [PATCH 124/483] Modified name of universal zip to be 'sbt' --- project/packaging.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/project/packaging.scala b/project/packaging.scala index 120eaee8c..2b1fffc92 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -126,6 +126,7 @@ object Packaging { unmanagedJars in Compile <+= jansiJar map identity, // Universal ZIP download install. TODO - Share the above windows code, here.... + name in Universal := "sbt", mappings in Universal <+= sbtLaunchJar map { f => f -> "bin/sbt-launch.jar" }, mappings in Universal <+= jansiJar map { f => f -> "bin/jansi.jar" }, mappings in Universal <++= sourceDirectory in Windows map { d => Seq( From 8f4f02e4ace477a2cb915f3758dc4a4d6e2f1590 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 15 Mar 2012 14:51:35 -0400 Subject: [PATCH 125/483] fixed bug with missing file --- project/packaging.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project/packaging.scala b/project/packaging.scala index 2b1fffc92..a69a2b3c9 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -23,6 +23,8 @@ object Packaging { sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) => import dispatch._ if(!file.exists) { + // oddly, some places require us to create the file before writing... + file.createNewFile() val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(file)) try Http(url(uri) >>> writer) finally writer.close() From d4894c660d67576dafb67b3398facfd3f4d0e5bc Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 15 Mar 2012 14:54:39 -0400 Subject: [PATCH 126/483] Fix #2, yippie. --- project/packaging.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project/packaging.scala b/project/packaging.scala index a69a2b3c9..ecadddfad 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -37,6 +37,8 @@ object Packaging { jansiJar <<= (jansiJarUrl, jansiJarLocation) map { (uri, file) => import dispatch._ if(!file.exists) { + // oddly, some places require us to create the file before writing... + file.createNewFile() val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(file)) try Http(url(uri) >>> writer) finally writer.close() From 9654a037cd812f3b68f44535c4fc3bf206004b91 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 15 Mar 2012 14:57:04 -0400 Subject: [PATCH 127/483] I seem to fail at remote debugging hudson nodes if I cannot replicate locally. --- project/packaging.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/packaging.scala b/project/packaging.scala index ecadddfad..d1f6e1fa5 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -24,7 +24,7 @@ object Packaging { import dispatch._ if(!file.exists) { // oddly, some places require us to create the file before writing... - file.createNewFile() + IO.touch(file) val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(file)) try Http(url(uri) >>> writer) finally writer.close() @@ -38,7 +38,7 @@ object Packaging { import dispatch._ if(!file.exists) { // oddly, some places require us to create the file before writing... - file.createNewFile() + IO.touch(file) val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(file)) try Http(url(uri) >>> writer) finally writer.close() From 4094af83047b5eb36029c12f9e177c69e650c21f Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 28 Mar 2012 16:11:05 -0400 Subject: [PATCH 128/483] Bumped for new version of native packager --- project/project/plugins.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/project/plugins.scala b/project/project/plugins.scala index 1a76e31f8..c456b6265 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -6,7 +6,7 @@ object PluginBuild extends Build { val root = Project("root", file(".")) settings( resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), - addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.3.0"), + addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.0"), libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.6" ) } From a0cbb9e48817ac0444d6e59deeb6e1371bd73b01 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 29 Mar 2012 10:06:33 -0400 Subject: [PATCH 129/483] Fixed univeral jar so the class files are in the right location. --- project/packaging.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/packaging.scala b/project/packaging.scala index d1f6e1fa5..3a09123a5 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -140,7 +140,7 @@ object Packaging { )}, mappings in Universal <+= (compile in Compile, classDirectory in Compile) map { (c, d) => compile; - (d / "SbtJansiLaunch.class") -> "bin/SbtJansiLaunch.class" + (d / "SbtJansiLaunch.class") -> "bin/classes/SbtJansiLaunch.class" } // TODO - Adapt global `sbt`/`sbt-launch-lib` scripts for universal install... ) From 6775c0e6849fbd9a137f0b44b08d006b196e3c45 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 7 May 2012 08:15:42 -0400 Subject: [PATCH 130/483] Fixes to build with SBT 0.11.3 --- project/packaging.scala | 2 +- project/project/plugins.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/packaging.scala b/project/packaging.scala index 3a09123a5..bce170993 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -18,7 +18,7 @@ object Packaging { def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]" val settings: Seq[Setting[_]] = packagerSettings ++ Seq( - sbtLaunchJarUrl <<= sbtVersion apply ("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+_+"/sbt-launch.jar"), + sbtLaunchJarUrl <<= sbtVersion apply ("http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+_+"/sbt-launch.jar"), sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"), sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) => import dispatch._ diff --git a/project/project/plugins.scala b/project/project/plugins.scala index c456b6265..2cef8a1aa 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -6,7 +6,7 @@ object PluginBuild extends Build { val root = Project("root", file(".")) settings( resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), - addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.0"), + addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.1"), libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.6" ) } From 70d0b31904e4800c0d1ef5d352fb2f959e7048ef Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 7 May 2012 08:19:44 -0400 Subject: [PATCH 131/483] Bumped version numbers for 0.11.3 --- src/linux/etc/sbt/sbtopts | 2 +- src/linux/sbt | 4 ++-- src/linux/sbt-launch-lib.bash | 6 +++--- src/universal/bin/sbt | 4 ++-- src/universal/bin/sbt-launch-lib.bash | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/linux/etc/sbt/sbtopts b/src/linux/etc/sbt/sbtopts index 8373b437c..f018465af 100644 --- a/src/linux/etc/sbt/sbtopts +++ b/src/linux/etc/sbt/sbtopts @@ -36,7 +36,7 @@ #-offline # Sets the SBT version to use. -#-sbt-version 0.11.2 +#-sbt-version 0.11.3 # Scala version (default: latest release) # diff --git a/src/linux/sbt b/src/linux/sbt index 29c83f0e1..f0dc35905 100755 --- a/src/linux/sbt +++ b/src/linux/sbt @@ -39,10 +39,10 @@ die() { } # todo - make this dynamic -declare -r sbt_release_version=0.11.2 +declare -r sbt_release_version=0.11.3 unset sbt_rc_version # declare -r sbt_rc_version= -declare -r sbt_snapshot_version=0.11.3-SNAPSHOT +declare -r sbt_snapshot_version=0.11.4-SNAPSHOT declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" declare -r default_java_opts="-Dfile.encoding=UTF8" diff --git a/src/linux/sbt-launch-lib.bash b/src/linux/sbt-launch-lib.bash index 7be2589df..254ebbb81 100644 --- a/src/linux/sbt-launch-lib.bash +++ b/src/linux/sbt-launch-lib.bash @@ -7,9 +7,9 @@ # TODO - Should we merge the main SBT script with this library? # TODO - Don't hardcode this. -declare sbt_version="0.11.2" -declare -r sbt_release_version=0.11.2 -declare -r sbt_snapshot_version=0.11.3-SNAPSHOT +declare sbt_version="0.11.3" +declare -r sbt_release_version=0.11.3 +declare -r sbt_snapshot_version=0.11.4-SNAPSHOT if test -z "$HOME"; then declare -r script_dir="$(dirname $script_path)" diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 28357cf0b..1402b2442 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -39,10 +39,10 @@ die() { } # todo - make this dynamic -declare -r sbt_release_version=0.11.2 +declare -r sbt_release_version=0.11.3 unset sbt_rc_version # declare -r sbt_rc_version= -declare -r sbt_snapshot_version=0.11.3-SNAPSHOT +declare -r sbt_snapshot_version=0.11.4-SNAPSHOT declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" declare -r default_java_opts="-Dfile.encoding=UTF8" diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 2de1e0d3a..4f3c367bd 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -7,9 +7,9 @@ # TODO - Should we merge the main SBT script with this library? # TODO - Don't hardcode this. -declare sbt_version="0.11.2" -declare -r sbt_release_version=0.11.2 -declare -r sbt_snapshot_version=0.11.3-SNAPSHOT +declare sbt_version="0.11.3" +declare -r sbt_release_version=0.11.3 +declare -r sbt_snapshot_version=0.11.4-SNAPSHOT if test -z "$HOME"; then declare -r script_dir="$(dirname $script_path)" From b8173fc41bd2f0b10197bb35df92af66d6e95843 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 9 May 2012 09:40:10 -0400 Subject: [PATCH 132/483] Removed autodownload from the scripts. --- src/linux/sbt | 13 ++++--------- src/linux/sbt-launch-lib.bash | 11 +++-------- src/universal/bin/sbt | 11 +++-------- src/universal/bin/sbt-launch-lib.bash | 11 +++-------- 4 files changed, 13 insertions(+), 33 deletions(-) diff --git a/src/linux/sbt b/src/linux/sbt index f0dc35905..3aaadec93 100755 --- a/src/linux/sbt +++ b/src/linux/sbt @@ -43,7 +43,7 @@ declare -r sbt_release_version=0.11.3 unset sbt_rc_version # declare -r sbt_rc_version= declare -r sbt_snapshot_version=0.11.4-SNAPSHOT -declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" +declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-sbt/sbt-launch/" declare -r default_java_opts="-Dfile.encoding=UTF8" declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled" @@ -191,17 +191,12 @@ download_url () { local url="$1" local jar="$2" - echo "Downloading sbt launcher $sbt_version:" + echo "Cannot find sbt launcher $sbt_version" + echo "Please download: " echo " From $url" echo " To $jar" - mkdir -p $(dirname "$jar") && { - if which curl >/dev/null; then - curl --silent "$url" --output "$jar" - elif which wget >/dev/null; then - wget --quiet -O "$jar" "$url" - fi - } && [[ -f "$jar" ]] + exit 1 } acquire_sbt_jar () { diff --git a/src/linux/sbt-launch-lib.bash b/src/linux/sbt-launch-lib.bash index 254ebbb81..3e95533a9 100644 --- a/src/linux/sbt-launch-lib.bash +++ b/src/linux/sbt-launch-lib.bash @@ -70,17 +70,12 @@ download_url () { local url="$1" local jar="$2" - echo "Downloading sbt launcher $sbt_version:" + echo "Cannot find sbt launcher $sbt_version" + echo "Please download: " echo " From $url" echo " To $jar" - mkdir -p $(dirname "$jar") && { - if which curl >/dev/null; then - curl --silent "$url" --output "$jar" - elif which wget >/dev/null; then - wget --quiet -O "$jar" "$url" - fi - } && [[ -f "$jar" ]] + exit 1 } acquire_sbt_jar () { diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 1402b2442..fb81d154e 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -192,17 +192,12 @@ download_url () { local url="$1" local jar="$2" - echo "Downloading sbt launcher $sbt_version:" + echo "Cannot find sbt launcher $sbt_version" + echo "Please download: " echo " From $url" echo " To $jar" - mkdir -p $(dirname "$jar") && { - if which curl >/dev/null; then - curl --silent "$url" --output "$jar" - elif which wget >/dev/null; then - wget --quiet -O "$jar" "$url" - fi - } && [[ -f "$jar" ]] + exit 1 } acquire_sbt_jar () { diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 4f3c367bd..9acf48da2 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -70,17 +70,12 @@ download_url () { local url="$1" local jar="$2" - echo "Downloading sbt launcher $sbt_version:" + echo "Cannot find sbt launcher $sbt_version" + echo "Please download: " echo " From $url" echo " To $jar" - mkdir -p $(dirname "$jar") && { - if which curl >/dev/null; then - curl --silent "$url" --output "$jar" - elif which wget >/dev/null; then - wget --quiet -O "$jar" "$url" - fi - } && [[ -f "$jar" ]] + exit 1 } acquire_sbt_jar () { From 02f6369f17a8952d7aa78f2d21ef2c7bfe488491 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 9 May 2012 15:53:10 -0400 Subject: [PATCH 133/483] Closes #14 - Generate INstalled-Size on debian --- project/project/plugins.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/project/plugins.scala b/project/project/plugins.scala index 2cef8a1aa..7792d70e0 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -6,7 +6,7 @@ object PluginBuild extends Build { val root = Project("root", file(".")) settings( resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), - addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.1"), + addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.2"), libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.6" ) } From c91159b3638754e21b96fbc1caaa39460632b670 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 14 May 2012 12:35:27 -0400 Subject: [PATCH 134/483] fixes debian architecture bug. --- project/project/plugins.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/project/plugins.scala b/project/project/plugins.scala index 7792d70e0..b9561d413 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -6,7 +6,7 @@ object PluginBuild extends Build { val root = Project("root", file(".")) settings( resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), - addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.2"), + addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.3"), libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.6" ) } From 440ad4bb0b3f77c5bbe8b40cb80ed782bba6d855 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 29 May 2012 08:49:02 -0400 Subject: [PATCH 135/483] First cut at using metapackages to allow multiple versions of SBT in the same debian repository. --- project/MetaPackaging.scala | 25 +++++++++++++++++++++++++ project/build.scala | 2 ++ project/packaging.scala | 15 +++++++++++---- 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 project/MetaPackaging.scala diff --git a/project/MetaPackaging.scala b/project/MetaPackaging.scala new file mode 100644 index 000000000..0d54b3852 --- /dev/null +++ b/project/MetaPackaging.scala @@ -0,0 +1,25 @@ +import sbt._ +import com.typesafe.packager.Keys._ +import sbt.Keys._ +import com.typesafe.packager.PackagerPlugin._ + + +object MetaPackaging { + + def settings(pkg: Project): Seq[Setting[_]] = packagerSettings ++ Seq( + name := "sbt", + version <<= sbtVersion apply { + case "0.11.3" => "0.11.3-build0300" + case v => v + }, + // GENERAL LINUX PACKAGING STUFFS + maintainer := "Josh Suereth ", + packageSummary := "Simple Build Tool for Scala-driven builds", + packageDescription := """This meta-package provides the most up-to-date version of the SBT package.""", + debianPackageDependencies in Debian <+= (name in Debian in pkg), + // STUBBED values + wixConfig := , + rpmRelease := "1", + rpmVendor := "typesafe" + ) +} diff --git a/project/build.scala b/project/build.scala index a546ea1ff..55117fac2 100644 --- a/project/build.scala +++ b/project/build.scala @@ -4,4 +4,6 @@ import Keys._ object SbtExtras extends Build { // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. val root = Project("sbt-extras", file(".")) settings(Packaging.settings:_*) + + val meta = Project("metapackage", file("metapackage")) settings(MetaPackaging.settings(root):_*) } diff --git a/project/packaging.scala b/project/packaging.scala index bce170993..2640993d0 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -17,8 +17,14 @@ object Packaging { def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]" + def downloadUrlForVersion(v: String) = (v split "[^\\d]" map (_.toInt)) match { + case Array(0, 11, x, _*) if x >= 3 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" + case Array(0, y, _*) if y >= 12 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" + case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" + } + val settings: Seq[Setting[_]] = packagerSettings ++ Seq( - sbtLaunchJarUrl <<= sbtVersion apply ("http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+_+"/sbt-launch.jar"), + sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion, sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"), sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) => import dispatch._ @@ -88,9 +94,10 @@ object Packaging { jar -> ("/usr/lib/sbt/"+v+"/sbt-launch.jar")) withPerms "0755" }, // DEBIAN SPECIFIC - name in Debian := "sbt", - version in Debian <<= (version, sbtVersion) apply { (v, sv) => - sv + "-build-" + (v split "\\." map (_.toInt) dropWhile (_ == 0) map ("%02d" format _) mkString "") + name in Debian <<= (sbtVersion) apply { (sv) => "sbt-" + (sv split "[^\\d]" take 3 mkString ".") }, + version in Debian <<= (version, sbtVersion) apply { (v, sv) => + val nums = (v split "[^\\d]") + "%s-build-%03d" format ((nums.init mkString "."), nums.last.toInt + 1) }, debianPackageDependencies in Debian ++= Seq("curl", "java2-runtime", "bash (>= 2.05a-11)"), debianPackageRecommends in Debian += "git", From 55e0dfdc65440cb02627ccbb290a9afba211a9dc Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 17 Jul 2012 16:37:19 -0400 Subject: [PATCH 136/483] Removed bad practices from sbt bash script. * No set XYZ arguments allowed. BAAD sbt practice. * No longer swaps launcher. New SBT launchers can handle old SBT. * SBT script now uses sbt-launch-lib.bash. --- project/build.scala | 2 +- project/packaging.scala | 38 +- src/debian/changelog | 6 + src/linux/sbt | 409 ------------------ src/linux/sbt-launch-lib.bash | 196 --------- src/scripts/sbt | 81 ++++ .../bin => scripts}/sbt-launch-lib.bash | 87 ++-- src/universal/bin/sbt | 401 ----------------- 8 files changed, 147 insertions(+), 1073 deletions(-) delete mode 100755 src/linux/sbt delete mode 100644 src/linux/sbt-launch-lib.bash create mode 100755 src/scripts/sbt rename src/{universal/bin => scripts}/sbt-launch-lib.bash (68%) mode change 100755 => 100644 delete mode 100755 src/universal/bin/sbt diff --git a/project/build.scala b/project/build.scala index 55117fac2..b3e4ba4ab 100644 --- a/project/build.scala +++ b/project/build.scala @@ -3,7 +3,7 @@ import Keys._ object SbtExtras extends Build { // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. - val root = Project("sbt-extras", file(".")) settings(Packaging.settings:_*) + val root = Project("sbt-packaging", file(".")) settings(Packaging.settings:_*) val meta = Project("metapackage", file("metapackage")) settings(MetaPackaging.settings(root):_*) } diff --git a/project/packaging.scala b/project/packaging.scala index 2640993d0..6110155eb 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -14,6 +14,12 @@ object Packaging { val jansiJar = TaskKey[File]("jansi-jar", "Resolves Jansi jar") val winowsReleaseUrl = "http://typesafe.artifactoryonline.com/typesafe/windows-releases" + + val fixedScriptDir = SettingKey[File]("fixed-script-dir") + val fixedLinuxScriptDir = SettingKey[File]("fixed-linux-script-dir") + val fixedUniversalScriptDir = SettingKey[File]("fixed-universal-script-dir") + val linuxFixedScripts = TaskKey[File]("linux-fixed-scripts") + val universalFixedScripts = TaskKey[File]("universal-fixed-scripts") def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]" @@ -23,7 +29,26 @@ object Packaging { case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" } + def fixScripts(launchJar: String, bashLib: String)(scriptDir: File, target: File): File = { + if(!target.exists) target.mkdirs() + for(file <- (scriptDir.*** --- scriptDir).get) { + val tfile = target / file.getName + // TODO - Speedier version + val lines = + for { + line <- IO.readLines(file).view + } yield line.replaceAll("@@BASH-LIB-LOCATION@@", bashLib).replaceAll("@@LAUNCH-JAR-LOCATION@@", launchJar) + IO.writeLines(tfile, lines) + } + target + } + val settings: Seq[Setting[_]] = packagerSettings ++ Seq( + fixedScriptDir <<= sourceDirectory / "scripts", + fixedLinuxScriptDir <<= target / "linux-scripts", + fixedUniversalScriptDir <<= target / "universal-scripts", + linuxFixedScripts <<= (fixedScriptDir, fixedLinuxScriptDir) map fixScripts("/usr/lib/sbt/sbt-launch.jar", "/usr/share/sbt/sbt-launch-lib.bash"), + universalFixedScripts <<= (fixedScriptDir, fixedUniversalScriptDir) map fixScripts("\\$(dirname \\$0)/sbt-launch.jar", "\\$(dirname \\$0)/sbt-launch-lib.bash"), sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion, sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"), sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) => @@ -57,7 +82,7 @@ object Packaging { packageSummary := "Simple Build Tool for Scala-driven builds", packageDescription := """This script provides a native way to run the Simple Build Tool, a build tool for Scala software, also called SBT.""", - linuxPackageMappings <+= (sourceDirectory in Linux) map { bd => + linuxPackageMappings <+= (linuxFixedScripts) map { bd => (packageMapping((bd / "sbt") -> "/usr/bin/sbt", bd -> "/usr/share/sbt", (bd / "sbt-launch-lib.bash") -> "/usr/share/sbt/sbt-launch-lib.bash") @@ -90,8 +115,7 @@ object Packaging { }, linuxPackageMappings <+= (sbtLaunchJar, sourceDirectory in Linux, sbtVersion) map { (jar, dir, v) => packageMapping(dir -> "/usr/lib/sbt", - dir -> ("/usr/lib/sbt/" + v), - jar -> ("/usr/lib/sbt/"+v+"/sbt-launch.jar")) withPerms "0755" + jar -> ("/usr/lib/sbt/sbt-launch.jar")) withPerms "0755" }, // DEBIAN SPECIFIC name in Debian <<= (sbtVersion) apply { (sv) => "sbt-" + (sv split "[^\\d]" take 3 mkString ".") }, @@ -138,8 +162,14 @@ object Packaging { // Universal ZIP download install. TODO - Share the above windows code, here.... name in Universal := "sbt", - mappings in Universal <+= sbtLaunchJar map { f => f -> "bin/sbt-launch.jar" }, + mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" }, mappings in Universal <+= jansiJar map { f => f -> "bin/jansi.jar" }, + mappings in Universal <++= universalFixedScripts map { d => + Seq( + (d / "sbt") -> "bin/sbt", + (d / "sbt-launch-lib.bash") -> "bin/sbt-launch-lib.bash" + ) + }, mappings in Universal <++= sourceDirectory in Windows map { d => Seq( (d / "sbt.bat") -> "bin/sbt.bat", (d / "sbt") -> "bin/win-sbt", diff --git a/src/debian/changelog b/src/debian/changelog index bc29d5d2b..ec30582fa 100644 --- a/src/debian/changelog +++ b/src/debian/changelog @@ -1,4 +1,10 @@ +sbt (0.12.0-build-0100) + + * No need for different launcher jar files now + + -- Joshua Suereth 2012-07-2012 + sbt (0.11.2-build-0100) * First debian package release diff --git a/src/linux/sbt b/src/linux/sbt deleted file mode 100755 index 3aaadec93..000000000 --- a/src/linux/sbt +++ /dev/null @@ -1,409 +0,0 @@ -#!/usr/bin/env bash -# -# A more capable sbt runner, coincidentally also called sbt. -# Author: Paul Phillips - -# this seems to cover the bases on OSX, and someone will -# have to tell me about the others. -get_script_path () { - local path="$1" - [[ -L "$path" ]] || { echo "$path" ; return; } - - local target=$(readlink "$path") - if [[ "${target:0:1}" == "/" ]]; then - echo "$target" - else - echo "$path/$target" - fi -} - -# a ham-fisted attempt to move some memory settings in concert -# so they need not be dicked around with individually. -get_mem_opts () { - local mem=${1:-1536} - local perm=$(( $mem / 4 )) - (( $perm > 256 )) || perm=256 - (( $perm < 1024 )) || perm=1024 - local codecache=$(( $perm / 2 )) - - echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" -} - -is_owned_by_user () { - [[ "$(stat --printf='%U' $1)" == "$(USER)" ]] && { echo "OK" ; return; } -} - -die() { - echo "Aborting: $@" - exit 1 -} - -# todo - make this dynamic -declare -r sbt_release_version=0.11.3 -unset sbt_rc_version -# declare -r sbt_rc_version= -declare -r sbt_snapshot_version=0.11.4-SNAPSHOT -declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-sbt/sbt-launch/" - -declare -r default_java_opts="-Dfile.encoding=UTF8" -declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled" -declare -r default_sbt_mem=1536 -declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" -declare -r sbt_opts_file=".sbtopts" -declare -r etc_sbt_opts_file="/etc/sbt/sbtopts" -declare -r latest_28="2.8.2" -declare -r latest_29="2.9.1" -declare -r latest_210="2.10.0-SNAPSHOT" - -declare -r script_path=$(get_script_path "$BASH_SOURCE") -if test -z "$HOME"; then - declare -r script_dir="$(dirname $script_path)" -else - declare -r script_dir="$HOME/.sbt" -fi -declare -r script_name="$(basename $script_path)" - -declare java_cmd=java -declare sbt_mem=$default_sbt_mem -declare java_opts="${JAVA_OPTS:-$default_java_opts}" - -unset sbt_jar sbt_create sbt_version sbt_snapshot -unset scala_version -unset java_home -unset verbose debug - -# pull -J and -D options to give to java. -declare -a residual_args -declare -a java_args -declare -a scalac_args -declare -a sbt_commands - -build_props_sbt () { - if [[ -f project/build.properties ]]; then - versionLine=$(grep ^sbt.version project/build.properties) - versionString=${versionLine##sbt.version=} - echo "$versionString" - fi -} -build_props_scala () { - if [[ -f project/build.properties ]]; then - versionLine=$(grep ^build.scala.versions project/build.properties) - versionString=${versionLine##build.scala.versions=} - echo ${versionString%% .*} - fi -} - -isSnapshot () { - [[ "$sbt_version" = *-SNAPSHOT* ]] -} -isRC () { - [[ "$sbt_version" = *-RC* ]] -} - -execRunner () { - # print the arguments one to a line, quoting any containing spaces - [[ $verbose || $debug ]] && echo "# Executing command line:" && { - for arg; do - if printf "%s\n" "$arg" | grep -q ' '; then - printf "\"%s\"\n" "$arg" - else - printf "%s\n" "$arg" - fi - done - echo "" - } - - exec "$@" -} - -echoerr () { - echo 1>&2 "$@" -} -vlog () { - [[ $verbose || $debug ]] && echoerr "$@" -} -dlog () { - [[ $debug ]] && echoerr "$@" -} - -sbtjar_07_url () { - echo "http://simple-build-tool.googlecode.com/files/sbt-launch-${1}.jar" -} -sbtjar_release_url () { - echo "http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/$sbt_version/sbt-launch.jar" -} -sbtjar_snapshot_url () { - local ver="$sbt_version" - if [[ "$sbt_version" = *-SNAPSHOT ]]; then - ver=$(sbt_snapshot_actual_version -SNAPSHOT) - echoerr "sbt snapshot is $ver" - elif [[ "$sbt_version" = *-SNAPSHOT ]]; then - ver=$(sbt_snapshot_actual_version -RC) - echoerr "sbt rc is $ver" - fi - - echo "${sbt_snapshot_baseurl}${ver}/sbt-launch.jar" -} -jar_url () { - case $sbt_version in - 0.7.4*) sbtjar_07_url 0.7.4 ;; - 0.7.5*) sbtjar_07_url 0.7.5 ;; - 0.7.7*) sbtjar_07_url 0.7.7 ;; - 0.7.*) sbtjar_07_url 0.7.7 ;; - *-SNAPSHOT*) sbtjar_snapshot_url ;; - *-RC*) sbtjar_snapshot_url ;; - *) sbtjar_release_url ;; - esac -} - -jar_file () { - if [[ -f "/usr/lib/sbt/$1/sbt-launch.jar" ]]; then - echo "/usr/lib/sbt/$1/sbt-launch.jar" - else - echo "$script_dir/.lib/$1/sbt-launch.jar" - fi -} - -sbt_artifactory_list () { - local type="$1" # -RC or -SNAPSHOT - local version=${sbt_version%-SNAPSHOT} - - curl -s --list-only "$sbt_snapshot_baseurl" | \ - grep -F $version | \ - perl -e 'print reverse <>' | \ - perl -pe 's#^/dev/null - dlog "curl returned: $?" - echo "$ver" - return - done -} - -download_url () { - local url="$1" - local jar="$2" - - echo "Cannot find sbt launcher $sbt_version" - echo "Please download: " - echo " From $url" - echo " To $jar" - - exit 1 -} - -acquire_sbt_jar () { - if [[ $sbt_snapshot ]]; then - sbt_version=$sbt_snapshot_version - elif [[ ! $sbt_version ]]; then - sbt_version=$sbt_release_version - fi - - sbt_url="$(jar_url)" - sbt_jar="$(jar_file $sbt_version)" - - [[ -f "$sbt_jar" ]] || download_url "$sbt_url" "$sbt_jar" -} - - -usage () { - cat < path to global settings/plugins directory (default: ~/.sbt) - -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) - -ivy path to local Ivy repository (default: ~/.ivy2) - -mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) - -no-share use all local caches; no sharing - -no-global uses global caches, but does not use global ~/.sbt directory. - -offline put sbt in offline mode - -jvm-debug Turn on JVM debugging, open at the given port. - -batch Disable interactive mode - - # sbt version (default: from project/build.properties if present, else latest release) - -sbt-version use the specified version of sbt - -sbt-jar use the specified jar as the sbt launcher - -sbt-rc use an RC version of sbt - -sbt-snapshot use a snapshot version of sbt - - # scala version (default: latest release) - -28 use $latest_28 - -29 use $latest_29 - -210 use $latest_210 - -scala-home use the scala build at the specified directory - -scala-version use the specified version of scala - - # java version (default: java from PATH, currently $(java -version 2>&1 | grep version)) - -java-home alternate JAVA_HOME - - # jvm options and output control - JAVA_OPTS environment variable, if unset uses "$java_opts" - SBT_OPTS environment variable, if unset uses "$default_sbt_opts" - .sbtopts if this file exists in the current directory, it is - prepended to the runner args - /etc/sbt/sbtopts if this file exists, it is prepended to the runner args - -Dkey=val pass -Dkey=val directly to the java runtime - -J-X pass option -X directly to the java runtime - (-J is stripped) - -S-X add -X to sbt's scalacOptions (-J is stripped) - -In the case of duplicated or conflicting options, the order above -shows precedence: JAVA_OPTS lowest, command line options highest. -EOM -} - -addJava () { - dlog "[addJava] arg = '$1'" - java_args=( "${java_args[@]}" "$1" ) -} -addSbt () { - dlog "[addSbt] arg = '$1'" - sbt_commands=( "${sbt_commands[@]}" "$1" ) -} -addScalac () { - dlog "[addScalac] arg = '$1'" - scalac_args=( "${scalac_args[@]}" "$1" ) -} -addResidual () { - dlog "[residual] arg = '$1'" - residual_args=( "${residual_args[@]}" "$1" ) -} -addResolver () { - addSbt "set resolvers in ThisBuild += $1" -} -unset addedSnapshotRepo -addSnapshotRepo () { - [[ -n "$addedSnapshotRepo" ]] || addResolver "ScalaToolsSnapshots" && addedSnapshotRepo=true -} -addDebugger () { - addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" -} - -process_args () -{ - require_arg () { - local type="$1" - local opt="$2" - local arg="$3" - - if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then - die "$opt requires <$type> argument" - fi - } - while [[ $# -gt 0 ]]; do - case "$1" in - -h|-help) usage; exit 1 ;; - -v|-verbose) verbose=1 && shift ;; - -d|-debug) debug=1 && shift ;; - # -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload && shift ;; - - -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; - -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; - -no-colors) addJava "-Dsbt.log.noformat=true" && shift ;; - -no-share) addJava "$noshare_opts" && shift ;; - -no-global) addJava "-Dsbt.global.base=project/.sbtboot" && shift ;; - -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; - -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;; - -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; - -offline) addSbt "set offline := true" && shift ;; - -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; - -batch) exec 0 )) || echo "Starting $script_name: invoke with -help for other options" - -# verify this is an sbt dir or -create was given -[[ -f ./build.sbt || -d ./project || -n "$sbt_create" ]] || { - cat <&2 "$@" -} -vlog () { - [[ $verbose || $debug ]] && echoerr "$@" -} -dlog () { - [[ $debug ]] && echoerr "$@" -} - -sbtjar_release_url () { - echo "http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/$sbt_version/sbt-launch.jar" -} - -sbtjar_snapshot_url () { - local ver="$sbt_version" - if [[ "$sbt_version" = *-SNAPSHOT ]]; then - ver=$(sbt_snapshot_actual_version -SNAPSHOT) - echoerr "sbt snapshot is $ver" - elif [[ "$sbt_version" = *-SNAPSHOT ]]; then - ver=$(sbt_snapshot_actual_version -RC) - echoerr "sbt rc is $ver" - fi - - echo "${sbt_snapshot_baseurl}${ver}/sbt-launch.jar" -} - -jar_url () { - case $sbt_version in - *-SNAPSHOT*) sbtjar_snapshot_url ;; - *-RC*) sbtjar_snapshot_url ;; - *) sbtjar_release_url ;; - esac -} - -jar_file () { - if [[ -f "/usr/lib/sbt/$1/sbt-launch.jar" ]]; then - echo "/usr/lib/sbt/$1/sbt-launch.jar" - else - echo "$script_dir/.lib/$1/sbt-launch.jar" - fi -} - -download_url () { - local url="$1" - local jar="$2" - - echo "Cannot find sbt launcher $sbt_version" - echo "Please download: " - echo " From $url" - echo " To $jar" - - exit 1 -} - -acquire_sbt_jar () { - local sbt_version="$1" - - sbt_url="$(jar_url)" - sbt_jar="$(jar_file $sbt_version)" - - [[ -f "$sbt_jar" ]] || download_url "$sbt_url" "$sbt_jar" -} - -execRunner () { - # print the arguments one to a line, quoting any containing spaces - [[ $verbose || $debug ]] && echo "# Executing command line:" && { - for arg; do - if printf "%s\n" "$arg" | grep -q ' '; then - printf "\"%s\"\n" "$arg" - else - printf "%s\n" "$arg" - fi - done - echo "" - } - - exec "$@" -} - -addJava () { - dlog "[addJava] arg = '$1'" - java_args=( "${java_args[@]}" "$1" ) -} -addSbt () { - dlog "[addSbt] arg = '$1'" - sbt_commands=( "${sbt_commands[@]}" "$1" ) -} -addResidual () { - dlog "[residual] arg = '$1'" - residual_args=( "${residual_args[@]}" "$1" ) -} -addDebugger () { - addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" -} - -# a ham-fisted attempt to move some memory settings in concert -# so they need not be dicked around with individually. -get_mem_opts () { - local mem=${1:-1536} - local perm=$(( $mem / 4 )) - (( $perm > 256 )) || perm=256 - (( $perm < 1024 )) || perm=1024 - local codecache=$(( $perm / 2 )) - - echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" -} - -process_args () { - require_arg () { - local type="$1" - local opt="$2" - local arg="$3" - - if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then - die "$opt requires <$type> argument" - fi - } - while [[ $# -gt 0 ]]; do - case "$1" in - -h|-help) usage; exit 1 ;; - -v|-verbose) verbose=1 && shift ;; - -d|-debug) debug=1 && shift ;; - # -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload && shift ;; - - -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; - -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; - -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; - -batch) exec path to global settings/plugins directory (default: ~/.sbt) + -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) + -ivy path to local Ivy repository (default: ~/.ivy2) + -mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) + -no-share use all local caches; no sharing + -no-global uses global caches, but does not use global ~/.sbt directory. + -jvm-debug Turn on JVM debugging, open at the given port. + -batch Disable interactive mode + + # sbt version (default: from project/build.properties if present, else latest release) + -sbt-version use the specified version of sbt + -sbt-jar use the specified jar as the sbt launcher + -sbt-rc use an RC version of sbt + -sbt-snapshot use a snapshot version of sbt + + # java version (default: java from PATH, currently $(java -version 2>&1 | grep version)) + -java-home alternate JAVA_HOME + + # jvm options and output control + JAVA_OPTS environment variable, if unset uses "$java_opts" + SBT_OPTS environment variable, if unset uses "$default_sbt_opts" + .sbtopts if this file exists in the current directory, it is + prepended to the runner args + /etc/sbt/sbtopts if this file exists, it is prepended to the runner args + -Dkey=val pass -Dkey=val directly to the java runtime + -J-X pass option -X directly to the java runtime + (-J is stripped) + -S-X add -X to sbt's scalacOptions (-J is stripped) + +In the case of duplicated or conflicting options, the order above +shows precedence: JAVA_OPTS lowest, command line options highest. +EOM +} + + + +process_my_args () { + while [[ $# -gt 0 ]]; do + case "$1" in + -no-colors) addJava "-Dsbt.log.noformat=true" && shift ;; + -no-share) addJava "$noshare_opts" && shift ;; + -no-global) addJava "-Dsbt.global.base=project/.sbtboot" && shift ;; + -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; + -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;; + -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; + -batch) exec argument" + fi +} - if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then - die "$opt requires <$type> argument" - fi - } +is_function_defined() { + declare -f "$1" > /dev/null +} + +process_args () { while [[ $# -gt 0 ]]; do case "$1" in -h|-help) usage; exit 1 ;; -v|-verbose) verbose=1 && shift ;; -d|-debug) debug=1 && shift ;; - # -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload && shift ;; -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; @@ -162,6 +119,12 @@ process_args () { *) addResidual "$1" && shift ;; esac done + + is_function_defined process_my_args && { + myargs=("${residual_args[@]}") + residual_args=() + process_my_args "${myargs[@]}" + } } run() { diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt deleted file mode 100755 index fb81d154e..000000000 --- a/src/universal/bin/sbt +++ /dev/null @@ -1,401 +0,0 @@ -#!/usr/bin/env bash -# -# A more capable sbt runner, coincidentally also called sbt. -# Author: Paul Phillips - -# this seems to cover the bases on OSX, and someone will -# have to tell me about the others. -get_script_path () { - local path="$1" - [[ -L "$path" ]] || { echo "$path" ; return; } - - local target=$(readlink "$path") - if [[ "${target:0:1}" == "/" ]]; then - echo "$target" - else - echo "$path/$target" - fi -} - -# a ham-fisted attempt to move some memory settings in concert -# so they need not be dicked around with individually. -get_mem_opts () { - local mem=${1:-1536} - local perm=$(( $mem / 4 )) - (( $perm > 256 )) || perm=256 - (( $perm < 1024 )) || perm=1024 - local codecache=$(( $perm / 2 )) - - echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" -} - -is_owned_by_user () { - [[ "$(stat --printf='%U' $1)" == "$(USER)" ]] && { echo "OK" ; return; } -} - -die() { - echo "Aborting: $@" - exit 1 -} - -# todo - make this dynamic -declare -r sbt_release_version=0.11.3 -unset sbt_rc_version -# declare -r sbt_rc_version= -declare -r sbt_snapshot_version=0.11.4-SNAPSHOT -declare -r sbt_snapshot_baseurl="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/" - -declare -r default_java_opts="-Dfile.encoding=UTF8" -declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled" -declare -r default_sbt_mem=1536 -declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" -declare -r sbt_opts_file=".sbtopts" -declare -r etc_sbt_opts_file="/etc/sbt/sbtopts" -declare -r latest_28="2.8.2" -declare -r latest_29="2.9.1" -declare -r latest_210="2.10.0-SNAPSHOT" - -declare -r script_path=$(get_script_path "$BASH_SOURCE") -if test -z "$HOME"; then - declare -r script_dir="$(dirname $script_path)" -else - declare -r script_dir="$HOME/.sbt" -fi -declare -r script_name="$(basename $script_path)" - -declare java_cmd=java -declare sbt_mem=$default_sbt_mem -declare java_opts="${JAVA_OPTS:-$default_java_opts}" - -unset sbt_jar sbt_create sbt_version sbt_snapshot -unset scala_version -unset java_home -unset verbose debug - -# pull -J and -D options to give to java. -declare -a residual_args -declare -a java_args -declare -a scalac_args -declare -a sbt_commands - -build_props_sbt () { - if [[ -f project/build.properties ]]; then - versionLine=$(grep ^sbt.version project/build.properties) - versionString=${versionLine##sbt.version=} - echo "$versionString" - fi -} -build_props_scala () { - if [[ -f project/build.properties ]]; then - versionLine=$(grep ^build.scala.versions project/build.properties) - versionString=${versionLine##build.scala.versions=} - echo ${versionString%% .*} - fi -} - -isSnapshot () { - [[ "$sbt_version" = *-SNAPSHOT* ]] -} -isRC () { - [[ "$sbt_version" = *-RC* ]] -} - -execRunner () { - # print the arguments one to a line, quoting any containing spaces - [[ $verbose || $debug ]] && echo "# Executing command line:" && { - for arg; do - if printf "%s\n" "$arg" | grep -q ' '; then - printf "\"%s\"\n" "$arg" - else - printf "%s\n" "$arg" - fi - done - echo "" - } - - exec "$@" -} - -echoerr () { - echo 1>&2 "$@" -} -vlog () { - [[ $verbose || $debug ]] && echoerr "$@" -} -dlog () { - [[ $debug ]] && echoerr "$@" -} - -sbtjar_07_url () { - echo "http://simple-build-tool.googlecode.com/files/sbt-launch-${1}.jar" -} -sbtjar_release_url () { - echo "http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/$sbt_version/sbt-launch.jar" -} -sbtjar_snapshot_url () { - local ver="$sbt_version" - if [[ "$sbt_version" = *-SNAPSHOT ]]; then - ver=$(sbt_snapshot_actual_version -SNAPSHOT) - echoerr "sbt snapshot is $ver" - elif [[ "$sbt_version" = *-SNAPSHOT ]]; then - ver=$(sbt_snapshot_actual_version -RC) - echoerr "sbt rc is $ver" - fi - - echo "${sbt_snapshot_baseurl}${ver}/sbt-launch.jar" -} -jar_url () { - case $sbt_version in - 0.7.4*) sbtjar_07_url 0.7.4 ;; - 0.7.5*) sbtjar_07_url 0.7.5 ;; - 0.7.7*) sbtjar_07_url 0.7.7 ;; - 0.7.*) sbtjar_07_url 0.7.7 ;; - *-SNAPSHOT*) sbtjar_snapshot_url ;; - *-RC*) sbtjar_snapshot_url ;; - *) sbtjar_release_url ;; - esac -} - -jar_file () { - # TODO - Allow alternative versions, maybe... - if [[ -f "$(dirname $0)/sbt-launch.jar" ]]; then - echo "$(dirname $0)/sbt-launch.jar" - else - echo "$script_dir/.lib/$1/sbt-launch.jar" - fi -} - -sbt_artifactory_list () { - local type="$1" # -RC or -SNAPSHOT - local version=${sbt_version%-SNAPSHOT} - - curl -s --list-only "$sbt_snapshot_baseurl" | \ - grep -F $version | \ - perl -e 'print reverse <>' | \ - perl -pe 's#^/dev/null - dlog "curl returned: $?" - echo "$ver" - return - done -} - -download_url () { - local url="$1" - local jar="$2" - - echo "Cannot find sbt launcher $sbt_version" - echo "Please download: " - echo " From $url" - echo " To $jar" - - exit 1 -} - -acquire_sbt_jar () { - if [[ $sbt_snapshot ]]; then - sbt_version=$sbt_snapshot_version - elif [[ ! $sbt_version ]]; then - sbt_version=$sbt_release_version - fi - - sbt_url="$(jar_url)" - sbt_jar="$(jar_file $sbt_version)" - - [[ -f "$sbt_jar" ]] || download_url "$sbt_url" "$sbt_jar" -} - - -usage () { - cat < path to global settings/plugins directory (default: ~/.sbt) - -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) - -ivy path to local Ivy repository (default: ~/.ivy2) - -mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) - -no-share use all local caches; no sharing - -no-global uses global caches, but does not use global ~/.sbt directory. - -offline put sbt in offline mode - -jvm-debug Turn on JVM debugging, open at the given port. - -batch Disable interactive mode - - # scala version (default: latest release) - -28 use $latest_28 - -29 use $latest_29 - -210 use $latest_210 - -scala-home use the scala build at the specified directory - -scala-version use the specified version of scala - - # java version (default: java from PATH, currently $(java -version 2>&1 | grep version)) - -java-home alternate JAVA_HOME - - # jvm options and output control - JAVA_OPTS environment variable, if unset uses "$java_opts" - SBT_OPTS environment variable, if unset uses "$default_sbt_opts" - .sbtopts if this file exists in the current directory, it is - prepended to the runner args - /etc/sbt/sbtopts if this file exists, it is prepended to the runner args - -Dkey=val pass -Dkey=val directly to the java runtime - -J-X pass option -X directly to the java runtime - (-J is stripped) - -S-X add -X to sbt's scalacOptions (-J is stripped) - -In the case of duplicated or conflicting options, the order above -shows precedence: JAVA_OPTS lowest, command line options highest. -EOM -} - -addJava () { - dlog "[addJava] arg = '$1'" - java_args=( "${java_args[@]}" "$1" ) -} -addSbt () { - dlog "[addSbt] arg = '$1'" - sbt_commands=( "${sbt_commands[@]}" "$1" ) -} -addScalac () { - dlog "[addScalac] arg = '$1'" - scalac_args=( "${scalac_args[@]}" "$1" ) -} -addResidual () { - dlog "[residual] arg = '$1'" - residual_args=( "${residual_args[@]}" "$1" ) -} -addResolver () { - addSbt "set resolvers in ThisBuild += $1" -} -unset addedSnapshotRepo -addSnapshotRepo () { - [[ -n "$addedSnapshotRepo" ]] || addResolver "ScalaToolsSnapshots" && addedSnapshotRepo=true -} -addDebugger () { - addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" -} - -process_args () -{ - require_arg () { - local type="$1" - local opt="$2" - local arg="$3" - - if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then - die "$opt requires <$type> argument" - fi - } - while [[ $# -gt 0 ]]; do - case "$1" in - -h|-help) usage; exit 1 ;; - -v|-verbose) verbose=1 && shift ;; - -d|-debug) debug=1 && shift ;; - # -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload && shift ;; - - -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; - -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; - -no-colors) addJava "-Dsbt.log.noformat=true" && shift ;; - -no-share) addJava "$noshare_opts" && shift ;; - -no-global) addJava "-Dsbt.global.base=project/.sbtboot" && shift ;; - -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; - -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;; - -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; - -offline) addSbt "set offline := true" && shift ;; - -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; - -batch) exec 0 )) || echo "Starting $script_name: invoke with -help for other options" - -# verify this is an sbt dir or -create was given -[[ -f ./build.sbt || -d ./project || -n "$sbt_create" ]] || { - cat < Date: Wed, 18 Jul 2012 10:40:29 -0400 Subject: [PATCH 137/483] Fixes for 0.12.0-RC4 release of launcher package. --- build.sbt | 10 +++++++++- project/packaging.scala | 23 +++++++++++++++-------- src/scripts/sbt | 7 +++++-- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/build.sbt b/build.sbt index 692ad3837..2b89cd7be 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,17 @@ sbtPlugin := true name := "sbt-launcher-package" -organization := "org.scalasbt" +organization := "org.scala-sbt" version := "0.1.0" crossTarget <<= target +publishTo in Global := { + val nativeReleaseUrl = "http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages" + val nativeReleasePattern = "[organization]/[module]/[revision]/[module].[ext]" + val resolver = Resolver.url("native-releases", new URL(nativeReleaseUrl))(Patterns(nativeReleasePattern)) +// Resolver.file("native-releases-local", file("/home/jsuereth/repos/native-packages"))(Patterns(nativeReleasePattern)) + Some(resolver) +} + diff --git a/project/packaging.scala b/project/packaging.scala index 6110155eb..0bd2d3294 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -13,8 +13,6 @@ object Packaging { val jansiJarLocation = SettingKey[File]("jansi-jar-location") val jansiJar = TaskKey[File]("jansi-jar", "Resolves Jansi jar") - val winowsReleaseUrl = "http://typesafe.artifactoryonline.com/typesafe/windows-releases" - val fixedScriptDir = SettingKey[File]("fixed-script-dir") val fixedLinuxScriptDir = SettingKey[File]("fixed-linux-script-dir") val fixedUniversalScriptDir = SettingKey[File]("fixed-universal-script-dir") @@ -22,8 +20,11 @@ object Packaging { val universalFixedScripts = TaskKey[File]("universal-fixed-scripts") def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]" - - def downloadUrlForVersion(v: String) = (v split "[^\\d]" map (_.toInt)) match { + + import util.control.Exception.catching + + def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching(classOf[Exception]) opt (i.toInt))) match { + case Array(0, 11, 3, _*) => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.11.3-2/sbt-launch.jar" case Array(0, 11, x, _*) if x >= 3 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case Array(0, y, _*) if y >= 12 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" @@ -43,7 +44,7 @@ object Packaging { target } - val settings: Seq[Setting[_]] = packagerSettings ++ Seq( + val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ Seq( fixedScriptDir <<= sourceDirectory / "scripts", fixedLinuxScriptDir <<= target / "linux-scripts", fixedUniversalScriptDir <<= target / "universal-scripts", @@ -118,10 +119,10 @@ object Packaging { jar -> ("/usr/lib/sbt/sbt-launch.jar")) withPerms "0755" }, // DEBIAN SPECIFIC - name in Debian <<= (sbtVersion) apply { (sv) => "sbt-" + (sv split "[^\\d]" take 3 mkString ".") }, + name in Debian <<= (sbtVersion) apply { (sv) => "sbt" /* + "-" + (sv split "[^\\d]" take 3 mkString ".")*/ }, version in Debian <<= (version, sbtVersion) apply { (v, sv) => val nums = (v split "[^\\d]") - "%s-build-%03d" format ((nums.init mkString "."), nums.last.toInt + 1) + "%s-%s-build-%03d" format (sv, (nums.init mkString "."), nums.last.toInt + 1) }, debianPackageDependencies in Debian ++= Seq("curl", "java2-runtime", "bash (>= 2.05a-11)"), debianPackageRecommends in Debian += "git", @@ -178,8 +179,14 @@ object Packaging { mappings in Universal <+= (compile in Compile, classDirectory in Compile) map { (c, d) => compile; (d / "SbtJansiLaunch.class") -> "bin/classes/SbtJansiLaunch.class" - } + }, // TODO - Adapt global `sbt`/`sbt-launch-lib` scripts for universal install... + + // Misccelaneous publishing stuff... + projectID in Debian <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) }, + projectID in Windows <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) }, + projectID in Rpm <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) }, + projectID in Universal <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) } ) def makeWindowsXml(sbtVersion: String, sourceDir: File): scala.xml.Node = { diff --git a/src/scripts/sbt b/src/scripts/sbt index 2ae5d37c3..502747d88 100755 --- a/src/scripts/sbt +++ b/src/scripts/sbt @@ -57,7 +57,7 @@ process_my_args () { case "$1" in -no-colors) addJava "-Dsbt.log.noformat=true" && shift ;; -no-share) addJava "$noshare_opts" && shift ;; - -no-global) addJava "-Dsbt.global.base=project/.sbtboot" && shift ;; + -no-global) addJava "-Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;; -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;; -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; @@ -68,6 +68,9 @@ process_my_args () { *) addResidual "$1" && shift ;; esac done + + # Now, ensure sbt version is used. + [[ "${sbt_version}XXX" != "XXX" ]] && addJava "-Dsbt.version=$sbt_version" } loadConfigFile() { @@ -78,4 +81,4 @@ loadConfigFile() { [[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@" [[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@" -run $@ \ No newline at end of file +run $@ From be912e904b2ff06ce811f7e7a829b86d52ec9aa0 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 18 Jul 2012 10:47:49 -0400 Subject: [PATCH 138/483] Fixed RPM versioning issue for RC releases. --- project/packaging.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/packaging.scala b/project/packaging.scala index 0bd2d3294..1ae5c6151 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -134,7 +134,7 @@ object Packaging { // RPM SPECIFIC name in Rpm := "sbt", - version in Rpm <<= sbtVersion.identity, + version in Rpm <<= sbtVersion apply { sv => (sv split "[^\\d]" filterNot (_.isEmpty) mkString ".") }, rpmRelease := "1", rpmVendor := "typesafe", rpmUrl := Some("http://github.com/paulp/sbt-extras"), From 41c21b9ed789b527b92d0884e5b293849ceef1b5 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 19 Jul 2012 11:12:15 -0400 Subject: [PATCH 139/483] Modified SBT launcher bat file so it can load a config file with default settings. --- src/windows/sbt.bat | 26 +++++++++++++++++++++----- src/windows/sbtconfig.txt | 8 ++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 src/windows/sbtconfig.txt diff --git a/src/windows/sbt.bat b/src/windows/sbt.bat index 84881fdb4..386c3ba81 100644 --- a/src/windows/sbt.bat +++ b/src/windows/sbt.bat @@ -3,14 +3,29 @@ @REM Envioronment: @REM JAVA_HOME - location of a JDK home dir (mandatory) @REM SBT_OPTS - JVM options (optional) +@REM Configuration: +@REM sbtconfig.txt found in the SBT_HOME. - -@setlocal +@REM ZOMG! We need delayed expansion to build up CFG_OPTS later +@setlocal enabledelayedexpansion @echo off set SBT_HOME=%~dp0 set ERROR_CODE=0 +rem FIRST we load the config file of extra options. +set FN=%SBT_HOME%/sbtconfig.txt +set CFG_OPTS= +FOR /F "tokens=* eol=#" %%i IN (%FN%) DO ( + set TMP=%%i + rem ZOMG (Part #2) WE use !! here to delay the expansion of + rem CFG_OPTS, otherwise it remains "" for this loop. + set CFG_OPTS=!CFG_OPTS! !TMP! +) + +echo CFG_OPTS = %CFG_OPTS% +exit /B 1 + rem We use the value of the JAVACMD environment variable if defined set _JAVACMD=%JAVACMD% @@ -22,12 +37,13 @@ if "%_JAVACMD%"=="" ( if "%_JAVACMD%"=="" set _JAVACMD=java -rem We use the value of the JAVA_OPTS environment variable if defined +rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config. set _JAVA_OPTS=%JAVA_OPTS% -if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=-Xmx512M -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=128m -Dsbt.log.format=true +if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% :run +echo "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%jansi.jar;%SBT_HOME%sbt-launch.jar;%SBT_HOME%classes" SbtJansiLaunch %* "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%jansi.jar;%SBT_HOME%sbt-launch.jar;%SBT_HOME%classes" SbtJansiLaunch %* if ERRORLEVEL 1 goto error goto end @@ -39,4 +55,4 @@ set ERROR_CODE=1 @endlocal -exit /B %ERROR_CODE% \ No newline at end of file +exit /B %ERROR_CODE% diff --git a/src/windows/sbtconfig.txt b/src/windows/sbtconfig.txt new file mode 100644 index 000000000..d49f3fae3 --- /dev/null +++ b/src/windows/sbtconfig.txt @@ -0,0 +1,8 @@ +# Set the java args to high +-Xmx512M +-XX:MaxPermSize=256m +-XX:ReservedCodeCacheSize=128m + +# Set the extra SBT options +-Dsbt.log.format=true + From df31ed1fcbc25f96a7c76fe8690468ac0566c985 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 19 Jul 2012 11:13:03 -0400 Subject: [PATCH 140/483] Fixed issue with sbt versioning for RC releases in windows. --- project/packaging.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/packaging.scala b/project/packaging.scala index 0bd2d3294..fc5486d36 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -190,7 +190,7 @@ object Packaging { ) def makeWindowsXml(sbtVersion: String, sourceDir: File): scala.xml.Node = { - val version = (sbtVersion split "\\.") match { + val version = (sbtVersion split "[^\\d]" filterNot (_.isEmpty)) match { case Array(major,minor,bugfix, _*) => Seq(major,minor,bugfix, "1") mkString "." case Array(major,minor) => Seq(major,minor,"0","1") mkString "." case Array(major) => Seq(major,"0","0","1") mkString "." From 75aedbc3d28822265f2add761bb484baa73ab598 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 1 Aug 2012 12:16:13 -0400 Subject: [PATCH 141/483] Fixes for build to work with SBT 0.12.0 --- project/project/plugins.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/project/plugins.scala b/project/project/plugins.scala index b9561d413..cf7cd2c8f 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -6,7 +6,7 @@ object PluginBuild extends Build { val root = Project("root", file(".")) settings( resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), - addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.3"), - libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.6" + addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.4"), + libraryDependencies += "net.databinder" % "dispatch-http_2.9.1" % "0.8.6" ) } From 1f600d049ba7c6858d4a7b9b3a364587804a1f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8D=9A?= Date: Fri, 10 Aug 2012 12:14:56 +0800 Subject: [PATCH 142/483] Check JAVA_HOME --- src/windows/sbt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/windows/sbt b/src/windows/sbt index e2fbdb5e6..70cdcfbe3 100644 --- a/src/windows/sbt +++ b/src/windows/sbt @@ -1,7 +1,12 @@ #!/bin/sh # sbt launcher script for Cygwin and MSYS +if [ -z "$JAVA_HOME" ]; then JAVA_CMD=java +else +JAVA_CMD=$JAVA_HOME/bin/java +fi + JAVA_OPTS=-Xmx512M UDIR=`dirname "$0"` From edecd0f1bdd12ad485150e7cb27725c746678120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8D=9A?= Date: Fri, 10 Aug 2012 12:15:45 +0800 Subject: [PATCH 143/483] Quote arguments and $JAVA_CMD --- src/windows/sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/windows/sbt b/src/windows/sbt index 70cdcfbe3..d1a88bdc8 100644 --- a/src/windows/sbt +++ b/src/windows/sbt @@ -19,9 +19,9 @@ fi if [ "_$TERM" = "_xterm" ]; then # Let the terminal handle ANSI sequences stty -icanon min 1 -echo > /dev/null 2>&1 - $JAVA_CMD $JAVA_OPTS -Djline.terminal=jline.UnixTerminal -jar "$WDIR/sbt-launch.jar" $@ + "$JAVA_CMD" $JAVA_OPTS -Djline.terminal=jline.UnixTerminal -jar "$WDIR/sbt-launch.jar" "$@" stty icanon echo > /dev/null 2>&1 else # Use Jansi to intercept ANSI sequences - $JAVA_CMD $JAVA_OPTS -Dsbt.log.format=true -cp "$WDIR/jansi.jar;$WDIR/sbt-launch.jar;$WDIR/classes" SbtJansiLaunch $@ -fi + "$JAVA_CMD" $JAVA_OPTS -Dsbt.log.format=true -cp "$WDIR/jansi.jar;$WDIR/sbt-launch.jar;$WDIR/classes" SbtJansiLaunch "$@" +fi \ No newline at end of file From 7820d3deea1b4f2025ec9cc76923273af1acbcaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8D=9A?= Date: Sun, 2 Sep 2012 14:31:59 +0800 Subject: [PATCH 144/483] Update src/scripts/sbt Enable space in arguments. Like: sbt 'run-main com.myhostname.myproject.Main' --- src/scripts/sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/sbt b/src/scripts/sbt index 502747d88..8e50f8f03 100755 --- a/src/scripts/sbt +++ b/src/scripts/sbt @@ -81,4 +81,4 @@ loadConfigFile() { [[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@" [[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@" -run $@ +run "$@" From 872d88ea237301a32f98dac0db1acd75c1b333bb Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Fri, 7 Sep 2012 12:58:02 -0400 Subject: [PATCH 145/483] Updated build so you can specify SBT version on the command line. --- project/build.scala | 6 +++++- project/project/plugins.scala | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/project/build.scala b/project/build.scala index b3e4ba4ab..82e6e13aa 100644 --- a/project/build.scala +++ b/project/build.scala @@ -3,7 +3,11 @@ import Keys._ object SbtExtras extends Build { // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. - val root = Project("sbt-packaging", file(".")) settings(Packaging.settings:_*) + val root = Project("sbt-packaging", file(".")) settings(Packaging.settings:_*) settings( + sbtVersion <<= sbtVersion apply { v => + sys.props.getOrElse("sbt.build.version", v) + } + ) val meta = Project("metapackage", file("metapackage")) settings(MetaPackaging.settings(root):_*) } diff --git a/project/project/plugins.scala b/project/project/plugins.scala index b9561d413..5ce8cb116 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -7,6 +7,6 @@ object PluginBuild extends Build { val root = Project("root", file(".")) settings( resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.3"), - libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.6" + libraryDependencies += "net.databinder" % "dispatch-http_2.9.1" % "0.8.6" ) } From 5407a218034bdc2e60e4702ced0431bae9bbe8c9 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Fri, 7 Sep 2012 13:52:05 -0400 Subject: [PATCH 146/483] Use environment variable thanks to lame sbt jenkins plugin --- project/build.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.scala b/project/build.scala index 82e6e13aa..61adf4122 100644 --- a/project/build.scala +++ b/project/build.scala @@ -5,7 +5,7 @@ object SbtExtras extends Build { // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. val root = Project("sbt-packaging", file(".")) settings(Packaging.settings:_*) settings( sbtVersion <<= sbtVersion apply { v => - sys.props.getOrElse("sbt.build.version", v) + sys.props.getOrElse("sbt.build.version", sys.env.getOrElse("sbt.build.version", v)) } ) From 0ac0a4767d944b8b8f04416a45a2b4b5f8b5199c Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Fri, 7 Sep 2012 14:08:46 -0400 Subject: [PATCH 147/483] Bumped to new sbt launcher that supports publishing universal packages. --- project/project/plugins.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/project/plugins.scala b/project/project/plugins.scala index 5ce8cb116..cf7cd2c8f 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -6,7 +6,7 @@ object PluginBuild extends Build { val root = Project("root", file(".")) settings( resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), - addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.3"), + addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.4"), libraryDependencies += "net.databinder" % "dispatch-http_2.9.1" % "0.8.6" ) } From 37f9d6bf2103f74e246ccf9ccc5c6187f61e4b03 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Sat, 22 Sep 2012 10:12:03 -0400 Subject: [PATCH 148/483] Windows config now works. Still an issue with sbt.bat not setting up paths/temp files correctly.... --- .gitattributes | 1 + project/packaging.scala | 49 ++++++++++++++++++++++++++++++++++----- src/windows/sbt.bat | 9 +++---- src/windows/sbtconfig.txt | 6 +++++ 4 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..09be01613 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +src/windows/sbtconfig.txt eol=crlf diff --git a/project/packaging.scala b/project/packaging.scala index fc5486d36..1018e7ac2 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -143,7 +143,10 @@ object Packaging { // WINDOWS SPECIFIC name in Windows := "sbt", - lightOptions ++= Seq("-ext", "WixUIExtension", "-cultures:en-us"), + candleOptions ++= Seq("-ext", "WixUtilExtension"), + lightOptions ++= Seq("-ext", "WixUIExtension", + "-ext", "WixUtilExtension", + "-cultures:en-us"), wixConfig <<= (sbtVersion, sourceDirectory in Windows) map makeWindowsXml, //wixFile <<= sourceDirectory in Windows map (_ / "sbt.xml"), mappings in packageMsi in Windows <+= sbtLaunchJar map { f => f -> "sbt-launch.jar" }, @@ -151,6 +154,7 @@ object Packaging { mappings in packageMsi in Windows <++= sourceDirectory in Windows map { d => Seq( (d / "sbt.bat") -> "sbt.bat", (d / "sbt") -> "sbt", + (d / "sbtconfig.txt") -> "sbtconfig.txt", (d / "jansi-license.txt") -> "jansi-license.txt" )}, mappings in packageMsi in Windows <+= (compile in Compile, classDirectory in Compile) map { (c, d) => @@ -196,7 +200,8 @@ object Packaging { case Array(major) => Seq(major,"0","0","1") mkString "." } ( - + + + + + + + - + + + + @@ -222,12 +236,19 @@ object Packaging { - + + + + + + + + @@ -243,7 +264,19 @@ object Packaging { - + + + + + + + + + @@ -251,10 +284,14 @@ object Packaging { + - + + + + + + + + + + + + + + + + - + - - - - - - - - + @@ -179,7 +187,7 @@ object Packaging { From 53f9de27352bd9da763a098c3d5e0c5671f37c1c Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Sat, 29 Jun 2013 10:09:42 -0400 Subject: [PATCH 162/483] Migrating to new native packaging plugin abstractions. * Use new native packaging abstractions for windows mappings. * Update universal sbt script to be cygwin friendly * Modify sbt.bat for universal layout * Fix some stty icanon (no)echo bugs in launcher script. --- project/packaging.scala | 157 ++++---------------------- project/project/plugins.scala | 6 +- src/universal/bin/sbt | 21 +--- src/universal/bin/sbt-launch-lib.bash | 15 +++ src/windows/sbt.bat | 2 +- 5 files changed, 44 insertions(+), 157 deletions(-) diff --git a/project/packaging.scala b/project/packaging.scala index 95c3d007e..852d534e0 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -23,7 +23,7 @@ object Packaging { case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" } - val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ Seq( + val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWinows ++ Seq( sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion, sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"), sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) => @@ -76,27 +76,30 @@ object Packaging { // WINDOWS SPECIFIC name in Windows := "sbt", - candleOptions ++= Seq("-ext", "WixUtilExtension"), - lightOptions ++= Seq("-ext", "WixUIExtension", - "-ext", "WixUtilExtension", - "-cultures:en-us"), + version in Windows <<= (sbtVersion) apply { sv => + (sv split "[^\\d]" filterNot (_.isEmpty)) match { + case Array(major,minor,bugfix, _*) => Seq(major,minor,bugfix, "1") mkString "." + case Array(major,minor) => Seq(major,minor,"0","1") mkString "." + case Array(major) => Seq(major,"0","0","1") mkString "." + } + }, + maintainer in Windows := "Typesafe, Inc.", + packageSummary in Windows := "Simple Build Tool", + packageDescription in Windows := "THE reactive build tool.", + wixProductId := "ce07be71-510d-414a-92d4-dff47631848a", + wixProductUpgradeId := "4552fb0e-e257-4dbd-9ecb-dba9dbacf424", javacOptions := Seq("-source", "1.5", "-target", "1.5"), - // Universal ZIP download install. TODO - Share the above windows code, here.... + // Universal ZIP download install. name in Universal := "sbt", mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" }, - mappings in Universal <+= sourceDirectory in Windows map { d => - (d / "sbt.bat") -> "bin/sbt.bat" + // TODO - move these into universal directory. + mappings in Universal <++= sourceDirectory in Windows map { d => + Seq( + (d / "sbt.bat") -> "bin/sbt.bat", + (d / "sbtconfig.txt") -> "conf/sbtconfig.txt" + ) }, - // TODO - Adapt global `sbt`/`sbt-launch-lib` scripts for universal install... - - // Windows customizations - mappings in Windows <++= mappings in Universal, - mappings in Windows <++= sourceDirectory in Windows map { d => Seq( - (d / "sbtconfig.txt") -> "conf/sbtconfig.txt" - )}, - wixConfig <<= (sbtVersion, sourceDirectory in Windows) map makeWindowsXml, - wixConfig in Windows <<= wixConfig, // Misccelaneous publishing stuff... projectID in Debian <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) }, @@ -111,124 +114,4 @@ object Packaging { dir } ) - - def makeWindowsXml(sbtVersion: String, sourceDir: File): scala.xml.Node = { - val version = (sbtVersion split "[^\\d]" filterNot (_.isEmpty)) match { - case Array(major,minor,bugfix, _*) => Seq(major,minor,bugfix, "1") mkString "." - case Array(major,minor) => Seq(major,minor,"0","1") mkString "." - case Array(major) => Seq(major,"0","0","1") mkString "." - } - ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ) - } } diff --git a/project/project/plugins.scala b/project/project/plugins.scala index 50b787b71..73f5ef970 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -6,10 +6,10 @@ object PluginBuild extends Build { val root = Project("root", file(".")) settings( resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), - addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.0-symlink-2"), + addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.0-symlink-3"), libraryDependencies += "net.databinder" % "dispatch-http_2.9.1" % "0.8.6" - ) /*dependsOn(nativePackager)*/ + ) //dependsOn(nativePackager) - /*lazy val nativePackager = uri("file:///home/jsuereth/projects/sbt/sbt-native-packager")*/ + //lazy val nativePackager = uri("file:///C:/projects/sbt-native-packager") } diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 24bf2f6cd..24c9799a2 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -51,7 +51,11 @@ cygwinpath() { fi } -. $(dirname "$(realpath "$0")")/sbt-launch-lib.bash +if [[ "$CYGWIN_FLAG" == "true" ]]; then + . $(dirname "$(cygpath "$(realpath "$0")")")/sbt-launch-lib.bash +else + . $(dirname "$(realpath "$0")")/sbt-launch-lib.bash +fi declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" @@ -129,14 +133,6 @@ loadConfigFile() { cat "$1" | sed '/^\#/d' } - -#If we're in cygwin, we should use the windows config, and terminal hacks -if [[ "$CYGWIN_FLAG" == "true" ]]; then - stty -icanon min 1 -echo > /dev/null 2>&1 - addJava "-Djline.terminal=jline.UnixTerminal" - addJava "-Dsbt.cygwin=true" -fi - # TODO - Pull in config based on operating system... (MSYS + cygwin should pull in txt file). # Here we pull in the global settings configuration. [[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@" @@ -149,11 +145,4 @@ fi run "$@" -exit_code=$? - -# Clean up the terminal from cygwin hacks. -if [[ "$IS_CYGWIN" == "true" ]] then - stty icanon echo > /dev/null 2>&1 -fi -exit $exit_code diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 0e159e759..37bf2ee2d 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -172,6 +172,13 @@ run() { # TODO - java check should be configurable... checkJava "1.6" + #If we're in cygwin, we should use the windows config, and terminal hacks + if [[ "$CYGWIN_FLAG" == "true" ]]; then + stty -icanon min 1 -echo > /dev/null 2>&1 + addJava "-Djline.terminal=jline.UnixTerminal" + addJava "-Dsbt.cygwin=true" + fi + # run sbt execRunner "$java_cmd" \ ${SBT_OPTS:-$default_sbt_opts} \ @@ -181,6 +188,14 @@ run() { -jar "$sbt_jar" \ "${sbt_commands[@]}" \ "${residual_args[@]}" + + exit_code=$? + + # Clean up the terminal from cygwin hacks. + if [[ "$IS_CYGWIN" == "true" ]]; then + stty icanon echo > /dev/null 2>&1 + fi + exit $exit_code } runAlternateBoot() { diff --git a/src/windows/sbt.bat b/src/windows/sbt.bat index 854a4a85c..2ffeb3774 100644 --- a/src/windows/sbt.bat +++ b/src/windows/sbt.bat @@ -14,7 +14,7 @@ set SBT_HOME=%~dp0 set ERROR_CODE=0 rem FIRST we load the config file of extra options. -set FN=%SBT_HOME%sbtconfig.txt +set FN=%SBT_HOME%\..\conf\sbtconfig.txt set CFG_OPTS= FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%FN%") DO ( set DO_NOT_REUSE_ME=%%i From d16ab1abd14656902a4b44555c550057e5c125bf Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Sat, 29 Jun 2013 10:21:58 -0400 Subject: [PATCH 163/483] Migrate universal windows scripts into universal directory. ALso, added back the commented sbtopts settings. --- project/packaging.scala | 7 - src/{windows => universal/bin}/sbt.bat | 0 src/{windows => universal/conf}/sbtconfig.txt | 0 src/universal/conf/sbtopts | 49 +++++ src/windows/jansi-license.txt | 202 ------------------ src/windows/sbt.xml | 36 ---- 6 files changed, 49 insertions(+), 245 deletions(-) rename src/{windows => universal/bin}/sbt.bat (100%) rename src/{windows => universal/conf}/sbtconfig.txt (100%) delete mode 100644 src/windows/jansi-license.txt delete mode 100644 src/windows/sbt.xml diff --git a/project/packaging.scala b/project/packaging.scala index 852d534e0..3f9188f38 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -93,13 +93,6 @@ object Packaging { // Universal ZIP download install. name in Universal := "sbt", mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" }, - // TODO - move these into universal directory. - mappings in Universal <++= sourceDirectory in Windows map { d => - Seq( - (d / "sbt.bat") -> "bin/sbt.bat", - (d / "sbtconfig.txt") -> "conf/sbtconfig.txt" - ) - }, // Misccelaneous publishing stuff... projectID in Debian <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) }, diff --git a/src/windows/sbt.bat b/src/universal/bin/sbt.bat similarity index 100% rename from src/windows/sbt.bat rename to src/universal/bin/sbt.bat diff --git a/src/windows/sbtconfig.txt b/src/universal/conf/sbtconfig.txt similarity index 100% rename from src/windows/sbtconfig.txt rename to src/universal/conf/sbtconfig.txt diff --git a/src/universal/conf/sbtopts b/src/universal/conf/sbtopts index e69de29bb..f018465af 100644 --- a/src/universal/conf/sbtopts +++ b/src/universal/conf/sbtopts @@ -0,0 +1,49 @@ +# ------------------------------------------------ # +# The SBT Configuration file. # +# ------------------------------------------------ # + + +# Disable ANSI color codes +# +#-no-colors + +# Starts sbt even if the current directory contains no sbt project. +# +-sbt-create + +# Path to global settings/plugins directory (default: ~/.sbt) +# +#-sbt-dir /etc/sbt + +# Path to shared boot directory (default: ~/.sbt/boot in 0.11 series) +# +#-sbt-boot ~/.sbt/boot + +# Path to local Ivy repository (default: ~/.ivy2) +# +#-ivy ~/.ivy2 + +# set memory options +# +#-mem + +# Use local caches for projects, no sharing. +# +#-no-share + +# Put SBT in offline mode. +# +#-offline + +# Sets the SBT version to use. +#-sbt-version 0.11.3 + +# Scala version (default: latest release) +# +#-scala-home +#-scala-version + +# java version (default: java from PATH, currently $(java -version |& grep version)) +# +#-java-home + diff --git a/src/windows/jansi-license.txt b/src/windows/jansi-license.txt deleted file mode 100644 index d64569567..000000000 --- a/src/windows/jansi-license.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/src/windows/sbt.xml b/src/windows/sbt.xml deleted file mode 100644 index bb0c3e020..000000000 --- a/src/windows/sbt.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 18352254e0dfe93987c0dde1d8aa450b144fb723 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Sat, 29 Jun 2013 10:23:49 -0400 Subject: [PATCH 164/483] Fix config file loading to do shell expansion first. from @benevans. --- src/universal/bin/sbt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 24c9799a2..427857fd5 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -130,7 +130,9 @@ process_my_args () { } loadConfigFile() { - cat "$1" | sed '/^\#/d' + for line in $(cat "$1" | sed '/^\#/d'); do + eval echo $line + done } # TODO - Pull in config based on operating system... (MSYS + cygwin should pull in txt file). From 08fb68c324f961975acad90020fd8ab5de341ce6 Mon Sep 17 00:00:00 2001 From: Alex Henning Johannessen Date: Sat, 13 Jul 2013 13:47:26 +0100 Subject: [PATCH 165/483] Removed duplicated code with regards to projectID generation. --- project/packaging.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/project/packaging.scala b/project/packaging.scala index 3f9188f38..6fdb8e7ab 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -8,7 +8,7 @@ object Packaging { val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url") val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") - + val moduleID = (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) } val stagingDirectory = SettingKey[File]("staging-directory") val stage = TaskKey[File]("stage") @@ -95,10 +95,10 @@ object Packaging { mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" }, // Misccelaneous publishing stuff... - projectID in Debian <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) }, - projectID in Windows <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) }, - projectID in Rpm <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) }, - projectID in Universal <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) }, + projectID in Debian <<= moduleID, + projectID in Windows <<= moduleID, + projectID in Rpm <<= moduleID, + projectID in Universal <<= moduleID, stagingDirectory <<= (target) apply { (t) => t / "stage" }, stage <<= (stagingDirectory, mappings in Universal) map { (dir, m) => val files = for((file, name) <- m) From d50c5973188cef90291318cf47bdd0f56c4a8a79 Mon Sep 17 00:00:00 2001 From: "U-jsuereth-win\\jsuereth" Date: Sun, 14 Jul 2013 15:26:05 -0400 Subject: [PATCH 166/483] Initial fixes for cygwin issues #50 --- src/universal/bin/sbt | 13 +++++++------ src/universal/bin/sbt-launch-lib.bash | 3 +-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 427857fd5..208527c39 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -8,6 +8,7 @@ realpath () { ( TARGET_FILE="$1" + FIX_CYGPATH="$2" cd $(dirname "$TARGET_FILE") TARGET_FILE=$(basename "$TARGET_FILE") @@ -22,7 +23,11 @@ realpath () { done # make sure we grab the actual windows path, instead of cygwin's path. - echo $(cygwinpath "$(pwd -P)/$TARGET_FILE") + if [[ "x$FIX_CYGPATH" != "x" ]]; then + echo "$(cygwinpath "$(pwd -P)/$TARGET_FILE")" + else + echo "$(pwd -P)/$TARGET_FILE" + fi ) } @@ -51,11 +56,7 @@ cygwinpath() { fi } -if [[ "$CYGWIN_FLAG" == "true" ]]; then - . $(dirname "$(cygpath "$(realpath "$0")")")/sbt-launch-lib.bash -else - . $(dirname "$(realpath "$0")")/sbt-launch-lib.bash -fi +. $(dirname "$(realpath "$0")")/sbt-launch-lib.bash declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 37bf2ee2d..9a5d557a4 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -31,8 +31,7 @@ dlog () { } jar_file () { - # TODO - Is this where we want the launch jar? - echo "${sbt_home}/bin/sbt-launch.jar" + echo "$(cygwinpath "${sbt_home}/bin/sbt-launch.jar")" } acquire_sbt_jar () { From 2b462315e5bdc8add17a2208d3b3008af31b75b7 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Sun, 14 Jul 2013 15:36:07 -0400 Subject: [PATCH 167/483] Reduce necessary memory --- src/universal/bin/sbt-launch-lib.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 9a5d557a4..760bade4e 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -76,9 +76,9 @@ addDebugger () { } # a ham-fisted attempt to move some memory settings in concert -# so they need not be dicked around with individually. +# so they need not be dorked around with individually. get_mem_opts () { - local mem=${1:-1536} + local mem=${1:-1024} local perm=$(( $mem / 4 )) (( $perm > 256 )) || perm=256 (( $perm < 1024 )) || perm=1024 From 595501304ef7bc7196d7d3be91f7815dd70a560f Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 30 Jul 2013 19:27:39 -0400 Subject: [PATCH 168/483] Refixes #50. Apparently a stealth cd was causing issues here. --- src/universal/bin/sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 208527c39..efa1987df 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -10,14 +10,14 @@ realpath () { TARGET_FILE="$1" FIX_CYGPATH="$2" - cd $(dirname "$TARGET_FILE") + cd "$(dirname "$TARGET_FILE")" TARGET_FILE=$(basename "$TARGET_FILE") COUNT=0 while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ] do TARGET_FILE=$(readlink "$TARGET_FILE") - cd $(dirname "$TARGET_FILE") + cd "$(dirname "$TARGET_FILE")" TARGET_FILE=$(basename "$TARGET_FILE") COUNT=$(($COUNT + 1)) done @@ -56,7 +56,7 @@ cygwinpath() { fi } -. $(dirname "$(realpath "$0")")/sbt-launch-lib.bash +. "$(dirname "$(realpath "$0")")/sbt-launch-lib.bash" declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" From 19f9330c320cfd013747ecf9be8a0b6f2ee1ba78 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 30 Jul 2013 19:38:33 -0400 Subject: [PATCH 169/483] Fixes #53 - echo disabled after sbt exits. Bad flag in bash. Wish this thing had a compiler.... --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 760bade4e..0c1b4d509 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -191,7 +191,7 @@ run() { exit_code=$? # Clean up the terminal from cygwin hacks. - if [[ "$IS_CYGWIN" == "true" ]]; then + if [[ "$CYGWIN_FLAG" == "true" ]]; then stty icanon echo > /dev/null 2>&1 fi exit $exit_code From 1a0715056050469b5b713d11d635f782b829f7bf Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 30 Jul 2013 19:49:17 -0400 Subject: [PATCH 170/483] Turns out the cygwin fix involved a bit more work. We can't exec bash, because we can't give over our process to sbt if we want to turn echo back on later. --- src/universal/bin/sbt | 2 ++ src/universal/bin/sbt-launch-lib.bash | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index efa1987df..c70c4aea8 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -56,6 +56,8 @@ cygwinpath() { fi } + +echo "Loading $(dirname "$(realpath "$0")")/sbt-launch-lib.bash" . "$(dirname "$(realpath "$0")")/sbt-launch-lib.bash" diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 0c1b4d509..265e87431 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -56,7 +56,9 @@ execRunner () { echo "" } - exec "$@" + # THis used to be exec, but we loose the ability to re-hook stty then + # for cygwin... Maybe we should flag the feature here... + "$@" } addJava () { @@ -182,12 +184,12 @@ run() { execRunner "$java_cmd" \ ${SBT_OPTS:-$default_sbt_opts} \ $(get_mem_opts $sbt_mem) \ - ${java_opts} \ + ${java_opts} \ ${java_args[@]} \ -jar "$sbt_jar" \ "${sbt_commands[@]}" \ - "${residual_args[@]}" - + "${residual_args[@]}" + exit_code=$? # Clean up the terminal from cygwin hacks. From 44b651d6079c98001d234d80b0a90e3bd8502b69 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 4 Sep 2013 11:50:58 -0400 Subject: [PATCH 171/483] Modify publishing to send packages into bintray. * Use rpm repository for rpms * Use debian repository for debians * Use generic repository for everything else. Note: we still need to mark a release as public afterwards with an API call. Need to figure that one out for automation. --- build.sbt | 14 ++------------ project/build.properties | 2 +- project/packaging.scala | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/build.sbt b/build.sbt index 2b89cd7be..9b16c9b80 100644 --- a/build.sbt +++ b/build.sbt @@ -1,18 +1,8 @@ -sbtPlugin := true - -name := "sbt-launcher-package" - organization := "org.scala-sbt" +name := "sbt-launcher-packaging" + version := "0.1.0" crossTarget <<= target -publishTo in Global := { - val nativeReleaseUrl = "http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages" - val nativeReleasePattern = "[organization]/[module]/[revision]/[module].[ext]" - val resolver = Resolver.url("native-releases", new URL(nativeReleaseUrl))(Patterns(nativeReleasePattern)) -// Resolver.file("native-releases-local", file("/home/jsuereth/repos/native-packages"))(Patterns(nativeReleasePattern)) - Some(resolver) -} - diff --git a/project/build.properties b/project/build.properties index 1ced03cad..5e96e9672 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.12.4-RC1 +sbt.version=0.12.4 diff --git a/project/packaging.scala b/project/packaging.scala index 6fdb8e7ab..c75922d56 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -12,7 +12,15 @@ object Packaging { val stagingDirectory = SettingKey[File]("staging-directory") val stage = TaskKey[File]("stage") - def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]" + val bintrayLinuxPattern = "[module]/[revision]/[module]-[revision].[ext]" + val bintrayGenericPattern = "[module]/[revision]/[module]/[revision]/[module]-[revision].[ext]" + val bintrayDebianUrl = "https://api.bintray.com/content/sbt/debian/" + val bintrayRpmUrl = "https://api.bintray.com/content/sbt/rpm/" + val bintrayGenericPackagesUrl = "https://api.bintray.com/content/sbt/native-packages/" + + // Note: The legacy api. + //val genericNativeReleasesUrl = "http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages" + //val genericNativeReleasesPattern = "[organisation]/[module]/[revision]/[module].[ext]" import util.control.Exception.catching @@ -22,8 +30,33 @@ object Packaging { case Array(0, y, _*) if y >= 12 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" } + /** Returns an id, url and pattern for publishing based on the given configuration. */ + def getPublishSettings(config: Configuration): (String, String, String) = + config.name match { + case Debian.name => ("bintray-debian", bintrayDebianUrl, bintrayLinuxPattern) + case Rpm.name => ("bintray-rpm", bintrayRpmUrl, bintrayLinuxPattern) + case _ => ("generic-native-packages-" + config.name, bintrayGenericPackagesUrl, bintrayGenericPattern) + } + + def makePublishTo(id: String, url: String, pattern: String): Setting[_] = { + publishTo := { + val resolver = Resolver.url(id, new URL(url))(Patterns(pattern)) + Some(resolver) + } + } + + def makePublishToForConfig(config: Configuration) = { + val (id, url, pattern) = getPublishSettings(config) + // Add the publish to and ensure global resolvers has the resolver we just configured. + inConfig(config)(Seq(makePublishTo(id, url, pattern))) ++ + Seq(resolvers <++= (publishTo in config) apply (_.toSeq)) + } - val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWinows ++ Seq( + def publishToSettings: Seq[Setting[_]] = + Seq[Configuration](Debian, Universal, Windows, Rpm) flatMap makePublishToForConfig + + + val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWinows ++ publishToSettings ++ Seq( sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion, sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"), sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) => From 5994a7bec5f5c0b645d672a082bbe54acba2c6b3 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 6 Jan 2014 09:30:02 -0500 Subject: [PATCH 172/483] Upgrade to sbt 0.13.1 --- project/build.properties | 2 +- project/packaging.scala | 15 +++------------ project/project/plugins.scala | 4 ++-- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/project/build.properties b/project/build.properties index 1ced03cad..37b489cb6 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.12.4-RC1 +sbt.version=0.13.1 diff --git a/project/packaging.scala b/project/packaging.scala index 6fdb8e7ab..1bc1e2bf8 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -9,8 +9,6 @@ object Packaging { val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") val moduleID = (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) } - val stagingDirectory = SettingKey[File]("staging-directory") - val stage = TaskKey[File]("stage") def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]" @@ -23,11 +21,11 @@ object Packaging { case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" } - val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWinows ++ Seq( + val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWindows ++ Seq( sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion, sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"), sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) => - import dispatch._ + import dispatch.classic._ if(!file.exists) { // oddly, some places require us to create the file before writing... IO.touch(file) @@ -98,13 +96,6 @@ object Packaging { projectID in Debian <<= moduleID, projectID in Windows <<= moduleID, projectID in Rpm <<= moduleID, - projectID in Universal <<= moduleID, - stagingDirectory <<= (target) apply { (t) => t / "stage" }, - stage <<= (stagingDirectory, mappings in Universal) map { (dir, m) => - val files = for((file, name) <- m) - yield file -> (dir / name) - IO copy files - dir - } + projectID in Universal <<= moduleID ) } diff --git a/project/project/plugins.scala b/project/project/plugins.scala index 73f5ef970..ddc50a0f4 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -6,8 +6,8 @@ object PluginBuild extends Build { val root = Project("root", file(".")) settings( resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), - addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.0-symlink-3"), - libraryDependencies += "net.databinder" % "dispatch-http_2.9.1" % "0.8.6" + addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.3"), + libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.10" ) //dependsOn(nativePackager) From 163c822ff3f88d6b9b867728b9374551e92bb0a3 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 6 Jan 2014 09:36:50 -0500 Subject: [PATCH 173/483] Removing debugging of loading bin helper. --- src/universal/bin/sbt | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index c70c4aea8..efa1987df 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -56,8 +56,6 @@ cygwinpath() { fi } - -echo "Loading $(dirname "$(realpath "$0")")/sbt-launch-lib.bash" . "$(dirname "$(realpath "$0")")/sbt-launch-lib.bash" From 8e4dbbaf0c00e049333d6ac07a0b07c02a3e5581 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 6 Jan 2014 09:39:29 -0500 Subject: [PATCH 174/483] -mem options only used if not otherwise specified directly. --- src/universal/bin/sbt-launch-lib.bash | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 265e87431..b87cabae2 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -78,7 +78,7 @@ addDebugger () { } # a ham-fisted attempt to move some memory settings in concert -# so they need not be dorked around with individually. +# so they need not be messed around with individually. get_mem_opts () { local mem=${1:-1024} local perm=$(( $mem / 4 )) @@ -86,7 +86,13 @@ get_mem_opts () { (( $perm < 1024 )) || perm=1024 local codecache=$(( $perm / 2 )) - echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" + # if we detect any of these settings in ${java_opts} we need to NOT output our settings. + # The reason is the Xms/Xmx, if they don't line up, cause errors. + if [[ "${java_opts}" == *-Xmx* ]] || [[ "${java_opts}" == *-Xms* ]] || [[ "${java_opts}" == *-XX:MaxPermSize* ]] || [[ "${java_opts}" == *-XX:ReservedCodeCacheSize* ]]; then + echo "" + else + echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" + fi } require_arg () { From f51c51edbee5640ef030b4e0d75fdec98148fc47 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 6 Jan 2014 10:41:23 -0500 Subject: [PATCH 175/483] Fix publishing to bintray to automatically make artifacts available after succesful upload. --- project/packaging.scala | 50 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/project/packaging.scala b/project/packaging.scala index a2fa44648..a86d06446 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -15,6 +15,7 @@ object Packaging { val bintrayDebianUrl = "https://api.bintray.com/content/sbt/debian/" val bintrayRpmUrl = "https://api.bintray.com/content/sbt/rpm/" val bintrayGenericPackagesUrl = "https://api.bintray.com/content/sbt/native-packages/" + val bintrayPublishAllStaged = TaskKey[Unit]("bintray-publish-all-staged", "Publish all staged artifacts on bintray.") // Note: The legacy api. //val genericNativeReleasesUrl = "http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages" @@ -31,9 +32,9 @@ object Packaging { /** Returns an id, url and pattern for publishing based on the given configuration. */ def getPublishSettings(config: Configuration): (String, String, String) = config.name match { - case Debian.name => ("bintray-debian", bintrayDebianUrl, bintrayLinuxPattern) - case Rpm.name => ("bintray-rpm", bintrayRpmUrl, bintrayLinuxPattern) - case _ => ("generic-native-packages-" + config.name, bintrayGenericPackagesUrl, bintrayGenericPattern) + case Debian.name => ("debian", bintrayDebianUrl, bintrayLinuxPattern) + case Rpm.name => ("rpm", bintrayRpmUrl, bintrayLinuxPattern) + case _ => ("native-packages", bintrayGenericPackagesUrl, bintrayGenericPattern) } def makePublishTo(id: String, url: String, pattern: String): Setting[_] = { @@ -45,14 +46,52 @@ object Packaging { def makePublishToForConfig(config: Configuration) = { val (id, url, pattern) = getPublishSettings(config) + + // Add the publish to and ensure global resolvers has the resolver we just configured. - inConfig(config)(Seq(makePublishTo(id, url, pattern))) ++ - Seq(resolvers <++= (publishTo in config) apply (_.toSeq)) + inConfig(config)(Seq( + makePublishTo(id, url, pattern), + bintrayPublishAllStaged <<= (credentials, version) map { (creds, version) => + publishContent(id, version, creds) + }, + // TODO - This is a little funky... + publish <<= (publish, credentials, version) apply { (publish, creds, version) => + for { + pub <- publish + creds <- creds + } yield publishContent(id, version, creds) + } + )) ++ Seq( + resolvers <++= (publishTo in config) apply (_.toSeq) + ) } def publishToSettings: Seq[Setting[_]] = Seq[Configuration](Debian, Universal, Windows, Rpm) flatMap makePublishToForConfig + def bintrayCreds(creds: Seq[sbt.Credentials]): (String, String) = { + val matching = + for { + c <- creds + if c.isInstanceOf[sbt.DirectCredentials] + val cred = c.asInstanceOf[sbt.DirectCredentials] + if cred.host == "api.bintray.com" + } yield cred.userName -> cred.passwd + + matching.headOption getOrElse sys.error("Unable to find bintray credentials (api.bintray.com)") + } + + def publishContent(repo: String, version: String, creds: Seq[sbt.Credentials]): Unit = { + val subject = "sbt" // Sbt org + val pkg = "sbt" // Sbt package + val uri = s"https://bintray.com/api/v1/content/$subject/$repo/$pkg/$version/publish" + + val (u,p) = bintrayCreds(creds) + import dispatch.classic._ + // TODO - Log the output + Http(url(uri).POST.as(u,p).>|) + } + val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWindows ++ publishToSettings ++ Seq( sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion, @@ -123,6 +162,7 @@ object Packaging { // Universal ZIP download install. name in Universal := "sbt", + version in Universal <<= sbtVersion, mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" }, // Misccelaneous publishing stuff... From d880e9319231eaf64c2708aa96a91dd8a33b19cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Pasche?= Date: Mon, 13 Jan 2014 15:35:24 +0100 Subject: [PATCH 176/483] Adding rpm dependencies Requirements and Provides --- project/packaging.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project/packaging.scala b/project/packaging.scala index a86d06446..fcd98d33a 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -142,6 +142,8 @@ object Packaging { rpmVendor := "typesafe", rpmUrl := Some("http://github.com/paulp/sbt-extras"), rpmLicense := Some("BSD"), + rpmRequirements :=Seq("java","java-devel","jpackage-utils","jansi","jline","jline2"), + rpmProvides := Seq("sbt"), // WINDOWS SPECIFIC From 4d1d5c0a3d8e2a97e48919ed0186ea7b9336a7ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Pasche?= Date: Mon, 13 Jan 2014 15:35:41 +0100 Subject: [PATCH 177/483] Updating minor version --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 37b489cb6..8ac605a3d 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.1 +sbt.version=0.13.2 From cdf2f4d89d906f012c5b2b0c17dcc9bb65048c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Pasche?= Date: Mon, 13 Jan 2014 16:46:17 +0100 Subject: [PATCH 178/483] Removing useless depsm thx to mighty sbt resolver --- project/packaging.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/packaging.scala b/project/packaging.scala index fcd98d33a..866ced574 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -142,7 +142,7 @@ object Packaging { rpmVendor := "typesafe", rpmUrl := Some("http://github.com/paulp/sbt-extras"), rpmLicense := Some("BSD"), - rpmRequirements :=Seq("java","java-devel","jpackage-utils","jansi","jline","jline2"), + rpmRequirements :=Seq("java","java-devel","jpackage-utils"), rpmProvides := Seq("sbt"), From b360b59f5aa68f0c7659ac04d428bed452cf4e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Pasche?= Date: Mon, 13 Jan 2014 16:46:32 +0100 Subject: [PATCH 179/483] Cleaning version number --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 8ac605a3d..37b489cb6 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.2 +sbt.version=0.13.1 From c2fcf34896a9a848d3fed501e10bd20adae2ccf3 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 21 Jan 2014 08:09:21 -0500 Subject: [PATCH 180/483] Adding travis configuration to the build. --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..5603ef833 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: scala +script: + - sbt ++$TRAVIS_SCALA_VERSION rpm:packageBin debian:packageBin universal:packageBin +scala: + - 2.10.3 +jdk: + - openjdk6 +notifications: + email: + - qbranch@typesafe.com From 67648b76263b2218b39dd88b469a7b94abda157a Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 21 Jan 2014 08:17:24 -0500 Subject: [PATCH 181/483] Add rpmbuld to travis-ci config. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5603ef833..0f949c800 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,3 +8,6 @@ jdk: notifications: email: - qbranch@typesafe.com +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq rpm From d5be7069e233ff4a1c6e0e0a02850c8be93bcd07 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 20 Feb 2014 08:31:19 -0500 Subject: [PATCH 182/483] Fix debian metadata. Fixes #51 * Move to java6-runtime-headless metapackage * Remove curl requirement (missed when removing that feature) --- project/packaging.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/packaging.scala b/project/packaging.scala index 866ced574..b9ed707b0 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -127,7 +127,7 @@ object Packaging { val nums = (v split "[^\\d]") "%s-%s-build-%03d" format (sv, (nums.init mkString "."), nums.last.toInt + 1) }, - debianPackageDependencies in Debian ++= Seq("curl", "java2-runtime", "bash (>= 2.05a-11)"), + debianPackageDependencies in Debian ++= Seq("java6-runtime-headless", "bash (>= 2.05a-11)"), debianPackageRecommends in Debian += "git", linuxPackageMappings in Debian <+= (sourceDirectory) map { bd => (packageMapping( From af97d53ec7b4cb92c85ca35b4d54b1698258baf2 Mon Sep 17 00:00:00 2001 From: Jason M Ray Date: Thu, 6 Mar 2014 19:18:16 -0800 Subject: [PATCH 183/483] Fixing exit code handling The endlocal statement will wipe out the ERROR_CODE variable, so we cannot access %ERROR_CODE% after endlocal. --- src/universal/bin/sbt.bat | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 2ffeb3774..0b707814b 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -11,7 +11,6 @@ @echo off set SBT_HOME=%~dp0 -set ERROR_CODE=0 rem FIRST we load the config file of extra options. set FN=%SBT_HOME%\..\conf\sbtconfig.txt @@ -45,10 +44,10 @@ if ERRORLEVEL 1 goto error goto end :error -set ERROR_CODE=1 +@endlocal +exit /B 1 + :end - @endlocal - -exit /B %ERROR_CODE% +exit /B 0 From c2deacbcbb2ebe48c9dc0b8c7a2c1133511588b0 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Wed, 23 Apr 2014 00:02:12 +0100 Subject: [PATCH 184/483] Only calculate memory opts if we need them... ...don't bother if won't use them due to them already being defined. --- src/universal/bin/sbt-launch-lib.bash | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index b87cabae2..243a8a832 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -77,20 +77,20 @@ addDebugger () { addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" } -# a ham-fisted attempt to move some memory settings in concert -# so they need not be messed around with individually. get_mem_opts () { - local mem=${1:-1024} - local perm=$(( $mem / 4 )) - (( $perm > 256 )) || perm=256 - (( $perm < 1024 )) || perm=1024 - local codecache=$(( $perm / 2 )) - # if we detect any of these settings in ${java_opts} we need to NOT output our settings. # The reason is the Xms/Xmx, if they don't line up, cause errors. if [[ "${java_opts}" == *-Xmx* ]] || [[ "${java_opts}" == *-Xms* ]] || [[ "${java_opts}" == *-XX:MaxPermSize* ]] || [[ "${java_opts}" == *-XX:ReservedCodeCacheSize* ]]; then echo "" - else + else + # a ham-fisted attempt to move some memory settings in concert + # so they need not be messed around with individually. + local mem=${1:-1024} + local perm=$(( $mem / 4 )) + (( $perm > 256 )) || perm=256 + (( $perm < 1024 )) || perm=1024 + local codecache=$(( $perm / 2 )) + echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" fi } From f716915f5270fad678b7dd1506332145561ec3c0 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Wed, 23 Apr 2014 00:24:17 +0100 Subject: [PATCH 185/483] Don't pass MaxPermSize to Java 8+ This change stops this annoying message being written to stderr (which can cause IntelliJ to freak): ``` Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 ``` See also: https://bugs.openjdk.java.net/browse/JDK-6964458 https://github.com/sbt/sbt-native-packager/issues/203 https://github.com/typesafehub/activator/issues/422 --- src/universal/bin/sbt-launch-lib.bash | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 243a8a832..7f576f2d1 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -17,6 +17,7 @@ declare -a java_args declare -a scalac_args declare -a sbt_commands declare java_cmd=java +declare java_version declare -r sbt_bin_dir="$(dirname "$(realpath "$0")")" declare -r sbt_home="$(dirname "$sbt_bin_dir")" @@ -86,12 +87,17 @@ get_mem_opts () { # a ham-fisted attempt to move some memory settings in concert # so they need not be messed around with individually. local mem=${1:-1024} - local perm=$(( $mem / 4 )) - (( $perm > 256 )) || perm=256 - (( $perm < 1024 )) || perm=1024 - local codecache=$(( $perm / 2 )) + local codecache=$(( $mem / 8 )) + (( $codecache > 128 )) || codecache=128 + (( $codecache < 512 )) || codecache=512 - echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" + local common_opts="-Xms${mem}m -Xmx${mem}m -XX:ReservedCodeCacheSize=${codecache}m" + if [[ "$java_version" < "1.8" ]]; then + local perm=$(( $codecache * 2 )) + echo "$common_opts -XX:MaxPermSize=${perm}m" + else + echo "$common_opts" + fi fi } @@ -136,13 +142,15 @@ process_args () { residual_args=() process_my_args "${myargs[@]}" } + + java_version=$("$java_cmd" -version 2>&1 | awk -F '"' '/version/ {print $2}') + vlog "[process_args] java_version = '$java_version'" } # Detect that we have java installed. checkJava() { local required_version="$1" # Now check to see if it's a good enough version - declare -r java_version=$("$java_cmd" -version 2>&1 | awk -F '"' '/version/ {print $2}') if [[ "$java_version" == "" ]]; then echo echo No java installations was detected. From c62738810272d1a81d57bcaf06ea2e47e711d0a0 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 1 May 2014 14:08:27 -0400 Subject: [PATCH 186/483] Bump for bintray publishing. --- project/build.properties | 2 +- project/packaging.scala | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/project/build.properties b/project/build.properties index 37b489cb6..8ac605a3d 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.1 +sbt.version=0.13.2 diff --git a/project/packaging.scala b/project/packaging.scala index b9ed707b0..eba9aa297 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -122,11 +122,8 @@ object Packaging { } yield link }, // DEBIAN SPECIFIC - name in Debian <<= (sbtVersion) apply { (sv) => "sbt" /* + "-" + (sv split "[^\\d]" take 3 mkString ".")*/ }, - version in Debian <<= (version, sbtVersion) apply { (v, sv) => - val nums = (v split "[^\\d]") - "%s-%s-build-%03d" format (sv, (nums.init mkString "."), nums.last.toInt + 1) - }, + name in Debian <<= "sbt", + version in Debian <<= sbtVersion, debianPackageDependencies in Debian ++= Seq("java6-runtime-headless", "bash (>= 2.05a-11)"), debianPackageRecommends in Debian += "git", linuxPackageMappings in Debian <+= (sourceDirectory) map { bd => From 9c296f96fb5dbb810d122c97db63379155b3d941 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 1 May 2014 14:10:35 -0400 Subject: [PATCH 187/483] Fix typo. --- project/packaging.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/packaging.scala b/project/packaging.scala index eba9aa297..194a69cbc 100644 --- a/project/packaging.scala +++ b/project/packaging.scala @@ -122,7 +122,7 @@ object Packaging { } yield link }, // DEBIAN SPECIFIC - name in Debian <<= "sbt", + name in Debian := "sbt", version in Debian <<= sbtVersion, debianPackageDependencies in Debian ++= Seq("java6-runtime-headless", "bash (>= 2.05a-11)"), debianPackageRecommends in Debian += "git", From bb21b9ce09a3dab46a801535b4dd02084affbc01 Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Thu, 11 Sep 2014 17:01:54 +0200 Subject: [PATCH 188/483] Remove unused variable script_dir This variable used to be set based on either $HOME or $script_path. However, $script_path is no longer set, so when $HOME is unset there will be an 'dirname: missing operand' error message. $script_dir is no longer used either, so we can safely remove it entirely. --- src/universal/bin/sbt-launch-lib.bash | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 7f576f2d1..5bb490746 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -6,12 +6,6 @@ # TODO - Should we merge the main SBT script with this library? -if test -z "$HOME"; then - declare -r script_dir="$(dirname $script_path)" -else - declare -r script_dir="$HOME/.sbt" -fi - declare -a residual_args declare -a java_args declare -a scalac_args From cb12ec1eaa6907273edd716356b33c6bec407fac Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Wed, 1 Oct 2014 09:24:01 +0100 Subject: [PATCH 189/483] Use MaxMetaspaceSize rather than MaxPermSize on Java 8 @jroper points out that class metadata has to go somewhere, and it's new name is 'Metaspace' - not 'PermGen': https://github.com/sbt/sbt-launcher-package/pull/66#issuecomment-57407643 http://java.dzone.com/articles/java-8-permgen-metaspace --- src/universal/bin/sbt-launch-lib.bash | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 7f576f2d1..015a03bcf 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -81,7 +81,7 @@ addDebugger () { get_mem_opts () { # if we detect any of these settings in ${java_opts} we need to NOT output our settings. # The reason is the Xms/Xmx, if they don't line up, cause errors. - if [[ "${java_opts}" == *-Xmx* ]] || [[ "${java_opts}" == *-Xms* ]] || [[ "${java_opts}" == *-XX:MaxPermSize* ]] || [[ "${java_opts}" == *-XX:ReservedCodeCacheSize* ]]; then + if [[ "${java_opts}" == *-Xmx* ]] || [[ "${java_opts}" == *-Xms* ]] || [[ "${java_opts}" == *-XX:MaxPermSize* ]] || [[ "${java_opts}" == *-XX:MaxMetaspaceSize* ]] || [[ "${java_opts}" == *-XX:ReservedCodeCacheSize* ]]; then echo "" else # a ham-fisted attempt to move some memory settings in concert @@ -90,14 +90,10 @@ get_mem_opts () { local codecache=$(( $mem / 8 )) (( $codecache > 128 )) || codecache=128 (( $codecache < 512 )) || codecache=512 + local class_metadata_size=$(( $codecache * 2 )) + local class_metadata_opt=$([[ "$java_version" < "1.8" ]] && echo "MaxPermSize" || echo "MaxMetaspaceSize") - local common_opts="-Xms${mem}m -Xmx${mem}m -XX:ReservedCodeCacheSize=${codecache}m" - if [[ "$java_version" < "1.8" ]]; then - local perm=$(( $codecache * 2 )) - echo "$common_opts -XX:MaxPermSize=${perm}m" - else - echo "$common_opts" - fi + echo "-Xms${mem}m -Xmx${mem}m -XX:ReservedCodeCacheSize=${codecache}m -XX:${class_metadata_opt}=${class_metadata_size}m" fi } From 4334c8672d358b5ef4c4b8772f19aeef2d21c3e2 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 30 Oct 2014 18:06:25 +0300 Subject: [PATCH 190/483] Fixed incorrect sbtopts lines processing It used `for` loop which is known to work incorrectly with spaces. This commit changes it to `while read` loop. This allows more complex options to be specified in sbtopts files. Fixes #80 --- src/universal/bin/sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index efa1987df..48d1ff90f 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -131,7 +131,7 @@ process_my_args () { } loadConfigFile() { - for line in $(cat "$1" | sed '/^\#/d'); do + cat "$1" | sed '/^\#/d' | while read line; do eval echo $line done } From 10e95ef2406c45f8e2bc49ada18e304eb412a8ed Mon Sep 17 00:00:00 2001 From: Stephen Nancekivell Date: Wed, 29 Oct 2014 20:33:57 +1100 Subject: [PATCH 191/483] use JAVA_OPTS instead of java_opts. --- src/universal/bin/sbt-launch-lib.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index aec86baee..427aa5b0c 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -73,9 +73,9 @@ addDebugger () { } get_mem_opts () { - # if we detect any of these settings in ${java_opts} we need to NOT output our settings. + # if we detect any of these settings in ${JAVA_OPTS} we need to NOT output our settings. # The reason is the Xms/Xmx, if they don't line up, cause errors. - if [[ "${java_opts}" == *-Xmx* ]] || [[ "${java_opts}" == *-Xms* ]] || [[ "${java_opts}" == *-XX:MaxPermSize* ]] || [[ "${java_opts}" == *-XX:MaxMetaspaceSize* ]] || [[ "${java_opts}" == *-XX:ReservedCodeCacheSize* ]]; then + if [[ "${JAVA_OPTS}" == *-Xmx* ]] || [[ "${JAVA_OPTS}" == *-Xms* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxPermSize* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${JAVA_OPTS}" == *-XX:ReservedCodeCacheSize* ]]; then echo "" else # a ham-fisted attempt to move some memory settings in concert @@ -188,7 +188,7 @@ run() { execRunner "$java_cmd" \ ${SBT_OPTS:-$default_sbt_opts} \ $(get_mem_opts $sbt_mem) \ - ${java_opts} \ + ${JAVA_OPTS} \ ${java_args[@]} \ -jar "$sbt_jar" \ "${sbt_commands[@]}" \ From be20baace031ef3d38789c6b3a657f516e3b7fd6 Mon Sep 17 00:00:00 2001 From: Kousuke Saruta Date: Fri, 7 Nov 2014 15:02:02 -0800 Subject: [PATCH 192/483] Fixed debug option --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 427aa5b0c..660471e44 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -69,7 +69,7 @@ addResidual () { residual_args=( "${residual_args[@]}" "$1" ) } addDebugger () { - addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" + addJava "-agentlib:jdwp:transport=dt_socket,server=y,suspend=n,address=$1" } get_mem_opts () { From bb06511109c6c3f3365006d80ed5198975551d6e Mon Sep 17 00:00:00 2001 From: KaiXinXiaoLei Date: Thu, 13 Nov 2014 20:33:20 +0800 Subject: [PATCH 193/483] Delete unnecessary function --- src/universal/bin/sbt-launch-lib.bash | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 427aa5b0c..b55955c47 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -202,10 +202,3 @@ run() { fi exit $exit_code } - -runAlternateBoot() { - local bootpropsfile="$1" - shift - addJava "-Dsbt.boot.properties=$bootpropsfile" - run $@ -} From 9b2a1fa24a98780626c494658f6e36b797fe1737 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 20 Nov 2014 10:07:08 -0500 Subject: [PATCH 194/483] bump to sbt 0.13.7 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 8ac605a3d..748703f77 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.2 +sbt.version=0.13.7 From 477f271d45b8d9672b9f02ebe169e4e51cb179f2 Mon Sep 17 00:00:00 2001 From: Kousuke Saruta Date: Fri, 21 Nov 2014 01:10:48 +0900 Subject: [PATCH 195/483] Fixed wrong debug option --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index df9a0e41e..c761397f6 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -69,7 +69,7 @@ addResidual () { residual_args=( "${residual_args[@]}" "$1" ) } addDebugger () { - addJava "-agentlib:jdwp:transport=dt_socket,server=y,suspend=n,address=$1" + addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$1" } get_mem_opts () { From 892de8e7d745df26e1a91e3fc820b6503344dd74 Mon Sep 17 00:00:00 2001 From: William Waites Date: Tue, 20 Jan 2015 13:16:33 +0000 Subject: [PATCH 196/483] Set resource limit for ${java_cmd} -version in sbt initialisation Java is a little anti-social and attempts to lazily allocate all of system memory, even for simple operations such as printing out the version. This causes sbt to fail to start in environments where resources are limited (i.e. ulimit(1)). This setup is common on shared infrastructure such as scientific computing clusters where because of the resource limit not being specified sbt cannot be used. The limit is set to 512MB which ought to be ample and is in any case the default from sbtconfig.txt. A better patch would use the limit specified there but it isn't clear that that is worth the effort. --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index c761397f6..d57f0e951 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -133,7 +133,7 @@ process_args () { process_my_args "${myargs[@]}" } - java_version=$("$java_cmd" -version 2>&1 | awk -F '"' '/version/ {print $2}') + java_version=$("$java_cmd" -Xmx512M -version 2>&1 | awk -F '"' '/version/ {print $2}') vlog "[process_args] java_version = '$java_version'" } From c49ea8cfc40e4399bb13ec449727ac2205317cad Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 11 Aug 2015 00:39:34 -0400 Subject: [PATCH 197/483] Refactored to sbt 0.13 multi-project build.sbt --- build.sbt | 176 ++++++++++++++++++++++++++++++++++++++- project/build.properties | 2 +- project/build.scala | 11 --- project/packaging.scala | 173 -------------------------------------- 4 files changed, 173 insertions(+), 189 deletions(-) delete mode 100644 project/build.scala delete mode 100644 project/packaging.scala diff --git a/build.sbt b/build.sbt index 9b16c9b80..700064c4f 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,176 @@ -organization := "org.scala-sbt" +import com.typesafe.sbt.packager.Keys._ +import com.typesafe.sbt.SbtNativePackager._ +import util.control.Exception.catching -name := "sbt-launcher-packaging" +val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url") +val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") +val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") +val moduleID = (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) } -version := "0.1.0" +val bintrayLinuxPattern = "[module]/[revision]/[module]-[revision].[ext]" +val bintrayGenericPattern = "[module]/[revision]/[module]/[revision]/[module]-[revision].[ext]" +val bintrayDebianUrl = "https://api.bintray.com/content/sbt/debian/" +val bintrayRpmUrl = "https://api.bintray.com/content/sbt/rpm/" +val bintrayGenericPackagesUrl = "https://api.bintray.com/content/sbt/native-packages/" +val bintrayPublishAllStaged = TaskKey[Unit]("bintray-publish-all-staged", "Publish all staged artifacts on bintray.") -crossTarget <<= target +// This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. +val root = (project in file(".")). + settings( + sbtVersion <<= sbtVersion apply { v => + sys.props.getOrElse("sbt.build.version", sys.env.getOrElse("sbt.build.version", v)) + }, + organization := "org.scala-sbt", + name := "sbt-launcher-packaging", + version := "0.1.0", + crossTarget <<= target, + packagerSettings, + deploymentSettings, + mapGenericFilesToLinux, + mapGenericFilesToWindows, + publishToSettings, + sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion, + sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"), + sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) => + import dispatch.classic._ + if(!file.exists) { + // oddly, some places require us to create the file before writing... + IO.touch(file) + val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(file)) + try Http(url(uri) >>> writer) + finally writer.close() + } + // TODO - GPG Trust validation. + file + }, + // GENERAL LINUX PACKAGING STUFFS + maintainer := "Josh Suereth ", + packageSummary := "Simple Build Tool for Scala-driven builds", + packageDescription := """This script provides a native way to run the Simple Build Tool, + a build tool for Scala software, also called SBT.""", + // Here we remove the jar file and launch lib from the symlinks: + linuxPackageSymlinks <<= linuxPackageSymlinks map { links => + for { + link <- links + if !(link.destination endsWith "sbt-launch-lib.bash") + if !(link.destination endsWith "sbt-launch.jar") + } yield link + }, + // DEBIAN SPECIFIC + name in Debian := "sbt", + version in Debian <<= sbtVersion, + debianPackageDependencies in Debian ++= Seq("java6-runtime-headless", "bash (>= 2.05a-11)"), + debianPackageRecommends in Debian += "git", + linuxPackageMappings in Debian <+= (sourceDirectory) map { bd => + (packageMapping( + (bd / "debian/changelog") -> "/usr/share/doc/sbt/changelog.gz" + ) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs() + }, + + // RPM SPECIFIC + name in Rpm := "sbt", + version in Rpm <<= sbtVersion apply { sv => (sv split "[^\\d]" filterNot (_.isEmpty) mkString ".") }, + rpmRelease := "1", + rpmVendor := "typesafe", + rpmUrl := Some("http://github.com/paulp/sbt-extras"), + rpmLicense := Some("BSD"), + rpmRequirements :=Seq("java","java-devel","jpackage-utils"), + rpmProvides := Seq("sbt"), + + // WINDOWS SPECIFIC + name in Windows := "sbt", + version in Windows <<= (sbtVersion) apply { sv => + (sv split "[^\\d]" filterNot (_.isEmpty)) match { + case Array(major,minor,bugfix, _*) => Seq(major,minor,bugfix, "1") mkString "." + case Array(major,minor) => Seq(major,minor,"0","1") mkString "." + case Array(major) => Seq(major,"0","0","1") mkString "." + } + }, + maintainer in Windows := "Typesafe, Inc.", + packageSummary in Windows := "Simple Build Tool", + packageDescription in Windows := "THE reactive build tool.", + wixProductId := "ce07be71-510d-414a-92d4-dff47631848a", + wixProductUpgradeId := "4552fb0e-e257-4dbd-9ecb-dba9dbacf424", + javacOptions := Seq("-source", "1.5", "-target", "1.5"), + + // Universal ZIP download install. + name in Universal := "sbt", + version in Universal <<= sbtVersion, + mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" }, + + // Misccelaneous publishing stuff... + projectID in Debian <<= moduleID, + projectID in Windows <<= moduleID, + projectID in Rpm <<= moduleID, + projectID in Universal <<= moduleID + ) + +def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching(classOf[Exception]) opt (i.toInt))) match { + case Array(0, 11, 3, _*) => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.11.3-2/sbt-launch.jar" + case Array(0, 11, x, _*) if x >= 3 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" + case Array(0, y, _*) if y >= 12 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" + case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" +} +/** Returns an id, url and pattern for publishing based on the given configuration. */ +def getPublishSettings(config: Configuration): (String, String, String) = + config.name match { + case Debian.name => ("debian", bintrayDebianUrl, bintrayLinuxPattern) + case Rpm.name => ("rpm", bintrayRpmUrl, bintrayLinuxPattern) + case _ => ("native-packages", bintrayGenericPackagesUrl, bintrayGenericPattern) + } + +def makePublishTo(id: String, url: String, pattern: String): Setting[_] = { + publishTo := { + val resolver = Resolver.url(id, new URL(url))(Patterns(pattern)) + Some(resolver) + } +} + +def makePublishToForConfig(config: Configuration) = { + val (id, url, pattern) = getPublishSettings(config) + + + // Add the publish to and ensure global resolvers has the resolver we just configured. + inConfig(config)(Seq( + makePublishTo(id, url, pattern), + bintrayPublishAllStaged <<= (credentials, version) map { (creds, version) => + publishContent(id, version, creds) + }, + // TODO - This is a little funky... + publish <<= (publish, credentials, version) apply { (publish, creds, version) => + for { + pub <- publish + creds <- creds + } yield publishContent(id, version, creds) + } + )) ++ Seq( + resolvers <++= (publishTo in config) apply (_.toSeq) + ) +} + +def publishToSettings: Seq[Setting[_]] = + Seq[Configuration](Debian, Universal, Windows, Rpm) flatMap makePublishToForConfig + +def bintrayCreds(creds: Seq[sbt.Credentials]): (String, String) = { + val matching = + for { + c <- creds + if c.isInstanceOf[sbt.DirectCredentials] + val cred = c.asInstanceOf[sbt.DirectCredentials] + if cred.host == "api.bintray.com" + } yield cred.userName -> cred.passwd + + matching.headOption getOrElse sys.error("Unable to find bintray credentials (api.bintray.com)") +} + +def publishContent(repo: String, version: String, creds: Seq[sbt.Credentials]): Unit = { + val subject = "sbt" // Sbt org + val pkg = "sbt" // Sbt package + val uri = s"https://bintray.com/api/v1/content/$subject/$repo/$pkg/$version/publish" + + val (u,p) = bintrayCreds(creds) + import dispatch.classic._ + // TODO - Log the output + Http(url(uri).POST.as(u,p).>|) +} diff --git a/project/build.properties b/project/build.properties index 748703f77..817bc38df 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.7 +sbt.version=0.13.9 diff --git a/project/build.scala b/project/build.scala deleted file mode 100644 index 4d185d0fe..000000000 --- a/project/build.scala +++ /dev/null @@ -1,11 +0,0 @@ -import sbt._ -import Keys._ - -object SbtLauncherPackage extends Build { - // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. - val root = Project("sbt-packaging", file(".")) settings(Packaging.settings:_*) settings( - sbtVersion <<= sbtVersion apply { v => - sys.props.getOrElse("sbt.build.version", sys.env.getOrElse("sbt.build.version", v)) - } - ) -} diff --git a/project/packaging.scala b/project/packaging.scala deleted file mode 100644 index 194a69cbc..000000000 --- a/project/packaging.scala +++ /dev/null @@ -1,173 +0,0 @@ -import sbt._ -import com.typesafe.sbt.packager.Keys._ -import sbt.Keys._ -import com.typesafe.sbt.SbtNativePackager._ - -object Packaging { - - val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url") - val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") - val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") - val moduleID = (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) } - - val bintrayLinuxPattern = "[module]/[revision]/[module]-[revision].[ext]" - val bintrayGenericPattern = "[module]/[revision]/[module]/[revision]/[module]-[revision].[ext]" - val bintrayDebianUrl = "https://api.bintray.com/content/sbt/debian/" - val bintrayRpmUrl = "https://api.bintray.com/content/sbt/rpm/" - val bintrayGenericPackagesUrl = "https://api.bintray.com/content/sbt/native-packages/" - val bintrayPublishAllStaged = TaskKey[Unit]("bintray-publish-all-staged", "Publish all staged artifacts on bintray.") - - // Note: The legacy api. - //val genericNativeReleasesUrl = "http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages" - //val genericNativeReleasesPattern = "[organisation]/[module]/[revision]/[module].[ext]" - - import util.control.Exception.catching - - def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching(classOf[Exception]) opt (i.toInt))) match { - case Array(0, 11, 3, _*) => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.11.3-2/sbt-launch.jar" - case Array(0, 11, x, _*) if x >= 3 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" - case Array(0, y, _*) if y >= 12 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" - case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" - } - /** Returns an id, url and pattern for publishing based on the given configuration. */ - def getPublishSettings(config: Configuration): (String, String, String) = - config.name match { - case Debian.name => ("debian", bintrayDebianUrl, bintrayLinuxPattern) - case Rpm.name => ("rpm", bintrayRpmUrl, bintrayLinuxPattern) - case _ => ("native-packages", bintrayGenericPackagesUrl, bintrayGenericPattern) - } - - def makePublishTo(id: String, url: String, pattern: String): Setting[_] = { - publishTo := { - val resolver = Resolver.url(id, new URL(url))(Patterns(pattern)) - Some(resolver) - } - } - - def makePublishToForConfig(config: Configuration) = { - val (id, url, pattern) = getPublishSettings(config) - - - // Add the publish to and ensure global resolvers has the resolver we just configured. - inConfig(config)(Seq( - makePublishTo(id, url, pattern), - bintrayPublishAllStaged <<= (credentials, version) map { (creds, version) => - publishContent(id, version, creds) - }, - // TODO - This is a little funky... - publish <<= (publish, credentials, version) apply { (publish, creds, version) => - for { - pub <- publish - creds <- creds - } yield publishContent(id, version, creds) - } - )) ++ Seq( - resolvers <++= (publishTo in config) apply (_.toSeq) - ) - } - - def publishToSettings: Seq[Setting[_]] = - Seq[Configuration](Debian, Universal, Windows, Rpm) flatMap makePublishToForConfig - - def bintrayCreds(creds: Seq[sbt.Credentials]): (String, String) = { - val matching = - for { - c <- creds - if c.isInstanceOf[sbt.DirectCredentials] - val cred = c.asInstanceOf[sbt.DirectCredentials] - if cred.host == "api.bintray.com" - } yield cred.userName -> cred.passwd - - matching.headOption getOrElse sys.error("Unable to find bintray credentials (api.bintray.com)") - } - - def publishContent(repo: String, version: String, creds: Seq[sbt.Credentials]): Unit = { - val subject = "sbt" // Sbt org - val pkg = "sbt" // Sbt package - val uri = s"https://bintray.com/api/v1/content/$subject/$repo/$pkg/$version/publish" - - val (u,p) = bintrayCreds(creds) - import dispatch.classic._ - // TODO - Log the output - Http(url(uri).POST.as(u,p).>|) - } - - - val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWindows ++ publishToSettings ++ Seq( - sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion, - sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"), - sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) => - import dispatch.classic._ - if(!file.exists) { - // oddly, some places require us to create the file before writing... - IO.touch(file) - val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(file)) - try Http(url(uri) >>> writer) - finally writer.close() - } - // TODO - GPG Trust validation. - file - }, - // GENERAL LINUX PACKAGING STUFFS - maintainer := "Josh Suereth ", - packageSummary := "Simple Build Tool for Scala-driven builds", - packageDescription := """This script provides a native way to run the Simple Build Tool, - a build tool for Scala software, also called SBT.""", - // Here we remove the jar file and launch lib from the symlinks: - linuxPackageSymlinks <<= linuxPackageSymlinks map { links => - for { - link <- links - if !(link.destination endsWith "sbt-launch-lib.bash") - if !(link.destination endsWith "sbt-launch.jar") - } yield link - }, - // DEBIAN SPECIFIC - name in Debian := "sbt", - version in Debian <<= sbtVersion, - debianPackageDependencies in Debian ++= Seq("java6-runtime-headless", "bash (>= 2.05a-11)"), - debianPackageRecommends in Debian += "git", - linuxPackageMappings in Debian <+= (sourceDirectory) map { bd => - (packageMapping( - (bd / "debian/changelog") -> "/usr/share/doc/sbt/changelog.gz" - ) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs() - }, - - // RPM SPECIFIC - name in Rpm := "sbt", - version in Rpm <<= sbtVersion apply { sv => (sv split "[^\\d]" filterNot (_.isEmpty) mkString ".") }, - rpmRelease := "1", - rpmVendor := "typesafe", - rpmUrl := Some("http://github.com/paulp/sbt-extras"), - rpmLicense := Some("BSD"), - rpmRequirements :=Seq("java","java-devel","jpackage-utils"), - rpmProvides := Seq("sbt"), - - - // WINDOWS SPECIFIC - name in Windows := "sbt", - version in Windows <<= (sbtVersion) apply { sv => - (sv split "[^\\d]" filterNot (_.isEmpty)) match { - case Array(major,minor,bugfix, _*) => Seq(major,minor,bugfix, "1") mkString "." - case Array(major,minor) => Seq(major,minor,"0","1") mkString "." - case Array(major) => Seq(major,"0","0","1") mkString "." - } - }, - maintainer in Windows := "Typesafe, Inc.", - packageSummary in Windows := "Simple Build Tool", - packageDescription in Windows := "THE reactive build tool.", - wixProductId := "ce07be71-510d-414a-92d4-dff47631848a", - wixProductUpgradeId := "4552fb0e-e257-4dbd-9ecb-dba9dbacf424", - javacOptions := Seq("-source", "1.5", "-target", "1.5"), - - // Universal ZIP download install. - name in Universal := "sbt", - version in Universal <<= sbtVersion, - mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" }, - - // Misccelaneous publishing stuff... - projectID in Debian <<= moduleID, - projectID in Windows <<= moduleID, - projectID in Rpm <<= moduleID, - projectID in Universal <<= moduleID - ) -} From b55237f1ad036572033e4964669d1107ad5f75d1 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 11 Aug 2015 01:30:16 -0400 Subject: [PATCH 198/483] Refactor to use bintray-sbt --- build.sbt | 70 +++++++++++++++++---------------------------- project/bintray.sbt | 2 ++ 2 files changed, 28 insertions(+), 44 deletions(-) create mode 100644 project/bintray.sbt diff --git a/build.sbt b/build.sbt index 700064c4f..657a11d59 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,8 @@ import com.typesafe.sbt.packager.Keys._ import com.typesafe.sbt.SbtNativePackager._ import util.control.Exception.catching +import _root_.bintray.InternalBintrayKeys._ +import _root_.bintray.{BintrayRepo, Bintray} val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url") val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") @@ -12,7 +14,7 @@ val bintrayGenericPattern = "[module]/[revision]/[module]/[revision]/[module]-[r val bintrayDebianUrl = "https://api.bintray.com/content/sbt/debian/" val bintrayRpmUrl = "https://api.bintray.com/content/sbt/rpm/" val bintrayGenericPackagesUrl = "https://api.bintray.com/content/sbt/native-packages/" -val bintrayPublishAllStaged = TaskKey[Unit]("bintray-publish-all-staged", "Publish all staged artifacts on bintray.") +val bintrayReleaseAllStaged = TaskKey[Unit]("bintray-release-all-staged", "Release all staged artifacts on bintray.") // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. val root = (project in file(".")). @@ -111,13 +113,6 @@ def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching( case Array(0, y, _*) if y >= 12 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" } -/** Returns an id, url and pattern for publishing based on the given configuration. */ -def getPublishSettings(config: Configuration): (String, String, String) = - config.name match { - case Debian.name => ("debian", bintrayDebianUrl, bintrayLinuxPattern) - case Rpm.name => ("rpm", bintrayRpmUrl, bintrayLinuxPattern) - case _ => ("native-packages", bintrayGenericPackagesUrl, bintrayGenericPattern) - } def makePublishTo(id: String, url: String, pattern: String): Setting[_] = { publishTo := { @@ -127,22 +122,29 @@ def makePublishTo(id: String, url: String, pattern: String): Setting[_] = { } def makePublishToForConfig(config: Configuration) = { - val (id, url, pattern) = getPublishSettings(config) - - + val (id, url, pattern) = + config.name match { + case Debian.name => ("debian", bintrayDebianUrl, bintrayLinuxPattern) + case Rpm.name => ("rpm", bintrayRpmUrl, bintrayLinuxPattern) + case _ => ("native-packages", bintrayGenericPackagesUrl, bintrayGenericPattern) + } // Add the publish to and ensure global resolvers has the resolver we just configured. inConfig(config)(Seq( - makePublishTo(id, url, pattern), - bintrayPublishAllStaged <<= (credentials, version) map { (creds, version) => - publishContent(id, version, creds) - }, - // TODO - This is a little funky... - publish <<= (publish, credentials, version) apply { (publish, creds, version) => - for { - pub <- publish - creds <- creds - } yield publishContent(id, version, creds) - } + bintrayOrganization := Some("sbt"), + bintrayRepository := id, + bintrayRepo := Bintray.cachedRepo(bintrayEnsureCredentials.value, + bintrayOrganization.value, + bintrayRepository.value), + bintrayPackage := "sbt", + makePublishTo(id, url, pattern), + bintrayReleaseAllStaged := bintrayRelease(bintrayRepo.value, bintrayPackage.value, version.value, sLog.value) + // Uncomment to release right after publishing + // publish <<= (publish, bintrayRepo, bintrayPackage, version, sLog) apply { (publish, bintrayRepo, bintrayPackage, version, sLog) => + // for { + // pub <- publish + // repo <- bintrayRepo + // } yield bintrayRelease(repo, bintrayPackage, version, sLog) + // } )) ++ Seq( resolvers <++= (publishTo in config) apply (_.toSeq) ) @@ -151,26 +153,6 @@ def makePublishToForConfig(config: Configuration) = { def publishToSettings: Seq[Setting[_]] = Seq[Configuration](Debian, Universal, Windows, Rpm) flatMap makePublishToForConfig -def bintrayCreds(creds: Seq[sbt.Credentials]): (String, String) = { - val matching = - for { - c <- creds - if c.isInstanceOf[sbt.DirectCredentials] - val cred = c.asInstanceOf[sbt.DirectCredentials] - if cred.host == "api.bintray.com" - } yield cred.userName -> cred.passwd - - matching.headOption getOrElse sys.error("Unable to find bintray credentials (api.bintray.com)") -} - -def publishContent(repo: String, version: String, creds: Seq[sbt.Credentials]): Unit = { - val subject = "sbt" // Sbt org - val pkg = "sbt" // Sbt package - val uri = s"https://bintray.com/api/v1/content/$subject/$repo/$pkg/$version/publish" - - val (u,p) = bintrayCreds(creds) - import dispatch.classic._ - // TODO - Log the output - Http(url(uri).POST.as(u,p).>|) -} +def bintrayRelease(repo: BintrayRepo, pkg: String, version: String, log: Logger): Unit = + repo.release(pkg, version, log) diff --git a/project/bintray.sbt b/project/bintray.sbt new file mode 100644 index 000000000..b2ace147a --- /dev/null +++ b/project/bintray.sbt @@ -0,0 +1,2 @@ +addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0") + From 0e929991251176beeb4b6800fdf903871bc1f6af Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 11 Aug 2015 01:34:13 -0400 Subject: [PATCH 199/483] Update description --- build.sbt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 657a11d59..ba77b8769 100644 --- a/build.sbt +++ b/build.sbt @@ -46,10 +46,10 @@ val root = (project in file(".")). file }, // GENERAL LINUX PACKAGING STUFFS - maintainer := "Josh Suereth ", - packageSummary := "Simple Build Tool for Scala-driven builds", - packageDescription := """This script provides a native way to run the Simple Build Tool, - a build tool for Scala software, also called SBT.""", + maintainer := "Eugene Yokota ", + packageSummary := "sbt, the interactive build tool", + packageDescription := """This script provides a native way to run sbt, + a build tool for Scala and more.""", // Here we remove the jar file and launch lib from the symlinks: linuxPackageSymlinks <<= linuxPackageSymlinks map { links => for { @@ -58,7 +58,7 @@ val root = (project in file(".")). if !(link.destination endsWith "sbt-launch.jar") } yield link }, - // DEBIAN SPECIFIC + // DEBIAN SPECIFIC name in Debian := "sbt", version in Debian <<= sbtVersion, debianPackageDependencies in Debian ++= Seq("java6-runtime-headless", "bash (>= 2.05a-11)"), @@ -74,7 +74,7 @@ val root = (project in file(".")). version in Rpm <<= sbtVersion apply { sv => (sv split "[^\\d]" filterNot (_.isEmpty) mkString ".") }, rpmRelease := "1", rpmVendor := "typesafe", - rpmUrl := Some("http://github.com/paulp/sbt-extras"), + rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"), rpmLicense := Some("BSD"), rpmRequirements :=Seq("java","java-devel","jpackage-utils"), rpmProvides := Seq("sbt"), @@ -89,8 +89,8 @@ val root = (project in file(".")). } }, maintainer in Windows := "Typesafe, Inc.", - packageSummary in Windows := "Simple Build Tool", - packageDescription in Windows := "THE reactive build tool.", + packageSummary in Windows := "sbt", + packageDescription in Windows := "The interactive build tool.", wixProductId := "ce07be71-510d-414a-92d4-dff47631848a", wixProductUpgradeId := "4552fb0e-e257-4dbd-9ecb-dba9dbacf424", javacOptions := Seq("-source", "1.5", "-target", "1.5"), From 597c309e6529a0f16931bd9b8f2975df68095721 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 11 Aug 2015 01:40:27 -0400 Subject: [PATCH 200/483] Adds CONTRIBUTING.md --- CONTRIBUTING.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..ca4918545 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,12 @@ +Steps to publish +================ + +``` +> universal:publish +> debian:publish +> rpm:publish +> universal:bintrayReleaseAllStaged +> debian:releaseAllStaged +> rpm:releaseAllStaged +``` + From 92a06fc5da81ce05a28ee1239e3a99752e067218 Mon Sep 17 00:00:00 2001 From: Hugo Freire Date: Sun, 6 Dec 2015 12:56:51 +0100 Subject: [PATCH 201/483] Allow to run sbt interactive mode in git for windows bash --- src/universal/bin/sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 48d1ff90f..632d45fd5 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -37,6 +37,7 @@ is_cygwin() { local os=$(uname -s) case "$os" in CYGWIN*) return 0 ;; + MINGW*) return 0 ;; *) return 1 ;; esac } From dc4a56c2e017a0fed53609d6cff35a4b9f593b9f Mon Sep 17 00:00:00 2001 From: Darren Bishop Date: Tue, 12 Jan 2016 14:50:37 +0000 Subject: [PATCH 202/483] Updated the MS Windows SBT launcher script to get the same/similar behaviour for -jvm-debug as implemented in the *nix shell script launcher. http://stackoverflow.com/questions/4150776/debugging-scala-code-with-simple-build-tool-sbt-and-intellij/28236830#28236830 --- src/universal/bin/sbt.bat | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 0b707814b..b83ba8405 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -37,11 +37,33 @@ rem We use the value of the JAVA_OPTS environment variable if defined, rather th set _JAVA_OPTS=%JAVA_OPTS% if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% +FOR %%a IN (%*) DO ( + if "%%a" == "-jvm-debug" ( + set JVM_DEBUG=true + set /a JVM_DEBUG_PORT=5005 2>nul >nul + ) else if "!JVM_DEBUG!" == "true" ( + set /a JVM_DEBUG_PORT=%%a 2>nul >nul + if not "%%a" == "!JVM_DEBUG_PORT!" ( + set SBT_ARGS=!SBT_ARGS! %%a + ) + ) else ( + set SBT_ARGS=!SBT_ARGS! %%a + ) +) + +if defined JVM_DEBUG_PORT ( + set _JAVA_OPTS=!_JAVA_OPTS! -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=!JVM_DEBUG_PORT! +) + +call :run %SBT_ARGS% + +if ERRORLEVEL 1 goto error +goto end + :run "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%sbt-launch.jar" xsbt.boot.Boot %* -if ERRORLEVEL 1 goto error -goto end +goto :eof :error @endlocal From 40167af167a9005118c91365ad3ecc806a1a0751 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 21 Jan 2016 23:26:25 -0500 Subject: [PATCH 203/483] Handle SBT_OPTS Fixes sbt/sbt-launcher-package#99 formerly known as sbt/sbt#2194. get_mem_opts() is a bash function that generates memory related options. This change makes it return `""` the SBT_OPTS variable contains memory-related options already. --- src/universal/bin/sbt-launch-lib.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index d57f0e951..1210fa9f3 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -76,7 +76,9 @@ get_mem_opts () { # if we detect any of these settings in ${JAVA_OPTS} we need to NOT output our settings. # The reason is the Xms/Xmx, if they don't line up, cause errors. if [[ "${JAVA_OPTS}" == *-Xmx* ]] || [[ "${JAVA_OPTS}" == *-Xms* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxPermSize* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${JAVA_OPTS}" == *-XX:ReservedCodeCacheSize* ]]; then - echo "" + echo "" + elif [[ "${SBT_OPTS}" == *-Xmx* ]] || [[ "${SBT_OPTS}" == *-Xms* ]] || [[ "${SBT_OPTS}" == *-XX:MaxPermSize* ]] || [[ "${SBT_OPTS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${SBT_OPTS}" == *-XX:ReservedCodeCacheSize* ]]; then + echo "" else # a ham-fisted attempt to move some memory settings in concert # so they need not be messed around with individually. From cd57c593725498ad558f986d270df85af0eaaf8d Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 21 Jan 2016 23:43:17 -0500 Subject: [PATCH 204/483] Workaround for travis-ci/travis-ci#5227 --- .travis.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0f949c800..aa8cfbbd0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,5 +9,9 @@ notifications: email: - qbranch@typesafe.com before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq rpm + - cat /etc/hosts # optionally check the content *before* + - sudo hostname "$(hostname | cut -c1-63)" + - sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts + - cat /etc/hosts # optionally check the content *after* + - sudo apt-get update -qq + - sudo apt-get install -qq rpm From 0d9806b9ffacc083e9c36b657b69b9d97fde8f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mihai=20Capot=C4=83?= Date: Wed, 17 Feb 2016 11:26:13 -0800 Subject: [PATCH 205/483] Check memory options in JAVA_TOOL_OPTIONS JAVA_TOOL_OPTIONS is used by the JVM [1] so it must also be checked for memory options that conflict with the ones set in get_mem_opts. [1] https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/envvars002.html --- src/universal/bin/sbt-launch-lib.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 1210fa9f3..ad0dc1ef5 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -73,10 +73,12 @@ addDebugger () { } get_mem_opts () { - # if we detect any of these settings in ${JAVA_OPTS} we need to NOT output our settings. + # if we detect any of these settings in ${JAVA_OPTS} or ${JAVA_TOOL_OPTIONS} we need to NOT output our settings. # The reason is the Xms/Xmx, if they don't line up, cause errors. if [[ "${JAVA_OPTS}" == *-Xmx* ]] || [[ "${JAVA_OPTS}" == *-Xms* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxPermSize* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${JAVA_OPTS}" == *-XX:ReservedCodeCacheSize* ]]; then echo "" + elif [[ "${JAVA_TOOL_OPTIONS}" == *-Xmx* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-Xms* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxPermSize* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-XX:ReservedCodeCacheSize* ]]; then + echo "" elif [[ "${SBT_OPTS}" == *-Xmx* ]] || [[ "${SBT_OPTS}" == *-Xms* ]] || [[ "${SBT_OPTS}" == *-XX:MaxPermSize* ]] || [[ "${SBT_OPTS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${SBT_OPTS}" == *-XX:ReservedCodeCacheSize* ]]; then echo "" else From 843a60734b021638a12b927c2444b5dccf20d75f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 19 Feb 2016 17:46:05 -0500 Subject: [PATCH 206/483] Fixes #104. Allow individual memory options to be controlled When a `-J` option is passed in such as `-J-XX:MaxPermSize=1001M`, it will override only that option. --- src/universal/bin/sbt-launch-lib.bash | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index ad0dc1ef5..62889cd4a 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -91,7 +91,12 @@ get_mem_opts () { local class_metadata_size=$(( $codecache * 2 )) local class_metadata_opt=$([[ "$java_version" < "1.8" ]] && echo "MaxPermSize" || echo "MaxMetaspaceSize") - echo "-Xms${mem}m -Xmx${mem}m -XX:ReservedCodeCacheSize=${codecache}m -XX:${class_metadata_opt}=${class_metadata_size}m" + local arg_xms=$([[ "${java_args[@]}" == *-Xms* ]] && echo "" || echo "-Xms${mem}m") + local arg_xmx=$([[ "${java_args[@]}" == *-Xmx* ]] && echo "" || echo "-Xmx${mem}m") + local arg_rccs=$([[ "${java_args[@]}" == *-XX:ReservedCodeCacheSize* ]] && echo "" || echo "-XX:ReservedCodeCacheSize=${codecache}m") + local arg_meta=$([[ "${java_args[@]}" == *-XX:${class_metadata_opt}* ]] && echo "" || echo "-XX:${class_metadata_opt}=${class_metadata_size}m") + + echo "${arg_xms} ${arg_xmx} ${arg_rccs} ${arg_meta}" fi } @@ -187,12 +192,12 @@ run() { addJava "-Djline.terminal=jline.UnixTerminal" addJava "-Dsbt.cygwin=true" fi - + # run sbt execRunner "$java_cmd" \ - ${SBT_OPTS:-$default_sbt_opts} \ $(get_mem_opts $sbt_mem) \ - ${JAVA_OPTS} \ + ${JAVA_OPTS} \ + ${SBT_OPTS:-$default_sbt_opts} \ ${java_args[@]} \ -jar "$sbt_jar" \ "${sbt_commands[@]}" \ From 6ed481346b395df70f902814a5e1795598e40d74 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 22 Feb 2016 01:13:57 -0500 Subject: [PATCH 207/483] 0.13.11 --- project/build.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 817bc38df..75836b233 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1,2 @@ -sbt.version=0.13.9 +sbt.version=0.13.11 + From ca0a42b349db2a31da3bab5c9287d9b199da9a99 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 18 Dec 2015 00:01:35 -0500 Subject: [PATCH 208/483] Generate product upgrade ID. Fixes sbt/sbt#2181 --- build.sbt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index ba77b8769..aff74af12 100644 --- a/build.sbt +++ b/build.sbt @@ -15,6 +15,7 @@ val bintrayDebianUrl = "https://api.bintray.com/content/sbt/debian/" val bintrayRpmUrl = "https://api.bintray.com/content/sbt/rpm/" val bintrayGenericPackagesUrl = "https://api.bintray.com/content/sbt/native-packages/" val bintrayReleaseAllStaged = TaskKey[Unit]("bintray-release-all-staged", "Release all staged artifacts on bintray.") +val windowsBuildId = settingKey[Int]("build id for Windows installer") // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. val root = (project in file(".")). @@ -81,18 +82,19 @@ val root = (project in file(".")). // WINDOWS SPECIFIC name in Windows := "sbt", - version in Windows <<= (sbtVersion) apply { sv => + windowsBuildId := 1, + version in Windows <<= (sbtVersion, windowsBuildId) apply { (sv, bid) => (sv split "[^\\d]" filterNot (_.isEmpty)) match { - case Array(major,minor,bugfix, _*) => Seq(major,minor,bugfix, "1") mkString "." - case Array(major,minor) => Seq(major,minor,"0","1") mkString "." - case Array(major) => Seq(major,"0","0","1") mkString "." + case Array(major,minor,bugfix, _*) => Seq(major, minor, bugfix, bid.toString) mkString "." + case Array(major,minor) => Seq(major, minor, "0", bid.toString) mkString "." + case Array(major) => Seq(major, "0", "0", bid.toString) mkString "." } }, maintainer in Windows := "Typesafe, Inc.", - packageSummary in Windows := "sbt", + packageSummary in Windows := "sbt " + (version in Windows).value, packageDescription in Windows := "The interactive build tool.", wixProductId := "ce07be71-510d-414a-92d4-dff47631848a", - wixProductUpgradeId := "4552fb0e-e257-4dbd-9ecb-dba9dbacf424", + wixProductUpgradeId := Hash.toHex(Hash((version in Windows).value)).take(32), javacOptions := Seq("-source", "1.5", "-target", "1.5"), // Universal ZIP download install. From 0e19b83e2e693a61880d43a48a218e8eec652498 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 22 Feb 2016 18:14:42 -0500 Subject: [PATCH 209/483] include version in Windws into the projectID --- build.sbt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index aff74af12..5362bc778 100644 --- a/build.sbt +++ b/build.sbt @@ -101,10 +101,13 @@ val root = (project in file(".")). name in Universal := "sbt", version in Universal <<= sbtVersion, mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" }, - + // Misccelaneous publishing stuff... projectID in Debian <<= moduleID, - projectID in Windows <<= moduleID, + projectID in Windows := { + val m = moduleID.value + m.copy(revision = (version in Windows).value) + }, projectID in Rpm <<= moduleID, projectID in Universal <<= moduleID ) From 289acc3b82b415f670594065024d2e819197d522 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 9 May 2016 00:25:16 -0400 Subject: [PATCH 210/483] Preparing cross publishing --- CONTRIBUTING.md | 1 + build.sbt | 46 ++++++++++++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca4918545..fed9ef6e0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,7 @@ Steps to publish ================ ``` +$ sbt -Dsbt.build.version=1.0.0-M1 > universal:publish > debian:publish > rpm:publish diff --git a/build.sbt b/build.sbt index 5362bc778..39514c050 100644 --- a/build.sbt +++ b/build.sbt @@ -4,15 +4,21 @@ import util.control.Exception.catching import _root_.bintray.InternalBintrayKeys._ import _root_.bintray.{BintrayRepo, Bintray} +lazy val sbtVersionToRelease = sys.props.getOrElse("sbt.build.version", sys.env.getOrElse("sbt.build.version", { + sys.error("-Dsbt.build.version must be set") + })) +lazy val isExperimental = (sbtVersionToRelease contains "RC") || (sbtVersionToRelease contains "M") val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url") val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") -val moduleID = (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) } +val moduleID = (organization) apply { (o) => ModuleID(o, "sbt", sbtVersionToRelease) } val bintrayLinuxPattern = "[module]/[revision]/[module]-[revision].[ext]" val bintrayGenericPattern = "[module]/[revision]/[module]/[revision]/[module]-[revision].[ext]" val bintrayDebianUrl = "https://api.bintray.com/content/sbt/debian/" +val bintrayDebianExperimentalUrl = "https://api.bintray.com/content/sbt/debian-experimental/" val bintrayRpmUrl = "https://api.bintray.com/content/sbt/rpm/" +val bintrayRpmExperimentalUrl = "https://api.bintray.com/content/sbt/rpm-experimental/" val bintrayGenericPackagesUrl = "https://api.bintray.com/content/sbt/native-packages/" val bintrayReleaseAllStaged = TaskKey[Unit]("bintray-release-all-staged", "Release all staged artifacts on bintray.") val windowsBuildId = settingKey[Int]("build id for Windows installer") @@ -20,9 +26,6 @@ val windowsBuildId = settingKey[Int]("build id for Windows installer") // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. val root = (project in file(".")). settings( - sbtVersion <<= sbtVersion apply { v => - sys.props.getOrElse("sbt.build.version", sys.env.getOrElse("sbt.build.version", v)) - }, organization := "org.scala-sbt", name := "sbt-launcher-packaging", version := "0.1.0", @@ -32,7 +35,7 @@ val root = (project in file(".")). mapGenericFilesToLinux, mapGenericFilesToWindows, publishToSettings, - sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion, + sbtLaunchJarUrl := downloadUrlForVersion(sbtVersionToRelease), sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"), sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) => import dispatch.classic._ @@ -53,7 +56,7 @@ val root = (project in file(".")). a build tool for Scala and more.""", // Here we remove the jar file and launch lib from the symlinks: linuxPackageSymlinks <<= linuxPackageSymlinks map { links => - for { + for { link <- links if !(link.destination endsWith "sbt-launch-lib.bash") if !(link.destination endsWith "sbt-launch.jar") @@ -61,7 +64,7 @@ val root = (project in file(".")). }, // DEBIAN SPECIFIC name in Debian := "sbt", - version in Debian <<= sbtVersion, + version in Debian := sbtVersionToRelease, debianPackageDependencies in Debian ++= Seq("java6-runtime-headless", "bash (>= 2.05a-11)"), debianPackageRecommends in Debian += "git", linuxPackageMappings in Debian <+= (sourceDirectory) map { bd => @@ -69,28 +72,35 @@ val root = (project in file(".")). (bd / "debian/changelog") -> "/usr/share/doc/sbt/changelog.gz" ) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs() }, - + // RPM SPECIFIC name in Rpm := "sbt", - version in Rpm <<= sbtVersion apply { sv => (sv split "[^\\d]" filterNot (_.isEmpty) mkString ".") }, + version in Rpm := { + val stable = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".") + if (isExperimental) ((sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty)).toList match { + case List(a, b, c, d) => List(0, 99, c, d).mkString(".") + }) + else stable + }, rpmRelease := "1", rpmVendor := "typesafe", rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"), rpmLicense := Some("BSD"), rpmRequirements :=Seq("java","java-devel","jpackage-utils"), rpmProvides := Seq("sbt"), - + // WINDOWS SPECIFIC name in Windows := "sbt", windowsBuildId := 1, - version in Windows <<= (sbtVersion, windowsBuildId) apply { (sv, bid) => + version in Windows <<= (windowsBuildId) apply { (bid) => + val sv = sbtVersionToRelease (sv split "[^\\d]" filterNot (_.isEmpty)) match { case Array(major,minor,bugfix, _*) => Seq(major, minor, bugfix, bid.toString) mkString "." case Array(major,minor) => Seq(major, minor, "0", bid.toString) mkString "." case Array(major) => Seq(major, "0", "0", bid.toString) mkString "." } }, - maintainer in Windows := "Typesafe, Inc.", + maintainer in Windows := "Lightbend, Inc.", packageSummary in Windows := "sbt " + (version in Windows).value, packageDescription in Windows := "The interactive build tool.", wixProductId := "ce07be71-510d-414a-92d4-dff47631848a", @@ -99,7 +109,7 @@ val root = (project in file(".")). // Universal ZIP download install. name in Universal := "sbt", - version in Universal <<= sbtVersion, + version in Universal := sbtVersionToRelease, mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" }, // Misccelaneous publishing stuff... @@ -116,6 +126,7 @@ def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching( case Array(0, 11, 3, _*) => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.11.3-2/sbt-launch.jar" case Array(0, 11, x, _*) if x >= 3 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case Array(0, y, _*) if y >= 12 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" + case Array(1, _, _*) => "http://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" } @@ -127,11 +138,14 @@ def makePublishTo(id: String, url: String, pattern: String): Setting[_] = { } def makePublishToForConfig(config: Configuration) = { + val v = sbtVersionToRelease val (id, url, pattern) = config.name match { + case Debian.name if isExperimental => ("debian-experimental", bintrayDebianExperimentalUrl, bintrayLinuxPattern) case Debian.name => ("debian", bintrayDebianUrl, bintrayLinuxPattern) - case Rpm.name => ("rpm", bintrayRpmUrl, bintrayLinuxPattern) - case _ => ("native-packages", bintrayGenericPackagesUrl, bintrayGenericPattern) + case Rpm.name if isExperimental => ("rpm-experimental", bintrayRpmExperimentalUrl, bintrayLinuxPattern) + case Rpm.name => ("rpm", bintrayRpmUrl, bintrayLinuxPattern) + case _ => ("native-packages", bintrayGenericPackagesUrl, bintrayGenericPattern) } // Add the publish to and ensure global resolvers has the resolver we just configured. inConfig(config)(Seq( @@ -155,7 +169,7 @@ def makePublishToForConfig(config: Configuration) = { ) } -def publishToSettings: Seq[Setting[_]] = +def publishToSettings = Seq[Configuration](Debian, Universal, Windows, Rpm) flatMap makePublishToForConfig def bintrayRelease(repo: BintrayRepo, pkg: String, version: String, log: Logger): Unit = From 1705b58fdea66dfbf28b3b29c3da5253d078db38 Mon Sep 17 00:00:00 2001 From: Martijn Riemers Date: Sat, 28 May 2016 12:27:53 +0200 Subject: [PATCH 211/483] Corrected spelling mistake in sbt.bat --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index b83ba8405..cbb432638 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -1,6 +1,6 @@ @REM SBT launcher script @REM -@REM Envioronment: +@REM Environment: @REM JAVA_HOME - location of a JDK home dir (mandatory) @REM SBT_OPTS - JVM options (optional) @REM Configuration: From bea3fac13ed27f8a8e0733ff1e139fde5335e49b Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 22 Aug 2016 11:25:30 +0100 Subject: [PATCH 212/483] Misc email/URL updates --- .travis.yml | 2 +- README.md | 2 +- build.sbt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa8cfbbd0..5cc2bc743 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ jdk: - openjdk6 notifications: email: - - qbranch@typesafe.com + - sbt-dev-bot@googlegroups.com before_install: - cat /etc/hosts # optionally check the content *before* - sudo hostname "$(hostname | cut -c1-63)" diff --git a/README.md b/README.md index 8d55860a2..76a62c377 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ sbt: the launcher ================== -An alternative script for running [sbt](https://github.com/harrah/xsbt). +An alternative script for running [sbt](https://github.com/sbt/sbt). It works with sbt 0.7.x projects as well as 0.10+. If you're in an sbt project directory, the runner will figure out the versions of sbt and scala required by the project and download them if necessary. diff --git a/build.sbt b/build.sbt index 39514c050..71f16dd60 100644 --- a/build.sbt +++ b/build.sbt @@ -50,7 +50,7 @@ val root = (project in file(".")). file }, // GENERAL LINUX PACKAGING STUFFS - maintainer := "Eugene Yokota ", + maintainer := "Eugene Yokota ", packageSummary := "sbt, the interactive build tool", packageDescription := """This script provides a native way to run sbt, a build tool for Scala and more.""", From cffb8e044173210e1abd6a535aa04dd6e0926ea0 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 22 Aug 2016 11:33:23 +0100 Subject: [PATCH 213/483] Upgrade to sbt-native-packager 1.1.1. Fixes #76. The upgrade includes this fix https://github.com/sbt/sbt-native-packager/pull/169 --- build.sbt | 8 ++------ project/project/plugins.scala | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index 71f16dd60..9148dc361 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,4 @@ -import com.typesafe.sbt.packager.Keys._ -import com.typesafe.sbt.SbtNativePackager._ -import util.control.Exception.catching +import scala.util.control.Exception.catching import _root_.bintray.InternalBintrayKeys._ import _root_.bintray.{BintrayRepo, Bintray} @@ -25,15 +23,13 @@ val windowsBuildId = settingKey[Int]("build id for Windows installer") // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. val root = (project in file(".")). + enablePlugins(UniversalPlugin, LinuxPlugin, DebianPlugin, RpmPlugin, WindowsPlugin). settings( organization := "org.scala-sbt", name := "sbt-launcher-packaging", version := "0.1.0", crossTarget <<= target, - packagerSettings, deploymentSettings, - mapGenericFilesToLinux, - mapGenericFilesToWindows, publishToSettings, sbtLaunchJarUrl := downloadUrlForVersion(sbtVersionToRelease), sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"), diff --git a/project/project/plugins.scala b/project/project/plugins.scala index ddc50a0f4..44a311937 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -6,7 +6,7 @@ object PluginBuild extends Build { val root = Project("root", file(".")) settings( resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), - addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.3"), + addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.1"), libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.10" ) //dependsOn(nativePackager) From acc734e66960e82bd5ed50b9a8e2f71d897344db Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 22 Aug 2016 12:13:25 +0100 Subject: [PATCH 214/483] Switch Travis to Oracle JDK 7 .. required by the newer sbt-native-packager. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5cc2bc743..fce30a8be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ script: scala: - 2.10.3 jdk: - - openjdk6 + - oraclejdk7 notifications: email: - sbt-dev-bot@googlegroups.com From a1e1a570e0b7e45c8d8a215f10c84ef891581f85 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 22 Aug 2016 12:22:29 +0100 Subject: [PATCH 215/483] Add sbt.build.version from CONTRIBUTING to Travis config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fce30a8be..e8c434f57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: scala script: - - sbt ++$TRAVIS_SCALA_VERSION rpm:packageBin debian:packageBin universal:packageBin + - sbt -Dsbt.build.version=1.0.0-M1 ++$TRAVIS_SCALA_VERSION rpm:packageBin debian:packageBin universal:packageBin scala: - 2.10.3 jdk: From daed09b8cd2b16d725abb1be20731cae07ccb13c Mon Sep 17 00:00:00 2001 From: Sam Halliday Date: Wed, 24 Aug 2016 20:55:02 +0100 Subject: [PATCH 216/483] add support for .jvmopts and .java-version to Windows launcher --- src/universal/bin/sbt.bat | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index cbb432638..5cf5fc7b7 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -22,6 +22,21 @@ FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%FN%") DO ( set CFG_OPTS=!CFG_OPTS! !DO_NOT_REUSE_ME! ) +rem poor man's jenv (which is not available on Windows) +IF DEFINED JAVA_HOMES ( + IF EXIST .java-version FOR /F %%A IN (.java-version) DO ( + SET JAVA_HOME=%JAVA_HOMES%\%%A + SET JDK_HOME=%JAVA_HOMES%\%%A + ) +) +rem must set PATH or wrong javac is used for java projects +IF DEFINED JAVA_HOME SET PATH=%JAVA_HOME%\bin;%PATH% + +rem users can set JAVA_OPTS via .jvmopts (sbt-extras style) +IF EXIST .jvmopts FOR /F %%A IN (.jvmopts) DO ( + SET JAVA_OPTS=%%A !JAVA_OPTS! +) + rem We use the value of the JAVACMD environment variable if defined set _JAVACMD=%JAVACMD% From 45badebcee9f33f8792144d2bf6048c2d1313347 Mon Sep 17 00:00:00 2001 From: Sam Halliday Date: Wed, 24 Aug 2016 21:57:06 +0100 Subject: [PATCH 217/483] add support for .jvmopts to the bash launcher --- src/linux/usr/share/man/man1/sbt.1 | 9 +++++++-- src/universal/bin/sbt | 12 ++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/linux/usr/share/man/man1/sbt.1 b/src/linux/usr/share/man/man1/sbt.1 index 27772cbdc..6dc5d7211 100644 --- a/src/linux/usr/share/man/man1/sbt.1 +++ b/src/linux/usr/share/man/man1/sbt.1 @@ -72,10 +72,15 @@ add -X to sbt's scalacOptions (-S is stripped) .RS The user configuration file. .RE +.I ".jvmopts" +.RS +if this file exists in the current directory, its contents are appended +to the JAVA_OPTS. +.RE .I ".sbtopts" .RS -if this file exists in the current directory, it is prepended to the -runner args. +if this file exists in the current directory, its contents are prepended +to the runner args. .RE .I "/etc/sbt/sbtopts" .RS diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 632d45fd5..d622f98ef 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -94,9 +94,11 @@ Usage: $script_name [options] # jvm options and output control JAVA_OPTS environment variable, if unset uses "$java_opts" + .jvmopts if this file exists in the current directory, its contents + are appended to JAVA_OPTS SBT_OPTS environment variable, if unset uses "$default_sbt_opts" - .sbtopts if this file exists in the current directory, it is - prepended to the runner args + .sbtopts if this file exists in the current directory, its contents + are prepended to the runner args /etc/sbt/sbtopts if this file exists, it is prepended to the runner args -Dkey=val pass -Dkey=val directly to the java runtime -J-X pass option -X directly to the java runtime @@ -137,16 +139,14 @@ loadConfigFile() { done } -# TODO - Pull in config based on operating system... (MSYS + cygwin should pull in txt file). # Here we pull in the global settings configuration. [[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@" -# -- Windows behavior stub'd -# JAVA_OPTS=$(cat "$WDIR/sbtconfig.txt" | sed -e 's/\r//g' -e 's/^#.*$//g' | sed ':a;N;$!ba;s/\n/ /g') - # Pull in the project-level config file, if it exists. [[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@" +# Pull in the project-level java config, if it exists. +[[ -f ".jvmopts" ]] && export JAVA_OPTS="$JAVA_OPTS $(loadConfigFile .jvmopts)" run "$@" From d9da67979a6498cf8383dbe7fa2d76461b7009eb Mon Sep 17 00:00:00 2001 From: Sam Halliday Date: Thu, 25 Aug 2016 20:06:23 +0100 Subject: [PATCH 218/483] -java-home should set PATH for javac usage --- src/universal/bin/sbt-launch-lib.bash | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 62889cd4a..78732874b 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -128,7 +128,12 @@ process_args () { -sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;; -sbt-version) require_arg version "$1" "$2" && sbt_version="$2" && shift 2 ;; - -java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;; + -java-home) require_arg path "$1" "$2" && + java_cmd="$2/bin/java" && + export JAVA_HOME="$2" && + export JDK_HOME="$2" && + export PATH="$2/bin:$PATH" && + shift 2 ;; -D*) addJava "$1" && shift ;; -J*) addJava "${1:2}" && shift ;; From c4aa9052b578ff6aa8ca1b92f5c058bcca5c3d2a Mon Sep 17 00:00:00 2001 From: Miranda Kastemaa Date: Mon, 17 Oct 2016 15:51:53 +0300 Subject: [PATCH 219/483] Use more reliable shift loop for processing args --- src/universal/bin/sbt.bat | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 5cf5fc7b7..27dd66d63 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -52,20 +52,25 @@ rem We use the value of the JAVA_OPTS environment variable if defined, rather th set _JAVA_OPTS=%JAVA_OPTS% if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% -FOR %%a IN (%*) DO ( - if "%%a" == "-jvm-debug" ( - set JVM_DEBUG=true - set /a JVM_DEBUG_PORT=5005 2>nul >nul - ) else if "!JVM_DEBUG!" == "true" ( - set /a JVM_DEBUG_PORT=%%a 2>nul >nul - if not "%%a" == "!JVM_DEBUG_PORT!" ( - set SBT_ARGS=!SBT_ARGS! %%a - ) - ) else ( - set SBT_ARGS=!SBT_ARGS! %%a +:args_loop +if "%~1" == "" goto args_end + +if "%~1" == "-jvm-debug" ( + set JVM_DEBUG=true + set /a JVM_DEBUG_PORT=5005 2>nul >nul +) else if "!JVM_DEBUG!" == "true" ( + set /a JVM_DEBUG_PORT=%1 2>nul >nul + if not "%~1" == "!JVM_DEBUG_PORT!" ( + set SBT_ARGS=!SBT_ARGS! %1 ) +) else ( + set SBT_ARGS=!SBT_ARGS! %1 ) +shift +goto args_loop +:args_end + if defined JVM_DEBUG_PORT ( set _JAVA_OPTS=!_JAVA_OPTS! -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=!JVM_DEBUG_PORT! ) From ad3b90bed87090e7add70c1537cb4d11a2d446f0 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Fri, 28 Oct 2016 14:54:41 +0100 Subject: [PATCH 220/483] Add the debian changelog, for 0.13.13 release (#123) --- build.sbt | 1 + debian/changelog | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 debian/changelog diff --git a/build.sbt b/build.sbt index 9148dc361..407138e14 100644 --- a/build.sbt +++ b/build.sbt @@ -68,6 +68,7 @@ val root = (project in file(".")). (bd / "debian/changelog") -> "/usr/share/doc/sbt/changelog.gz" ) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs() }, + debianChangelog in Debian := Some(file("debian/changelog")) // RPM SPECIFIC name in Rpm := "sbt", diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 000000000..a7f55ff4a --- /dev/null +++ b/debian/changelog @@ -0,0 +1,21 @@ +sbt (0.13.13) + + * The `new` command, which helps creating new build definitions. + This is extensible via `templateResolverInfos` setting. + sbt 0.13.13 will ship with Giter8 template resolver out of the box. + #2705 by @eed3si9n + * Auto plugins can add synthetic subprojects. #2717 by @eed3si9n + * The no-longer-documented sbt 0.12 DSL `<<=`, `<+=`, and `<++=` + operators and tuple enrichment are now marked deprecated. + (These are removed in 1.0.x branch.) @eed3si9n and @dwijnand + * The `.value` method is deprecated for input tasks since `.evaluated` + is normally what's needed. + (Also removed in 1.0.x branch) #2709 by @eed3si9n + * sbt 0.13.13 will display deprecation warning for build.sbt. + #2784 by @eed3si9n + * Renames the early command `--` that was added in 0.13.1 to + `early()`. `--error` will work, but we encourage you to + migrate to single hyphen version: `-error`, `-warn`, `-info`, and + `-debug`. #2742 by @eed3si9n + + -- Dale Wijnand From 7b08fadd4ae5ce7ede35c181965b24649ae2d522 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Fri, 28 Oct 2016 14:58:48 +0100 Subject: [PATCH 221/483] My arch-enemy, the trailing comma --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 407138e14..606862696 100644 --- a/build.sbt +++ b/build.sbt @@ -68,7 +68,7 @@ val root = (project in file(".")). (bd / "debian/changelog") -> "/usr/share/doc/sbt/changelog.gz" ) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs() }, - debianChangelog in Debian := Some(file("debian/changelog")) + debianChangelog in Debian := Some(file("debian/changelog")), // RPM SPECIFIC name in Rpm := "sbt", From d8bf3825c320593700328688338b3875e83f320f Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Fri, 28 Oct 2016 15:37:35 +0100 Subject: [PATCH 222/483] Fixup debian changelog (#124) --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index a7f55ff4a..31d4e3726 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -sbt (0.13.13) +sbt (0.13.13) stable; urgency=low * The `new` command, which helps creating new build definitions. This is extensible via `templateResolverInfos` setting. @@ -18,4 +18,4 @@ sbt (0.13.13) migrate to single hyphen version: `-error`, `-warn`, `-info`, and `-debug`. #2742 by @eed3si9n - -- Dale Wijnand + -- Dale Wijnand Fri, 28 Oct 2016 14:30:00 +0000 From 1148f6f350ded207a77fe9460083289e71426137 Mon Sep 17 00:00:00 2001 From: Nepomuk Seiler Date: Mon, 31 Oct 2016 21:30:31 +0100 Subject: [PATCH 223/483] Upgrade native-packager --- project/project/plugins.scala | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/project/project/plugins.scala b/project/project/plugins.scala index 44a311937..c361ee041 100644 --- a/project/project/plugins.scala +++ b/project/project/plugins.scala @@ -3,13 +3,10 @@ import Keys._ object PluginBuild extends Build { override def projects = Seq(root) - + val root = Project("root", file(".")) settings( resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), - addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.1"), + addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.4"), libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.10" - ) //dependsOn(nativePackager) - - - //lazy val nativePackager = uri("file:///C:/projects/sbt-native-packager") + ) } From 95db5dcb016b6c68122e3fb2018a2f6e3f11fe11 Mon Sep 17 00:00:00 2001 From: Nepomuk Seiler Date: Mon, 31 Oct 2016 21:30:39 +0100 Subject: [PATCH 224/483] Fix package name --- build.sbt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index 606862696..0e92dbc20 100644 --- a/build.sbt +++ b/build.sbt @@ -7,7 +7,7 @@ lazy val sbtVersionToRelease = sys.props.getOrElse("sbt.build.version", sys.env. })) lazy val isExperimental = (sbtVersionToRelease contains "RC") || (sbtVersionToRelease contains "M") val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url") -val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") +val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") val moduleID = (organization) apply { (o) => ModuleID(o, "sbt", sbtVersionToRelease) } @@ -27,6 +27,7 @@ val root = (project in file(".")). settings( organization := "org.scala-sbt", name := "sbt-launcher-packaging", + packageName := "sbt", version := "0.1.0", crossTarget <<= target, deploymentSettings, @@ -59,7 +60,6 @@ val root = (project in file(".")). } yield link }, // DEBIAN SPECIFIC - name in Debian := "sbt", version in Debian := sbtVersionToRelease, debianPackageDependencies in Debian ++= Seq("java6-runtime-headless", "bash (>= 2.05a-11)"), debianPackageRecommends in Debian += "git", @@ -71,7 +71,6 @@ val root = (project in file(".")). debianChangelog in Debian := Some(file("debian/changelog")), // RPM SPECIFIC - name in Rpm := "sbt", version in Rpm := { val stable = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".") if (isExperimental) ((sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty)).toList match { @@ -87,7 +86,6 @@ val root = (project in file(".")). rpmProvides := Seq("sbt"), // WINDOWS SPECIFIC - name in Windows := "sbt", windowsBuildId := 1, version in Windows <<= (windowsBuildId) apply { (bid) => val sv = sbtVersionToRelease @@ -105,7 +103,7 @@ val root = (project in file(".")). javacOptions := Seq("-source", "1.5", "-target", "1.5"), // Universal ZIP download install. - name in Universal := "sbt", + packageName in Universal := packageName.value, // needs to be set explicitly due to a bug in native-packager version in Universal := sbtVersionToRelease, mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" }, @@ -171,4 +169,3 @@ def publishToSettings = def bintrayRelease(repo: BintrayRepo, pkg: String, version: String, log: Logger): Unit = repo.release(pkg, version, log) - From 345890880ee11a31c74c5ffe3335907365bce00d Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Wed, 16 Nov 2016 14:26:39 +0100 Subject: [PATCH 225/483] Missing quotes may cause incorrect PATH expansion, fixed If PATH contains ampersands etc, PATH may be incorrectly expanded. --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 5cf5fc7b7..bcbfd3b81 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -30,7 +30,7 @@ IF DEFINED JAVA_HOMES ( ) ) rem must set PATH or wrong javac is used for java projects -IF DEFINED JAVA_HOME SET PATH=%JAVA_HOME%\bin;%PATH% +IF DEFINED JAVA_HOME SET "PATH=%JAVA_HOME%\bin;%PATH%" rem users can set JAVA_OPTS via .jvmopts (sbt-extras style) IF EXIST .jvmopts FOR /F %%A IN (.jvmopts) DO ( From 04dfd94ff5efb66310b8dfb696309b5a56282e9a Mon Sep 17 00:00:00 2001 From: Will Sargent Date: Sun, 27 Nov 2016 20:30:58 -0800 Subject: [PATCH 226/483] Add MSYS as a "cygwin" like --- src/universal/bin/sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index d622f98ef..8ada3d5f4 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -38,6 +38,7 @@ is_cygwin() { case "$os" in CYGWIN*) return 0 ;; MINGW*) return 0 ;; + MSYS*) return 0 ;; *) return 1 ;; esac } From e1d64533f39c77fe81d380c4bc408af877e0fa8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8D=9A=20=28Yang=20Bo=29?= Date: Wed, 11 Jan 2017 12:00:34 +0800 Subject: [PATCH 227/483] Don't set MaxMetaspaceSize on Java 8 by default --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 78732874b..7b9e21aa0 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -94,7 +94,7 @@ get_mem_opts () { local arg_xms=$([[ "${java_args[@]}" == *-Xms* ]] && echo "" || echo "-Xms${mem}m") local arg_xmx=$([[ "${java_args[@]}" == *-Xmx* ]] && echo "" || echo "-Xmx${mem}m") local arg_rccs=$([[ "${java_args[@]}" == *-XX:ReservedCodeCacheSize* ]] && echo "" || echo "-XX:ReservedCodeCacheSize=${codecache}m") - local arg_meta=$([[ "${java_args[@]}" == *-XX:${class_metadata_opt}* ]] && echo "" || echo "-XX:${class_metadata_opt}=${class_metadata_size}m") + local arg_meta=$([[ "${java_args[@]}" == *-XX:${class_metadata_opt}* && ! "$java_version" < "1.8" ]] && echo "" || echo "-XX:${class_metadata_opt}=${class_metadata_size}m") echo "${arg_xms} ${arg_xmx} ${arg_rccs} ${arg_meta}" fi From f14b165523c7afe01e508736b61aa817717e2a6c Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 11 Jan 2017 00:20:38 -0500 Subject: [PATCH 228/483] Fix java version detection Previously awk was used to grab the full Java version such as 1.8.0_91. While this is more accurate, 1.8.0_91 is not a number that can be compared by bash, and thus JDK8 detection logics were failing. Fixes #135 --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 78732874b..7e49163f3 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -147,7 +147,7 @@ process_args () { process_my_args "${myargs[@]}" } - java_version=$("$java_cmd" -Xmx512M -version 2>&1 | awk -F '"' '/version/ {print $2}') + java_version=$("$java_cmd" -Xmx512M -version 2>&1 | sed 's/.*version "\([0-9]*\)\.\([0-9]*\)\..*"/\1.\2/; 1q') vlog "[process_args] java_version = '$java_version'" } From acd610be675b7125b3f226a31011ba2dcda7d084 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 16 Jan 2017 03:09:29 -0500 Subject: [PATCH 229/483] Fix checkJava function --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 3bc47cd72..6b73f7f28 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -161,7 +161,7 @@ checkJava() { echo Please go to http://www.java.com/getjava/ and download echo exit 1 - elif [[ ! "$java_version" > "$required_version" ]]; then + elif [[ "$java_version" < "$required_version" ]]; then echo echo The java installation you have is not up to date echo $script_name requires at least version $required_version+, you have From 3235fd1bf1854558a9019dc26476ca0088b6aa50 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 21 Jan 2017 05:56:55 -0500 Subject: [PATCH 230/483] Update copyright and license --- LICENSE.txt | 2 +- src/debian/usr/share/doc/sbt/copyright | 8 ++++---- src/linux/usr/share/doc/sbt/copyright | 8 ++++---- src/windows/License.rtf | Bin 1724 -> 1645 bytes 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index dc8aa7aad..7f3a9b61e 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,5 @@ // Generated from http://www.opensource.org/licenses/bsd-license.php -Copyright (c) 2011, Paul Phillips. +Copyright (c) 2011 - 2017, Paul Phillips, Lightbend, and other contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/src/debian/usr/share/doc/sbt/copyright b/src/debian/usr/share/doc/sbt/copyright index 4464f3ae7..53987e201 100644 --- a/src/debian/usr/share/doc/sbt/copyright +++ b/src/debian/usr/share/doc/sbt/copyright @@ -1,16 +1,16 @@ sbt -Copyright: Typesafe, Inc. +Copyright: Paul Phillips, Lightbend, and other contributors. 2011-11-28 -The home page of sbt package is at: -http://github.com/paulp/sbt-extras +The home page of sbt package is at: +https://github.com/sbt/sbt-launcher-package The entire code base may be distributed under the terms of the BSD license, which appears immediately below. -Copyright (c) 2011, Typesafe, Inc. +Copyright (c) 2011 - 2017, Paul Phillips, Lightbend, and other contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/src/linux/usr/share/doc/sbt/copyright b/src/linux/usr/share/doc/sbt/copyright index 4464f3ae7..53987e201 100644 --- a/src/linux/usr/share/doc/sbt/copyright +++ b/src/linux/usr/share/doc/sbt/copyright @@ -1,16 +1,16 @@ sbt -Copyright: Typesafe, Inc. +Copyright: Paul Phillips, Lightbend, and other contributors. 2011-11-28 -The home page of sbt package is at: -http://github.com/paulp/sbt-extras +The home page of sbt package is at: +https://github.com/sbt/sbt-launcher-package The entire code base may be distributed under the terms of the BSD license, which appears immediately below. -Copyright (c) 2011, Typesafe, Inc. +Copyright (c) 2011 - 2017, Paul Phillips, Lightbend, and other contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/src/windows/License.rtf b/src/windows/License.rtf index 4f90c8da4330e1b2820ec9f9e5c134b258983d9e..f0b3562a1d9d0ef840f690b33c2437ae72d8b84d 100644 GIT binary patch delta 72 zcmdnP`<7?IUK>M01ziOr14A<%g@DA;9EE_4%$%Ief?^#7pUm`(lBCqU6di@cycC7} bl8n?Mh2;FalA_F{(vtk5V!h2Cj3ul9Z)X^` delta 151 zcmXZUF$w}P5Jut3PVev^AVsv&RvQt7#mE+RqYj&8!$gvdu$5QvD)xFL4`AmCHV Date: Sat, 21 Jan 2017 06:36:33 -0500 Subject: [PATCH 231/483] Update the build --- .lib/README | 1 - build.sbt | 36 ++++++++++--------- debian/changelog | 21 ----------- project/build.properties | 3 +- project/plugins.sbt | 2 ++ project/project/plugins.scala | 12 ------- src/debian/changelog | 23 +++++++++++- template-project/build.sbt | 7 ---- template-project/project/Build.scala | 4 --- .../project/plugins/project/Build.scala | 7 ---- 10 files changed, 45 insertions(+), 71 deletions(-) delete mode 100644 .lib/README delete mode 100644 debian/changelog create mode 100644 project/plugins.sbt delete mode 100644 project/project/plugins.scala delete mode 100644 template-project/build.sbt delete mode 100644 template-project/project/Build.scala delete mode 100644 template-project/project/plugins/project/Build.scala diff --git a/.lib/README b/.lib/README deleted file mode 100644 index 6e3f9b576..000000000 --- a/.lib/README +++ /dev/null @@ -1 +0,0 @@ -sbt-launch.jar is downloaded into here. diff --git a/build.sbt b/build.sbt index 0e92dbc20..7c77a99b9 100644 --- a/build.sbt +++ b/build.sbt @@ -23,18 +23,20 @@ val windowsBuildId = settingKey[Int]("build id for Windows installer") // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. val root = (project in file(".")). - enablePlugins(UniversalPlugin, LinuxPlugin, DebianPlugin, RpmPlugin, WindowsPlugin). + enablePlugins(UniversalPlugin, LinuxPlugin, DebianPlugin, RpmPlugin, WindowsPlugin, + UniversalDeployPlugin, DebianDeployPlugin, RpmDeployPlugin, WindowsDeployPlugin). settings( organization := "org.scala-sbt", name := "sbt-launcher-packaging", packageName := "sbt", version := "0.1.0", - crossTarget <<= target, - deploymentSettings, + crossTarget := target.value, publishToSettings, sbtLaunchJarUrl := downloadUrlForVersion(sbtVersionToRelease), - sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"), - sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) => + sbtLaunchJarLocation := { target.value / "sbt-launch.jar" }, + sbtLaunchJar := { + val uri = sbtLaunchJarUrl.value + val file = sbtLaunchJarLocation.value import dispatch.classic._ if(!file.exists) { // oddly, some places require us to create the file before writing... @@ -52,7 +54,8 @@ val root = (project in file(".")). packageDescription := """This script provides a native way to run sbt, a build tool for Scala and more.""", // Here we remove the jar file and launch lib from the symlinks: - linuxPackageSymlinks <<= linuxPackageSymlinks map { links => + linuxPackageSymlinks := { + val links = linuxPackageSymlinks.value for { link <- links if !(link.destination endsWith "sbt-launch-lib.bash") @@ -63,13 +66,13 @@ val root = (project in file(".")). version in Debian := sbtVersionToRelease, debianPackageDependencies in Debian ++= Seq("java6-runtime-headless", "bash (>= 2.05a-11)"), debianPackageRecommends in Debian += "git", - linuxPackageMappings in Debian <+= (sourceDirectory) map { bd => + linuxPackageMappings in Debian += { + val bd = sourceDirectory.value (packageMapping( - (bd / "debian/changelog") -> "/usr/share/doc/sbt/changelog.gz" + (bd / "debian" / "changelog") -> "/usr/share/doc/sbt/changelog.gz" ) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs() }, - debianChangelog in Debian := Some(file("debian/changelog")), - + debianChangelog in Debian := { Some(sourceDirectory.value / "debian" / "changelog") }, // RPM SPECIFIC version in Rpm := { val stable = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".") @@ -87,7 +90,8 @@ val root = (project in file(".")). // WINDOWS SPECIFIC windowsBuildId := 1, - version in Windows <<= (windowsBuildId) apply { (bid) => + version in Windows := { + val bid = windowsBuildId.value val sv = sbtVersionToRelease (sv split "[^\\d]" filterNot (_.isEmpty)) match { case Array(major,minor,bugfix, _*) => Seq(major, minor, bugfix, bid.toString) mkString "." @@ -105,16 +109,16 @@ val root = (project in file(".")). // Universal ZIP download install. packageName in Universal := packageName.value, // needs to be set explicitly due to a bug in native-packager version in Universal := sbtVersionToRelease, - mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" }, + mappings in Universal += { sbtLaunchJar.value -> "bin/sbt-launch.jar" }, // Misccelaneous publishing stuff... - projectID in Debian <<= moduleID, + projectID in Debian := moduleID.value, projectID in Windows := { val m = moduleID.value m.copy(revision = (version in Windows).value) }, - projectID in Rpm <<= moduleID, - projectID in Universal <<= moduleID + projectID in Rpm := moduleID.value, + projectID in Universal := moduleID.value ) def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching(classOf[Exception]) opt (i.toInt))) match { @@ -160,7 +164,7 @@ def makePublishToForConfig(config: Configuration) = { // } yield bintrayRelease(repo, bintrayPackage, version, sLog) // } )) ++ Seq( - resolvers <++= (publishTo in config) apply (_.toSeq) + resolvers ++= ((publishTo in config) apply (_.toSeq)).value ) } diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 31d4e3726..000000000 --- a/debian/changelog +++ /dev/null @@ -1,21 +0,0 @@ -sbt (0.13.13) stable; urgency=low - - * The `new` command, which helps creating new build definitions. - This is extensible via `templateResolverInfos` setting. - sbt 0.13.13 will ship with Giter8 template resolver out of the box. - #2705 by @eed3si9n - * Auto plugins can add synthetic subprojects. #2717 by @eed3si9n - * The no-longer-documented sbt 0.12 DSL `<<=`, `<+=`, and `<++=` - operators and tuple enrichment are now marked deprecated. - (These are removed in 1.0.x branch.) @eed3si9n and @dwijnand - * The `.value` method is deprecated for input tasks since `.evaluated` - is normally what's needed. - (Also removed in 1.0.x branch) #2709 by @eed3si9n - * sbt 0.13.13 will display deprecation warning for build.sbt. - #2784 by @eed3si9n - * Renames the early command `--` that was added in 0.13.1 to - `early()`. `--error` will work, but we encourage you to - migrate to single hyphen version: `-error`, `-warn`, `-info`, and - `-debug`. #2742 by @eed3si9n - - -- Dale Wijnand Fri, 28 Oct 2016 14:30:00 +0000 diff --git a/project/build.properties b/project/build.properties index 75836b233..27e88aa11 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1 @@ -sbt.version=0.13.11 - +sbt.version=0.13.13 diff --git a/project/plugins.sbt b/project/plugins.sbt new file mode 100644 index 000000000..2c21f109f --- /dev/null +++ b/project/plugins.sbt @@ -0,0 +1,2 @@ +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.4") +libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.10" diff --git a/project/project/plugins.scala b/project/project/plugins.scala deleted file mode 100644 index c361ee041..000000000 --- a/project/project/plugins.scala +++ /dev/null @@ -1,12 +0,0 @@ -import sbt._ -import Keys._ - -object PluginBuild extends Build { - override def projects = Seq(root) - - val root = Project("root", file(".")) settings( - resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns), - addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.4"), - libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.10" - ) -} diff --git a/src/debian/changelog b/src/debian/changelog index ec30582fa..810742dc3 100644 --- a/src/debian/changelog +++ b/src/debian/changelog @@ -1,10 +1,31 @@ +sbt (0.13.13) stable; urgency=low + + * The `new` command, which helps creating new build definitions. + This is extensible via `templateResolverInfos` setting. + sbt 0.13.13 will ship with Giter8 template resolver out of the box. + #2705 by @eed3si9n + * Auto plugins can add synthetic subprojects. #2717 by @eed3si9n + * The no-longer-documented sbt 0.12 DSL `<<=`, `<+=`, and `<++=` + operators and tuple enrichment are now marked deprecated. + (These are removed in 1.0.x branch.) @eed3si9n and @dwijnand + * The `.value` method is deprecated for input tasks since `.evaluated` + is normally what's needed. + (Also removed in 1.0.x branch) #2709 by @eed3si9n + * sbt 0.13.13 will display deprecation warning for build.sbt. + #2784 by @eed3si9n + * Renames the early command `--` that was added in 0.13.1 to + `early()`. `--error` will work, but we encourage you to + migrate to single hyphen version: `-error`, `-warn`, `-info`, and + `-debug`. #2742 by @eed3si9n + + -- Dale Wijnand Fri, 28 Oct 2016 14:30:00 +0000 sbt (0.12.0-build-0100) * No need for different launcher jar files now -- Joshua Suereth 2012-07-2012 - + sbt (0.11.2-build-0100) * First debian package release diff --git a/template-project/build.sbt b/template-project/build.sbt deleted file mode 100644 index bb948043e..000000000 --- a/template-project/build.sbt +++ /dev/null @@ -1,7 +0,0 @@ -simple_setting("name") is "test-project" - -simple_task("zomg") is { println("ZOMG") } - -simple_task("zomg2") on (name, version) is { (n,v) => println("ZOMG " + n + " = " + v + " !!!!!") } - - diff --git a/template-project/project/Build.scala b/template-project/project/Build.scala deleted file mode 100644 index 9e4f80e1f..000000000 --- a/template-project/project/Build.scala +++ /dev/null @@ -1,4 +0,0 @@ -import sbt._ -import template.TemplateBuild - -object MyAwesomeBuild extends TemplateBuild { } diff --git a/template-project/project/plugins/project/Build.scala b/template-project/project/plugins/project/Build.scala deleted file mode 100644 index 3d793bec8..000000000 --- a/template-project/project/plugins/project/Build.scala +++ /dev/null @@ -1,7 +0,0 @@ -import sbt._ - -object PluginDef extends Build { - override def projects = Seq(root) - lazy val root = Project("plugins", file(".")) dependsOn(extras) - lazy val extras = uri("git://github.com/paulp/sbt-extras") -} From b6d6f243d8aab4f7ed0f4a082e9f1058e0371b0f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 21 Jan 2017 06:57:48 -0500 Subject: [PATCH 232/483] Hardcode to OpenJDK 8 Fixes sbt/sbt#2931 java6-runtime-headless is a virtual package. On some distribution it actually installs JDK 9. --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 7c77a99b9..9ce1c4b22 100644 --- a/build.sbt +++ b/build.sbt @@ -64,7 +64,7 @@ val root = (project in file(".")). }, // DEBIAN SPECIFIC version in Debian := sbtVersionToRelease, - debianPackageDependencies in Debian ++= Seq("java6-runtime-headless", "bash (>= 2.05a-11)"), + debianPackageDependencies in Debian ++= Seq("openjdk-8-jdk", "bash (>= 3.2)"), debianPackageRecommends in Debian += "git", linuxPackageMappings in Debian += { val bd = sourceDirectory.value From 8cc3cdfc291b73fa02e053ba256ce82cca359371 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 21 Jan 2017 07:19:57 -0500 Subject: [PATCH 233/483] java-devel >= 1.8, java-devel < 1.9 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 9ce1c4b22..51fbaf83b 100644 --- a/build.sbt +++ b/build.sbt @@ -82,10 +82,10 @@ val root = (project in file(".")). else stable }, rpmRelease := "1", - rpmVendor := "typesafe", + rpmVendor := "lightbend", rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"), rpmLicense := Some("BSD"), - rpmRequirements :=Seq("java","java-devel","jpackage-utils"), + rpmRequirements := Seq("java-devel >= 1.8", "java-devel < 1.9"), rpmProvides := Seq("sbt"), // WINDOWS SPECIFIC From f77c15496b18324e893f7ba3c43f5c78433d3833 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 15 Feb 2017 04:57:47 -0500 Subject: [PATCH 234/483] add JDK 9 support --- .java-version | 1 + build.sbt | 18 ++++++- .../github/retronym/java9rtexport/Copy.java | 49 +++++++++++++++++++ .../github/retronym/java9rtexport/Export.java | 48 ++++++++++++++++++ src/universal/bin/sbt-launch-lib.bash | 32 +++++++++++- 5 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 .java-version create mode 100644 java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Copy.java create mode 100644 java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java diff --git a/.java-version b/.java-version new file mode 100644 index 000000000..625934097 --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +1.8 diff --git a/build.sbt b/build.sbt index 0e92dbc20..b3721d359 100644 --- a/build.sbt +++ b/build.sbt @@ -105,7 +105,11 @@ val root = (project in file(".")). // Universal ZIP download install. packageName in Universal := packageName.value, // needs to be set explicitly due to a bug in native-packager version in Universal := sbtVersionToRelease, - mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" }, + mappings in Universal ++= { + val launchJar = sbtLaunchJar.value + val rtExportJar = (packageBin in Compile in java9rtexport).value + Seq(launchJar -> "bin/sbt-launch.jar", rtExportJar -> "bin/java9-rt-export.jar") + }, // Misccelaneous publishing stuff... projectID in Debian <<= moduleID, @@ -117,6 +121,18 @@ val root = (project in file(".")). projectID in Universal <<= moduleID ) +lazy val java9rtexport = (project in file("java9-rt-export")) + .settings( + name := "java9-rt-export", + autoScalaLibrary := false, + crossPaths := false, + description := "Exports the contents of the Java 9. JEP-220 runtime image to a JAR for compatibility with older tools.", + homepage := Some(url("http://github.com/retronym/" + name.value)), + startYear := Some(2017), + licenses += ("Scala license", url(homepage.value.get.toString + "/blob/master/LICENSE")), + mainClass in Compile := Some("io.github.retronym.java9rtexport.Export") + ) + def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching(classOf[Exception]) opt (i.toInt))) match { case Array(0, 11, 3, _*) => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.11.3-2/sbt-launch.jar" case Array(0, 11, x, _*) if x >= 3 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" diff --git a/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Copy.java b/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Copy.java new file mode 100644 index 000000000..31c7e95d7 --- /dev/null +++ b/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Copy.java @@ -0,0 +1,49 @@ +package io.github.retronym.java9rtexport; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.file.*; +import java.nio.file.attribute.*; +import java.util.EnumSet; + +import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; + +public class Copy { + public static void copyDirectory(final Path source, final Path target) + throws IOException { + Files.walkFileTree(source, EnumSet.of(FileVisitOption.FOLLOW_LINKS), + Integer.MAX_VALUE, new FileVisitor() { + + @Override + public FileVisitResult preVisitDirectory(Path dir, + BasicFileAttributes sourceBasic) throws IOException { + + String relative = source.relativize(dir).toString(); + if (!Files.exists(target.getFileSystem().getPath(relative))) + Files.createDirectory(target.getFileSystem().getPath(relative)); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFile(Path file, + BasicFileAttributes attrs) throws IOException { + String relative = source.relativize(file).toString(); + Files.copy(file, target.getFileSystem().getPath(relative), COPY_ATTRIBUTES, REPLACE_EXISTING); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFileFailed(Path file, IOException e) throws IOException { + throw e; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException { + if (e != null) throw e; + return FileVisitResult.CONTINUE; + } + }); + } + +} diff --git a/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java b/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java new file mode 100644 index 000000000..eee31ce46 --- /dev/null +++ b/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java @@ -0,0 +1,48 @@ +package io.github.retronym.java9rtexport; + +import java.io.IOException; +import java.net.URI; +import java.nio.file.*; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class Export { + public static void main(String[] args) { + try { + + if (args.length == 0) { + System.err.println("Usage:"); + System.err.println(" java -jar java9-rt-export-*.jar $HOME/.sbt/java9-rt-ext/rt.jar"); + System.err.println(" Exports rt.jar to the specified path."); + System.err.println(""); + System.err.println(" java -jar java9-rt-export-*.jar --global-base"); + System.err.println(" Prints sbt global base."); + System.exit(-1); + } + String destination = args[0]; + if (destination.equals("--global-base")) { + Path defaultGlobalBase = Paths.get(System.getProperty("user.home"), ".sbt", "0.13"); + String globalBase = System.getProperty("sbt.global.base", defaultGlobalBase.toString()); + System.out.println(globalBase); + System.exit(0); + } + FileSystem fileSystem = FileSystems.getFileSystem(URI.create("jrt:/")); + Path path = fileSystem.getPath("/modules"); + Path destPath = Paths.get(destination); + URI uri = URI.create( "jar:" + destPath.toUri() ); + Map env = new HashMap<>(); + env.put( "create", "true" ); + try ( FileSystem zipfs = FileSystems.newFileSystem( uri, env ) ) { + Iterator iterator = Files.list(path).iterator(); + while(iterator.hasNext()) { + Path next = iterator.next(); + Copy.copyDirectory(next, zipfs.getPath("/")); + } + } + } catch (IOException e) { + e.printStackTrace(); + System.exit(-1); + } + } +} diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 6b73f7f28..f51460a2a 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -38,6 +38,10 @@ acquire_sbt_jar () { fi } +rt_export_file () { + echo "${sbt_bin_dir}/java9-rt-export.jar" +} + execRunner () { # print the arguments one to a line, quoting any containing spaces [[ $verbose || $debug ]] && echo "# Executing command line:" && { @@ -147,8 +151,16 @@ process_args () { process_my_args "${myargs[@]}" } - java_version=$("$java_cmd" -Xmx512M -version 2>&1 | sed 's/.*version "\([0-9]*\)\.\([0-9]*\)\..*"/\1.\2/; 1q') + ## parses 1.7, 1.8, 9, etc out of java version "1.8.0_91" + java_version=$("$java_cmd" -Xmx512M -version 2>&1 | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') vlog "[process_args] java_version = '$java_version'" + rtexport=$(rt_export_file) + sbt_global_dir=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ + -jar "$rtexport" --global-base) + java9_ext=$(echo "$sbt_global_dir/java9-rt-ext") + java9_rt=$(echo "$java9_ext/rt.jar") + vlog "[process_args] sbt_global_dir = '$sbt_global_dir'" + vlog "[process_args] java9_rt = '$java9_rt'" } # Detect that we have java installed. @@ -174,6 +186,21 @@ checkJava() { fi } +copyRt() { + if [[ "$java_version" > "8" ]] && [[ ! -f "$java9_rt" ]]; then + echo Copying runtime jar. + execRunner "$java_cmd" \ + ${JAVA_OPTS} \ + ${SBT_OPTS:-$default_sbt_opts} \ + ${java_args[@]} \ + -jar "$rtexport" \ + "${java9_rt}" + fi + if [[ "$java_version" > "8" ]]; then + addJava "-Dscala.ext.dirs=${java9_ext}" + fi +} + run() { # no jar? download it. @@ -191,6 +218,9 @@ run() { # TODO - java check should be configurable... checkJava "1.6" + # Java 9 support + copyRt + #If we're in cygwin, we should use the windows config, and terminal hacks if [[ "$CYGWIN_FLAG" == "true" ]]; then stty -icanon min 1 -echo > /dev/null 2>&1 From e8670ba78fb114de013636ab70c6c7fa08e48661 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 15 Feb 2017 12:17:23 -0500 Subject: [PATCH 235/483] Change to Windows lineending --- src/universal/bin/sbt.bat | 190 +++++++++++++++++++------------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 0f7a3e9a3..737d99db3 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -1,95 +1,95 @@ -@REM SBT launcher script -@REM -@REM Environment: -@REM JAVA_HOME - location of a JDK home dir (mandatory) -@REM SBT_OPTS - JVM options (optional) -@REM Configuration: -@REM sbtconfig.txt found in the SBT_HOME. - -@REM ZOMG! We need delayed expansion to build up CFG_OPTS later -@setlocal enabledelayedexpansion - -@echo off -set SBT_HOME=%~dp0 - -rem FIRST we load the config file of extra options. -set FN=%SBT_HOME%\..\conf\sbtconfig.txt -set CFG_OPTS= -FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%FN%") DO ( - set DO_NOT_REUSE_ME=%%i - rem ZOMG (Part #2) WE use !! here to delay the expansion of - rem CFG_OPTS, otherwise it remains "" for this loop. - set CFG_OPTS=!CFG_OPTS! !DO_NOT_REUSE_ME! -) - -rem poor man's jenv (which is not available on Windows) -IF DEFINED JAVA_HOMES ( - IF EXIST .java-version FOR /F %%A IN (.java-version) DO ( - SET JAVA_HOME=%JAVA_HOMES%\%%A - SET JDK_HOME=%JAVA_HOMES%\%%A - ) -) -rem must set PATH or wrong javac is used for java projects -IF DEFINED JAVA_HOME SET "PATH=%JAVA_HOME%\bin;%PATH%" - -rem users can set JAVA_OPTS via .jvmopts (sbt-extras style) -IF EXIST .jvmopts FOR /F %%A IN (.jvmopts) DO ( - SET JAVA_OPTS=%%A !JAVA_OPTS! -) - -rem We use the value of the JAVACMD environment variable if defined -set _JAVACMD=%JAVACMD% - -if "%_JAVACMD%"=="" ( - if not "%JAVA_HOME%"=="" ( - if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe" - ) -) - -if "%_JAVACMD%"=="" set _JAVACMD=java - -rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config. -set _JAVA_OPTS=%JAVA_OPTS% -if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% - -:args_loop -if "%~1" == "" goto args_end - -if "%~1" == "-jvm-debug" ( - set JVM_DEBUG=true - set /a JVM_DEBUG_PORT=5005 2>nul >nul -) else if "!JVM_DEBUG!" == "true" ( - set /a JVM_DEBUG_PORT=%1 2>nul >nul - if not "%~1" == "!JVM_DEBUG_PORT!" ( - set SBT_ARGS=!SBT_ARGS! %1 - ) -) else ( - set SBT_ARGS=!SBT_ARGS! %1 -) - -shift -goto args_loop -:args_end - -if defined JVM_DEBUG_PORT ( - set _JAVA_OPTS=!_JAVA_OPTS! -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=!JVM_DEBUG_PORT! -) - -call :run %SBT_ARGS% - -if ERRORLEVEL 1 goto error -goto end - -:run - -"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%sbt-launch.jar" xsbt.boot.Boot %* -goto :eof - -:error -@endlocal -exit /B 1 - - -:end -@endlocal -exit /B 0 +@REM SBT launcher script +@REM +@REM Environment: +@REM JAVA_HOME - location of a JDK home dir (mandatory) +@REM SBT_OPTS - JVM options (optional) +@REM Configuration: +@REM sbtconfig.txt found in the SBT_HOME. + +@REM ZOMG! We need delayed expansion to build up CFG_OPTS later +@setlocal enabledelayedexpansion + +@echo off +set SBT_HOME=%~dp0 + +rem FIRST we load the config file of extra options. +set FN=%SBT_HOME%\..\conf\sbtconfig.txt +set CFG_OPTS= +FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%FN%") DO ( + set DO_NOT_REUSE_ME=%%i + rem ZOMG (Part #2) WE use !! here to delay the expansion of + rem CFG_OPTS, otherwise it remains "" for this loop. + set CFG_OPTS=!CFG_OPTS! !DO_NOT_REUSE_ME! +) + +rem poor man's jenv (which is not available on Windows) +IF DEFINED JAVA_HOMES ( + IF EXIST .java-version FOR /F %%A IN (.java-version) DO ( + SET JAVA_HOME=%JAVA_HOMES%\%%A + SET JDK_HOME=%JAVA_HOMES%\%%A + ) +) +rem must set PATH or wrong javac is used for java projects +IF DEFINED JAVA_HOME SET "PATH=%JAVA_HOME%\bin;%PATH%" + +rem users can set JAVA_OPTS via .jvmopts (sbt-extras style) +IF EXIST .jvmopts FOR /F %%A IN (.jvmopts) DO ( + SET JAVA_OPTS=%%A !JAVA_OPTS! +) + +rem We use the value of the JAVACMD environment variable if defined +set _JAVACMD=%JAVACMD% + +if "%_JAVACMD%"=="" ( + if not "%JAVA_HOME%"=="" ( + if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe" + ) +) + +if "%_JAVACMD%"=="" set _JAVACMD=java + +rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config. +set _JAVA_OPTS=%JAVA_OPTS% +if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% + +:args_loop +if "%~1" == "" goto args_end + +if "%~1" == "-jvm-debug" ( + set JVM_DEBUG=true + set /a JVM_DEBUG_PORT=5005 2>nul >nul +) else if "!JVM_DEBUG!" == "true" ( + set /a JVM_DEBUG_PORT=%1 2>nul >nul + if not "%~1" == "!JVM_DEBUG_PORT!" ( + set SBT_ARGS=!SBT_ARGS! %1 + ) +) else ( + set SBT_ARGS=!SBT_ARGS! %1 +) + +shift +goto args_loop +:args_end + +if defined JVM_DEBUG_PORT ( + set _JAVA_OPTS=!_JAVA_OPTS! -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=!JVM_DEBUG_PORT! +) + +call :run %SBT_ARGS% + +if ERRORLEVEL 1 goto error +goto end + +:run + +"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%sbt-launch.jar" xsbt.boot.Boot %* +goto :eof + +:error +@endlocal +exit /B 1 + + +:end +@endlocal +exit /B 0 From 1b9f618efa2a4039a6961a8336b35034404f6cbb Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 15 Feb 2017 12:18:51 -0500 Subject: [PATCH 236/483] Implement JDK 9 support for Windows --- src/universal/bin/sbt.bat | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 737d99db3..4411697a1 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -75,6 +75,12 @@ if defined JVM_DEBUG_PORT ( set _JAVA_OPTS=!_JAVA_OPTS! -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=!JVM_DEBUG_PORT! ) +call :process + +call :checkjava + +call :copyrt + call :run %SBT_ARGS% if ERRORLEVEL 1 goto error @@ -93,3 +99,55 @@ exit /B 1 :end @endlocal exit /B 0 + +:process +rem parses 1.7, 1.8, 9, etc out of java version "1.8.0_91" +"%_JAVACMD%" -Xmx512M -version 2> "%TEMP%.\out.txt" +set JAVA_VERSION=0 +findstr /c:"version \"9" "%TEMP%.\out.txt" +if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=9) +findstr /c:"version \"1.8" "%TEMP%.\out.txt" +if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.8) +findstr /c:"version \"1.7" "%TEMP%.\out.txt" +if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.7) +findstr /c:"version \"1.6" "%TEMP%.\out.txt" +if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.6) +findstr /c:"version \"1.5" "%TEMP%.\out.txt" +if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.5) + +set rtexport=%SBT_HOME%java9-rt-export.jar + +"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "%rtexport%" --global-base > "%TEMP%.\global_base.txt" +set /p sbt_global_dir= < "%TEMP%.\global_base.txt" +set java9_ext=%sbt_global_dir%\java9-rt-ext +set java9_rt=%java9_ext%\rt.jar + +echo %java9_rt% + +exit /B 0 + +:checkjava +set required_version=1.6 +if /I "%JAVA_VERSION%" GEQ "%required_version%" ( + exit /B 0 +) +echo. +echo The java installation you have is not up to date +echo sbt requires at least version %required_version%+, you have +echo version %JAVA_VERSION% +echo. +echo Please go to http://www.java.com/getjava/ and download +echo a valid Java Runtime and install before running sbt. +echo. +exit /B 1 + +:copyrt +if /I "%JAVA_VERSION%" GEQ "9" ( + if not exist "%java9_rt%" ( + echo Copying runtime jar. + mkdir "%java9_ext%" + "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "%rtexport%" "%java9_rt%" + ) + set _JAVA_OPTS=!_JAVA_OPTS! -Dscala.ext.dirs="%java9_ext%" +) +exit /B 0 From dfc3312c7d47868d34eb69fbc112138f41d73ec1 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 15 Feb 2017 12:21:08 -0500 Subject: [PATCH 237/483] oraclejdk8 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e8c434f57..b58de08cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ script: scala: - 2.10.3 jdk: - - oraclejdk7 + - oraclejdk8 notifications: email: - sbt-dev-bot@googlegroups.com From 605a17d9495f2adca59fc282d3f9f24fdcda4043 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 19 Feb 2017 09:16:40 +0100 Subject: [PATCH 238/483] move JDK9 logic within copyRt --- src/universal/bin/sbt-launch-lib.bash | 33 +++++++++++++-------------- src/universal/bin/sbt.bat | 16 ++++++------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index f51460a2a..c66f5e849 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -154,13 +154,6 @@ process_args () { ## parses 1.7, 1.8, 9, etc out of java version "1.8.0_91" java_version=$("$java_cmd" -Xmx512M -version 2>&1 | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') vlog "[process_args] java_version = '$java_version'" - rtexport=$(rt_export_file) - sbt_global_dir=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ - -jar "$rtexport" --global-base) - java9_ext=$(echo "$sbt_global_dir/java9-rt-ext") - java9_rt=$(echo "$java9_ext/rt.jar") - vlog "[process_args] sbt_global_dir = '$sbt_global_dir'" - vlog "[process_args] java9_rt = '$java9_rt'" } # Detect that we have java installed. @@ -187,21 +180,27 @@ checkJava() { } copyRt() { - if [[ "$java_version" > "8" ]] && [[ ! -f "$java9_rt" ]]; then - echo Copying runtime jar. - execRunner "$java_cmd" \ - ${JAVA_OPTS} \ - ${SBT_OPTS:-$default_sbt_opts} \ - ${java_args[@]} \ - -jar "$rtexport" \ - "${java9_rt}" - fi if [[ "$java_version" > "8" ]]; then + rtexport=$(rt_export_file) + sbt_global_dir=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ + -jar "$rtexport" --global-base) + java9_ext=$(echo "$sbt_global_dir/java9-rt-ext") + java9_rt=$(echo "$java9_ext/rt.jar") + vlog "[copyRt] sbt_global_dir = '$sbt_global_dir'" + vlog "[copyRt] java9_rt = '$java9_rt'" + if [[ ! -f "$java9_rt" ]]; then + echo Copying runtime jar. + execRunner "$java_cmd" \ + ${JAVA_OPTS} \ + ${SBT_OPTS:-$default_sbt_opts} \ + ${java_args[@]} \ + -jar "$rtexport" \ + "${java9_rt}" + fi addJava "-Dscala.ext.dirs=${java9_ext}" fi } - run() { # no jar? download it. [[ -f "$sbt_jar" ]] || acquire_sbt_jar "$sbt_version" || { diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 4411697a1..a02088a23 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -115,15 +115,6 @@ if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.6) findstr /c:"version \"1.5" "%TEMP%.\out.txt" if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.5) -set rtexport=%SBT_HOME%java9-rt-export.jar - -"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "%rtexport%" --global-base > "%TEMP%.\global_base.txt" -set /p sbt_global_dir= < "%TEMP%.\global_base.txt" -set java9_ext=%sbt_global_dir%\java9-rt-ext -set java9_rt=%java9_ext%\rt.jar - -echo %java9_rt% - exit /B 0 :checkjava @@ -143,6 +134,13 @@ exit /B 1 :copyrt if /I "%JAVA_VERSION%" GEQ "9" ( + set rtexport=%SBT_HOME%java9-rt-export.jar + + "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "%rtexport%" --global-base > "%TEMP%.\global_base.txt" + set /p sbt_global_dir= < "%TEMP%.\global_base.txt" + set java9_ext=%sbt_global_dir%\java9-rt-ext + set java9_rt=%java9_ext%\rt.jar + if not exist "%java9_rt%" ( echo Copying runtime jar. mkdir "%java9_ext%" From 84624d8ce59794b2fffb1dd6c16709b3d19871af Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Wed, 22 Feb 2017 11:48:02 +0100 Subject: [PATCH 239/483] Fix java-devel dependency on rpm-based systems The dependency as specified won't work on Fedora 25. The situation concerning requiring the selection of Java versions is tricky, and is detailed at: https://github.com/elastic/logstash/issues/6275 The conclusion of that thread is that "it is not possible to provide a package that correctly works for users of all supported Java packages.", meaning a dependency on either one of OpenJDK or Oracle JDK. Assuming the dependency is on OpenJDK, the list of metapackages provided is listed at: https://github.com/elastic/logstash/issues/6275#issuecomment-261356980 The dependency "java-1.8.0-devel" will be satisfied by any revision of OpenJDK 1.8, so that is the one that is proposed in this pull request. --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 51fbaf83b..5dcf76bda 100644 --- a/build.sbt +++ b/build.sbt @@ -85,7 +85,7 @@ val root = (project in file(".")). rpmVendor := "lightbend", rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"), rpmLicense := Some("BSD"), - rpmRequirements := Seq("java-devel >= 1.8", "java-devel < 1.9"), + rpmRequirements := Seq("java-1.8.0-devel"), rpmProvides := Seq("sbt"), // WINDOWS SPECIFIC From 39d850404555bd9da25adf0f4a5b758a08a955b5 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 4 Mar 2017 13:03:36 -0500 Subject: [PATCH 240/483] --rt-ext-dir returns a dir specific to JDK 9 ver --- .../io/github/retronym/java9rtexport/Export.java | 16 +++++++++++----- .../java9rtexport/{Copy.java => IO.java} | 2 +- src/universal/bin/sbt-launch-lib.bash | 6 ++---- src/universal/bin/sbt.bat | 5 ++--- 4 files changed, 16 insertions(+), 13 deletions(-) rename java9-rt-export/src/main/java/io/github/retronym/java9rtexport/{Copy.java => IO.java} (99%) diff --git a/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java b/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java index eee31ce46..6bb468531 100644 --- a/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java +++ b/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java @@ -10,23 +10,29 @@ import java.util.Map; public class Export { public static void main(String[] args) { try { - if (args.length == 0) { System.err.println("Usage:"); System.err.println(" java -jar java9-rt-export-*.jar $HOME/.sbt/java9-rt-ext/rt.jar"); System.err.println(" Exports rt.jar to the specified path."); System.err.println(""); - System.err.println(" java -jar java9-rt-export-*.jar --global-base"); + System.err.println(" java -jar java9-rt-export-*.jar --rt-ext-dir"); System.err.println(" Prints sbt global base."); System.exit(-1); } String destination = args[0]; + Path defaultGlobalBase = Paths.get(System.getProperty("user.home"), ".sbt", "0.13"); + String globalBase = System.getProperty("sbt.global.base", defaultGlobalBase.toString()); if (destination.equals("--global-base")) { - Path defaultGlobalBase = Paths.get(System.getProperty("user.home"), ".sbt", "0.13"); - String globalBase = System.getProperty("sbt.global.base", defaultGlobalBase.toString()); System.out.println(globalBase); System.exit(0); } + if (destination.equals("--rt-ext-dir")) { + String v = System.getProperty("java.vendor") + "_" + System.getProperty("java.version"); + v = v.replaceAll("\\W", "_").toLowerCase(); + Path rtExtDir = Paths.get(globalBase, "java9-rt-ext-" + v); + System.out.println(rtExtDir.toString()); + System.exit(0); + } FileSystem fileSystem = FileSystems.getFileSystem(URI.create("jrt:/")); Path path = fileSystem.getPath("/modules"); Path destPath = Paths.get(destination); @@ -37,7 +43,7 @@ public class Export { Iterator iterator = Files.list(path).iterator(); while(iterator.hasNext()) { Path next = iterator.next(); - Copy.copyDirectory(next, zipfs.getPath("/")); + IO.copyDirectory(next, zipfs.getPath("/")); } } } catch (IOException e) { diff --git a/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Copy.java b/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/IO.java similarity index 99% rename from java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Copy.java rename to java9-rt-export/src/main/java/io/github/retronym/java9rtexport/IO.java index 31c7e95d7..a57eaa392 100644 --- a/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Copy.java +++ b/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/IO.java @@ -9,7 +9,7 @@ import java.util.EnumSet; import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; -public class Copy { +public class IO { public static void copyDirectory(final Path source, final Path target) throws IOException { Files.walkFileTree(source, EnumSet.of(FileVisitOption.FOLLOW_LINKS), diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index c66f5e849..c58f445da 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -182,11 +182,9 @@ checkJava() { copyRt() { if [[ "$java_version" > "8" ]]; then rtexport=$(rt_export_file) - sbt_global_dir=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ - -jar "$rtexport" --global-base) - java9_ext=$(echo "$sbt_global_dir/java9-rt-ext") + java9_ext=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ + -jar "$rtexport" --rt-ext-dir) java9_rt=$(echo "$java9_ext/rt.jar") - vlog "[copyRt] sbt_global_dir = '$sbt_global_dir'" vlog "[copyRt] java9_rt = '$java9_rt'" if [[ ! -f "$java9_rt" ]]; then echo Copying runtime jar. diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index a02088a23..12178b7c7 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -136,9 +136,8 @@ exit /B 1 if /I "%JAVA_VERSION%" GEQ "9" ( set rtexport=%SBT_HOME%java9-rt-export.jar - "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "%rtexport%" --global-base > "%TEMP%.\global_base.txt" - set /p sbt_global_dir= < "%TEMP%.\global_base.txt" - set java9_ext=%sbt_global_dir%\java9-rt-ext + "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "%rtexport%" --rt-ext-dir > "%TEMP%.\rtext.txt" + set /p java9_ext= < "%TEMP%.\rtext.txt" set java9_rt=%java9_ext%\rt.jar if not exist "%java9_rt%" ( From cea5d178d86b91ba0231e46be885f80c386723f4 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 6 Mar 2017 22:34:59 -0500 Subject: [PATCH 241/483] add offline installtion To utilize local preloaded repo, this will create lib/ directory with all artifacts required for sbt. This can be rsynced to the preloaded repo. --- build.sbt | 60 +++++++++++++++++++++++++++ project/bintray.sbt | 2 - project/plugins.sbt | 2 + src/universal/bin/sbt-launch-lib.bash | 11 +++++ src/universal/bin/sbt.bat | 33 +++++++++++---- 5 files changed, 97 insertions(+), 11 deletions(-) delete mode 100644 project/bintray.sbt diff --git a/build.sbt b/build.sbt index a446273de..09cd19857 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,7 @@ import scala.util.control.Exception.catching import _root_.bintray.InternalBintrayKeys._ import _root_.bintray.{BintrayRepo, Bintray} +import NativePackagerHelper._ lazy val sbtVersionToRelease = sys.props.getOrElse("sbt.build.version", sys.env.getOrElse("sbt.build.version", { sys.error("-Dsbt.build.version must be set") @@ -114,6 +115,19 @@ val root = (project in file(".")). val rtExportJar = (packageBin in Compile in java9rtexport).value Seq(launchJar -> "bin/sbt-launch.jar", rtExportJar -> "bin/java9-rt-export.jar") }, + mappings in Universal ++= { + val _ = (exportRepo in dist).value + directory((target in dist).value / "lib") + }, + stage in Universal := { + val old = (stage in Universal).value + val sd = (stagingDirectory in Universal).value + val x = IO.read(sd / "bin" / "sbt-launch-lib.bash") + IO.write(sd / "bin" / "sbt-launch-lib.bash", x.replaceAllLiterally("declare init_sbt_version=", s"declare init_sbt_version=$sbtVersionToRelease")) + val y = IO.read(sd / "bin" / "sbt.bat") + IO.write(sd / "bin" / "sbt.bat", y.replaceAllLiterally("set INIT_SBT_VERSION=", s"set INIT_SBT_VERSION=$sbtVersionToRelease")) + old + }, // Misccelaneous publishing stuff... projectID in Debian := moduleID.value, @@ -189,3 +203,49 @@ def publishToSettings = def bintrayRelease(repo: BintrayRepo, pkg: String, version: String, log: Logger): Unit = repo.release(pkg, version, log) + + +lazy val scala210 = "2.10.6" +lazy val scala212 = "2.12.1" +lazy val scala210Jline = "org.scala-lang" % "jline" % scala210 +lazy val jansi = "org.fusesource.jansi" % "jansi" % "1.4" +lazy val scala212Jline = "jline" % "jline" % "2.14.1" +lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6" +lazy val scala212Compiler = "org.scala-lang" % "scala-compiler" % scala212 +lazy val sbtActual = "org.scala-sbt" % "sbt" % sbtVersionToRelease + +def downloadUrl(uri: URI, out: File): Unit = + { + import dispatch.classic._ + if(!out.exists) { + IO.touch(out) + val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(out)) + try Http(url(uri.toString) >>> writer) + finally writer.close() + } + } + +lazy val dist = (project in file("dist")) + .enablePlugins(ExportRepoPlugin) + .settings( + name := "dist", + scalaVersion := scala210, + libraryDependencies ++= Seq(sbtActual, scala210Jline, jansi, scala212Compiler, scala212Jline, scala212Xml), + exportRepo := { + val old = exportRepo.value + sbtVersionToRelease match { + case v if v.startsWith("0.13.") => + val outbase = exportRepoDirectory.value / "org.scala-sbt" / "compiler-interface" / v + val uribase = s"https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compiler-interface/$v/" + downloadUrl(uri(uribase + "ivys/ivy.xml"), outbase / "ivys" / "ivy.xml") + downloadUrl(uri(uribase + "jars/compiler-interface.jar"), outbase / "jars" / "compiler-interface.jar") + downloadUrl(uri(uribase + "srcs/compiler-interface-sources.jar"), outbase / "srcs" / "compiler-interface-sources.jar") + case _ => + } + old + }, + exportRepoDirectory := target.value / "lib" / "local-preloaded", + conflictWarning := ConflictWarning.disable, + publish := (), + publishLocal := () + ) diff --git a/project/bintray.sbt b/project/bintray.sbt deleted file mode 100644 index b2ace147a..000000000 --- a/project/bintray.sbt +++ /dev/null @@ -1,2 +0,0 @@ -addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0") - diff --git a/project/plugins.sbt b/project/plugins.sbt index 2c21f109f..74869e0ed 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,4 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.4") libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.10" +addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0") +addSbtPlugin("com.eed3si9n" % "sbt-export-repo" % "0.1.0") diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index c58f445da..963634795 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -14,6 +14,7 @@ declare java_cmd=java declare java_version declare -r sbt_bin_dir="$(dirname "$(realpath "$0")")" declare -r sbt_home="$(dirname "$sbt_bin_dir")" +declare init_sbt_version= echoerr () { echo 1>&2 "$@" @@ -156,6 +157,14 @@ process_args () { vlog "[process_args] java_version = '$java_version'" } +syncPreloaded() { + [[ -f "$HOME/.sbt/preloaded/org.scala-sbt/sbt/$init_sbt_version/jars/sbt.jar" ]] || { + command -v rsync >/dev/null 2>&1 && { + rsync -a --ignore-existing "$sbt_home/lib/local-preloaded/" "$HOME/.sbt/preloaded" + } + } +} + # Detect that we have java installed. checkJava() { local required_version="$1" @@ -200,6 +209,8 @@ copyRt() { } run() { + syncPreloaded + # no jar? download it. [[ -f "$sbt_jar" ]] || acquire_sbt_jar "$sbt_version" || { # still no jar? uh-oh. diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 12178b7c7..73878794e 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -81,6 +81,8 @@ call :checkjava call :copyrt +call :sync_preloaded + call :run %SBT_ARGS% if ERRORLEVEL 1 goto error @@ -91,15 +93,6 @@ goto end "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%sbt-launch.jar" xsbt.boot.Boot %* goto :eof -:error -@endlocal -exit /B 1 - - -:end -@endlocal -exit /B 0 - :process rem parses 1.7, 1.8, 9, etc out of java version "1.8.0_91" "%_JAVACMD%" -Xmx512M -version 2> "%TEMP%.\out.txt" @@ -148,3 +141,25 @@ if /I "%JAVA_VERSION%" GEQ "9" ( set _JAVA_OPTS=!_JAVA_OPTS! -Dscala.ext.dirs="%java9_ext%" ) exit /B 0 + +:sync_preloaded +set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org.scala-sbt\sbt\%INIT_SBT_VERSION%\jars\sbt.jar" +if /I "%JAVA_VERSION%" GEQ "8" ( + where robocopy >nul 2>nul + if %ERRORLEVEL% equ 0 ( + echo %PRELOAD_SBT_JAR% + if not exist %PRELOAD_SBT_JAR% ( + echo 'about to robocopy' + robocopy "%SBT_HOME%\..\lib\local-preloaded\" "%UserProfile%\.sbt\preloaded" + ) + ) +) +exit /B 0 + +:error +@endlocal +exit /B 1 + +:end +@endlocal +exit /B 0 From a867202ea5643c5c4959abdf5fffa6c04424c3eb Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 11 Mar 2017 14:29:58 -0500 Subject: [PATCH 242/483] Add ivy-releases to resolver --- build.sbt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 09cd19857..b8245ebfd 100644 --- a/build.sbt +++ b/build.sbt @@ -247,5 +247,6 @@ lazy val dist = (project in file("dist")) exportRepoDirectory := target.value / "lib" / "local-preloaded", conflictWarning := ConflictWarning.disable, publish := (), - publishLocal := () + publishLocal := (), + resolvers += Resolver.typesafeIvyRepo("releases") ) From e4dae9a120d8c73a3501decbb89877dd50a1f099 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 11 Mar 2017 16:34:10 -0500 Subject: [PATCH 243/483] Fix Java 9 support --- src/universal/bin/sbt-launch-lib.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 963634795..47bed1748 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -197,6 +197,7 @@ copyRt() { vlog "[copyRt] java9_rt = '$java9_rt'" if [[ ! -f "$java9_rt" ]]; then echo Copying runtime jar. + mkdir "$java9_ext" execRunner "$java_cmd" \ ${JAVA_OPTS} \ ${SBT_OPTS:-$default_sbt_opts} \ From 8f0d61ec0df51226329a6b65b5a0d2e64c98c684 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 11 Mar 2017 16:34:18 -0500 Subject: [PATCH 244/483] Clean dist --- build.sbt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.sbt b/build.sbt index b8245ebfd..d554f90da 100644 --- a/build.sbt +++ b/build.sbt @@ -32,6 +32,10 @@ val root = (project in file(".")). packageName := "sbt", version := "0.1.0", crossTarget := target.value, + clean := { + val _ = (clean in dist).value + clean.value + }, publishToSettings, sbtLaunchJarUrl := downloadUrlForVersion(sbtVersionToRelease), sbtLaunchJarLocation := { target.value / "sbt-launch.jar" }, From c7f3be3b58ee07601d01448f2ee936ccc6b8e9bf Mon Sep 17 00:00:00 2001 From: monktastic Date: Thu, 16 Mar 2017 17:01:57 -0700 Subject: [PATCH 245/483] Preserve quotes in system properties Today you cannot have spaces in system properties: $ sbt -Dfoo="bar baz" ... It passes [-Dfoo=bar] and [baz] to java (see https://github.com/sbt/sbt/issues/2787). This change allows you to do: $ sbt "-Dfoo=bar baz" which will pass ["-Dfoo=bar baz"]. And both of these two: $ sbt "-Dfoo=bar" $ sbt -Dfoo=bar still work, passing [-Dfoo=bar]. --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 47bed1748..621ae125e 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -140,7 +140,7 @@ process_args () { export PATH="$2/bin:$PATH" && shift 2 ;; - -D*) addJava "$1" && shift ;; + "-D*") addJava "$1" && shift ;; -J*) addJava "${1:2}" && shift ;; *) addResidual "$1" && shift ;; esac From 1ea1f5d52dd528bbb13f49f7e1f406c99982481f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 17 Mar 2017 16:54:04 -0400 Subject: [PATCH 246/483] mkdir -p Fixes sbt/sbt#3005 --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 621ae125e..59cf9e2a8 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -197,7 +197,7 @@ copyRt() { vlog "[copyRt] java9_rt = '$java9_rt'" if [[ ! -f "$java9_rt" ]]; then echo Copying runtime jar. - mkdir "$java9_ext" + mkdir -p "$java9_ext" execRunner "$java_cmd" \ ${JAVA_OPTS} \ ${SBT_OPTS:-$default_sbt_opts} \ From d3ca77a95d3f9c04481fd46b85490ab77acf9f81 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 7 Apr 2017 00:22:14 -0400 Subject: [PATCH 247/483] mkdir before rsync Fixes sbt/sbt#3005 --- src/universal/bin/sbt-launch-lib.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 59cf9e2a8..d3ef432f8 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -160,6 +160,7 @@ process_args () { syncPreloaded() { [[ -f "$HOME/.sbt/preloaded/org.scala-sbt/sbt/$init_sbt_version/jars/sbt.jar" ]] || { command -v rsync >/dev/null 2>&1 && { + mkdir -p "$HOME/.sbt/preloaded" rsync -a --ignore-existing "$sbt_home/lib/local-preloaded/" "$HOME/.sbt/preloaded" } } From 2fad446e6726aafe9fc28d444dc0105ad5fcf1c8 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 7 Apr 2017 00:56:55 -0400 Subject: [PATCH 248/483] Make offline installer optional --- CONTRIBUTING.md | 2 +- build.sbt | 18 ++++++++++++++---- src/universal/bin/sbt-launch-lib.bash | 9 ++++++--- src/universal/bin/sbt.bat | 6 ++++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fed9ef6e0..7597f6eb1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Steps to publish ================ ``` -$ sbt -Dsbt.build.version=1.0.0-M1 +$ sbt -Dsbt.build.version=1.0.0-M1 -Dsbt.build.offline=true > universal:publish > debian:publish > rpm:publish diff --git a/build.sbt b/build.sbt index d554f90da..8843e3c7a 100644 --- a/build.sbt +++ b/build.sbt @@ -3,6 +3,12 @@ import _root_.bintray.InternalBintrayKeys._ import _root_.bintray.{BintrayRepo, Bintray} import NativePackagerHelper._ +lazy val sbtOfflineInstall = + sys.props.getOrElse("sbt.build.offline", sys.env.getOrElse("sbt.build.offline", "false")) match { + case "true" => true + case "1" => true + case _ => false + } lazy val sbtVersionToRelease = sys.props.getOrElse("sbt.build.version", sys.env.getOrElse("sbt.build.version", { sys.error("-Dsbt.build.version must be set") })) @@ -119,10 +125,14 @@ val root = (project in file(".")). val rtExportJar = (packageBin in Compile in java9rtexport).value Seq(launchJar -> "bin/sbt-launch.jar", rtExportJar -> "bin/java9-rt-export.jar") }, - mappings in Universal ++= { - val _ = (exportRepo in dist).value - directory((target in dist).value / "lib") - }, + mappings in Universal ++= (Def.taskDyn { + if (sbtOfflineInstall) + Def.task { + val _ = (exportRepo in dist).value + directory((target in dist).value / "lib") + } + else Def.task { Seq[(File, String)]() } + }).value, stage in Universal := { val old = (stage in Universal).value val sd = (stagingDirectory in Universal).value diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index d3ef432f8..7ef516bae 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -159,9 +159,12 @@ process_args () { syncPreloaded() { [[ -f "$HOME/.sbt/preloaded/org.scala-sbt/sbt/$init_sbt_version/jars/sbt.jar" ]] || { - command -v rsync >/dev/null 2>&1 && { - mkdir -p "$HOME/.sbt/preloaded" - rsync -a --ignore-existing "$sbt_home/lib/local-preloaded/" "$HOME/.sbt/preloaded" + # lib/local-preloaded exists (This is optional) + [[ -f "$sbt_home/lib/local-preloaded/" ]] && { + command -v rsync >/dev/null 2>&1 && { + mkdir -p "$HOME/.sbt/preloaded" + rsync -a --ignore-existing "$sbt_home/lib/local-preloaded/" "$HOME/.sbt/preloaded" + } } } } diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 73878794e..dd85d29bf 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -149,8 +149,10 @@ if /I "%JAVA_VERSION%" GEQ "8" ( if %ERRORLEVEL% equ 0 ( echo %PRELOAD_SBT_JAR% if not exist %PRELOAD_SBT_JAR% ( - echo 'about to robocopy' - robocopy "%SBT_HOME%\..\lib\local-preloaded\" "%UserProfile%\.sbt\preloaded" + if exist "%SBT_HOME%\..\lib\local-preloaded\" ( + echo 'about to robocopy' + robocopy "%SBT_HOME%\..\lib\local-preloaded\" "%UserProfile%\.sbt\preloaded" + ) ) ) ) From 04bc5a9dd294f572e315a554001542ccc6455396 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 7 Apr 2017 01:40:05 -0400 Subject: [PATCH 249/483] Publish full installers to lightbend organization Offline installation exceeds 50MB file limit for OSS organization. --- build.sbt | 57 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/build.sbt b/build.sbt index 8843e3c7a..312a90dc3 100644 --- a/build.sbt +++ b/build.sbt @@ -18,13 +18,15 @@ val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") val moduleID = (organization) apply { (o) => ModuleID(o, "sbt", sbtVersionToRelease) } +lazy val bintrayDebianUrl = settingKey[String]("API point for Debian packages") +lazy val bintrayDebianExperimentalUrl = settingKey[String]("API point for Debian experimental packages") +lazy val bintrayRpmUrl = settingKey[String]("API point for RPM packages") +lazy val bintrayRpmExperimentalUrl = settingKey[String]("API point for RPM experimental packages") +lazy val bintrayGenericPackagesUrl = settingKey[String]("API point for generic packages") +lazy val bintrayTripple = settingKey[(String, String, String)]("id, url, and pattern") + val bintrayLinuxPattern = "[module]/[revision]/[module]-[revision].[ext]" val bintrayGenericPattern = "[module]/[revision]/[module]/[revision]/[module]-[revision].[ext]" -val bintrayDebianUrl = "https://api.bintray.com/content/sbt/debian/" -val bintrayDebianExperimentalUrl = "https://api.bintray.com/content/sbt/debian-experimental/" -val bintrayRpmUrl = "https://api.bintray.com/content/sbt/rpm/" -val bintrayRpmExperimentalUrl = "https://api.bintray.com/content/sbt/rpm-experimental/" -val bintrayGenericPackagesUrl = "https://api.bintray.com/content/sbt/native-packages/" val bintrayReleaseAllStaged = TaskKey[Unit]("bintray-release-all-staged", "Release all staged artifacts on bintray.") val windowsBuildId = settingKey[Int]("build id for Windows installer") @@ -173,32 +175,41 @@ def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching( case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" } -def makePublishTo(id: String, url: String, pattern: String): Setting[_] = { - publishTo := { - val resolver = Resolver.url(id, new URL(url))(Patterns(pattern)) - Some(resolver) - } -} - def makePublishToForConfig(config: Configuration) = { val v = sbtVersionToRelease - val (id, url, pattern) = - config.name match { - case Debian.name if isExperimental => ("debian-experimental", bintrayDebianExperimentalUrl, bintrayLinuxPattern) - case Debian.name => ("debian", bintrayDebianUrl, bintrayLinuxPattern) - case Rpm.name if isExperimental => ("rpm-experimental", bintrayRpmExperimentalUrl, bintrayLinuxPattern) - case Rpm.name => ("rpm", bintrayRpmUrl, bintrayLinuxPattern) - case _ => ("native-packages", bintrayGenericPackagesUrl, bintrayGenericPattern) - } + // Add the publish to and ensure global resolvers has the resolver we just configured. inConfig(config)(Seq( - bintrayOrganization := Some("sbt"), - bintrayRepository := id, + bintrayOrganization := { + // offline installation exceeds 50MB file limit for OSS organization + if (sbtOfflineInstall) Some("lightbend") + else Some("sbt") + }, + bintrayRepository := bintrayTripple.value._1, bintrayRepo := Bintray.cachedRepo(bintrayEnsureCredentials.value, bintrayOrganization.value, bintrayRepository.value), bintrayPackage := "sbt", - makePublishTo(id, url, pattern), + + bintrayDebianUrl := s"https://api.bintray.com/content/${bintrayOrganization.value.get}/debian/", + bintrayDebianExperimentalUrl := s"https://api.bintray.com/content/${bintrayOrganization.value.get}/debian-experimental/", + bintrayRpmUrl := s"https://api.bintray.com/content/${bintrayOrganization.value.get}/rpm/", + bintrayRpmExperimentalUrl := s"https://api.bintray.com/content/${bintrayOrganization.value.get}/rpm-experimental/", + bintrayGenericPackagesUrl := s"https://api.bintray.com/content/${bintrayOrganization.value.get}/native-packages/", + bintrayTripple := { + config.name match { + case Debian.name if isExperimental => ("debian-experimental", bintrayDebianExperimentalUrl.value, bintrayLinuxPattern) + case Debian.name => ("debian", bintrayDebianUrl.value, bintrayLinuxPattern) + case Rpm.name if isExperimental => ("rpm-experimental", bintrayRpmExperimentalUrl.value, bintrayLinuxPattern) + case Rpm.name => ("rpm", bintrayRpmUrl.value, bintrayLinuxPattern) + case _ => ("native-packages", bintrayGenericPackagesUrl.value, bintrayGenericPattern) + } + }, + publishTo := { + val (id, url, pattern) = bintrayTripple.value + val resolver = Resolver.url(id, new URL(url))(Patterns(pattern)) + Some(resolver) + }, bintrayReleaseAllStaged := bintrayRelease(bintrayRepo.value, bintrayPackage.value, version.value, sLog.value) // Uncomment to release right after publishing // publish <<= (publish, bintrayRepo, bintrayPackage, version, sLog) apply { (publish, bintrayRepo, bintrayPackage, version, sLog) => From 0f8b3b0ffb29dfb035bc3422b79cfef004ac3b9a Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 7 Apr 2017 04:13:13 -0400 Subject: [PATCH 250/483] Fix bash script --- build.sbt | 4 ++-- src/universal/bin/sbt-launch-lib.bash | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 312a90dc3..b2946b37c 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ import _root_.bintray.{BintrayRepo, Bintray} import NativePackagerHelper._ lazy val sbtOfflineInstall = - sys.props.getOrElse("sbt.build.offline", sys.env.getOrElse("sbt.build.offline", "false")) match { + sys.props.getOrElse("sbt.build.offline", sys.env.getOrElse("sbt.build.offline", "true")) match { case "true" => true case "1" => true case _ => false @@ -182,7 +182,7 @@ def makePublishToForConfig(config: Configuration) = { inConfig(config)(Seq( bintrayOrganization := { // offline installation exceeds 50MB file limit for OSS organization - if (sbtOfflineInstall) Some("lightbend") + if (sbtOfflineInstall) Some("sbt") else Some("sbt") }, bintrayRepository := bintrayTripple.value._1, diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 7ef516bae..cb7a66a46 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -160,7 +160,7 @@ process_args () { syncPreloaded() { [[ -f "$HOME/.sbt/preloaded/org.scala-sbt/sbt/$init_sbt_version/jars/sbt.jar" ]] || { # lib/local-preloaded exists (This is optional) - [[ -f "$sbt_home/lib/local-preloaded/" ]] && { + [[ -d "$sbt_home/lib/local-preloaded/" ]] && { command -v rsync >/dev/null 2>&1 && { mkdir -p "$HOME/.sbt/preloaded" rsync -a --ignore-existing "$sbt_home/lib/local-preloaded/" "$HOME/.sbt/preloaded" From 70ad35ebb6a9ce7372b43909c01dff96c16b53b4 Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Fri, 7 Apr 2017 22:13:12 -0700 Subject: [PATCH 251/483] Minor Windows fixes --- build.sbt | 3 ++- src/universal/bin/sbt.bat | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index b2946b37c..53c5f8b3c 100644 --- a/build.sbt +++ b/build.sbt @@ -102,11 +102,12 @@ val root = (project in file(".")). rpmProvides := Seq("sbt"), // WINDOWS SPECIFIC - windowsBuildId := 1, + windowsBuildId := 0, version in Windows := { val bid = windowsBuildId.value val sv = sbtVersionToRelease (sv split "[^\\d]" filterNot (_.isEmpty)) match { + case Array(major,minor,bugfix, _*) if bid == 0 => Seq(major, minor, bugfix) mkString "." case Array(major,minor,bugfix, _*) => Seq(major, minor, bugfix, bid.toString) mkString "." case Array(major,minor) => Seq(major, minor, "0", bid.toString) mkString "." case Array(major) => Seq(major, "0", "0", bid.toString) mkString "." diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index dd85d29bf..0bf79a0c7 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -11,6 +11,7 @@ @echo off set SBT_HOME=%~dp0 +set SBT_ARGS= rem FIRST we load the config file of extra options. set FN=%SBT_HOME%\..\conf\sbtconfig.txt @@ -95,19 +96,18 @@ goto :eof :process rem parses 1.7, 1.8, 9, etc out of java version "1.8.0_91" -"%_JAVACMD%" -Xmx512M -version 2> "%TEMP%.\out.txt" +"%_JAVACMD%" -Xmx512M -version 2> "%TEMP%\out.txt" set JAVA_VERSION=0 -findstr /c:"version \"9" "%TEMP%.\out.txt" +>nul findstr /c:"version \"9" "%TEMP%\out.txt" if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=9) -findstr /c:"version \"1.8" "%TEMP%.\out.txt" +>nul findstr /c:"version \"1.8" "%TEMP%\out.txt" if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.8) -findstr /c:"version \"1.7" "%TEMP%.\out.txt" +>nul findstr /c:"version \"1.7" "%TEMP%\out.txt" if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.7) -findstr /c:"version \"1.6" "%TEMP%.\out.txt" +>nul findstr /c:"version \"1.6" "%TEMP%\out.txt" if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.6) -findstr /c:"version \"1.5" "%TEMP%.\out.txt" +>nul findstr /c:"version \"1.5" "%TEMP%\out.txt" if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.5) - exit /B 0 :checkjava From bd18a0c2c6967adab4fdb33bc4376085ee9ddcdf Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Sat, 8 Apr 2017 23:35:20 -0700 Subject: [PATCH 252/483] Fix Windows script --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 0bf79a0c7..1f72b990e 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -127,7 +127,7 @@ exit /B 1 :copyrt if /I "%JAVA_VERSION%" GEQ "9" ( - set rtexport=%SBT_HOME%java9-rt-export.jar + set rtexport="%SBT_HOME%java9-rt-export.jar" "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "%rtexport%" --rt-ext-dir > "%TEMP%.\rtext.txt" set /p java9_ext= < "%TEMP%.\rtext.txt" From 4043810dda19ba5cfb05550aa729436ca64573db Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Sun, 9 Apr 2017 07:37:42 -0700 Subject: [PATCH 253/483] Fix installer name --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index 53c5f8b3c..4289788e6 100644 --- a/build.sbt +++ b/build.sbt @@ -181,6 +181,7 @@ def makePublishToForConfig(config: Configuration) = { // Add the publish to and ensure global resolvers has the resolver we just configured. inConfig(config)(Seq( + name := "sbt", bintrayOrganization := { // offline installation exceeds 50MB file limit for OSS organization if (sbtOfflineInstall) Some("sbt") From b2b84cc052cea78d17fab7ae4b27a6d71402a748 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 12 Apr 2017 05:20:00 -0400 Subject: [PATCH 254/483] Remove RPM requirements Fixes #151 Ref #144, #62 We are removing RPM requirements for JDK because it's not possible to reliably specify JDK 1.8 across different distros. --- build.sbt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 4289788e6..3ece5978a 100644 --- a/build.sbt +++ b/build.sbt @@ -98,7 +98,11 @@ val root = (project in file(".")). rpmVendor := "lightbend", rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"), rpmLicense := Some("BSD"), - rpmRequirements := Seq("java-1.8.0-devel"), + // This is intentionally empty. java-devel could bring in JDK 9-ea on Fedora, + // and java-1.8.0-devel doesn't work on CentOS 6 and 7. + // https://github.com/sbt/sbt-launcher-package/issues/151 + // https://github.com/elastic/logstash/issues/6275#issuecomment-261359933 + rpmRequirements := Seq(), rpmProvides := Seq("sbt"), // WINDOWS SPECIFIC From 226c34a7bf6b7d2d60f73492bcae959aceb50935 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 12 Apr 2017 07:53:43 -0400 Subject: [PATCH 255/483] Replace realpath with something Mac compat Mac by default doesn't have realpath(1). This replaces it with an equivalent bash script, so we can reduce script replacements on Homebrew. Fixes #149 --- src/universal/bin/sbt-launch-lib.bash | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index cb7a66a46..3e2c2b450 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -12,10 +12,22 @@ declare -a scalac_args declare -a sbt_commands declare java_cmd=java declare java_version -declare -r sbt_bin_dir="$(dirname "$(realpath "$0")")" -declare -r sbt_home="$(dirname "$sbt_bin_dir")" declare init_sbt_version= +declare SCRIPT=$0 +while [ -h "$SCRIPT" ] ; do + ls=$(ls -ld "$SCRIPT") + # Drop everything prior to -> + link=$(expr "$ls" : '.*-> \(.*\)$') + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=$(dirname "$SCRIPT")/"$link" + fi +done +declare -r sbt_bin_dir="$(dirname "$SCRIPT")" +declare -r sbt_home="$(dirname "$sbt_bin_dir")" + echoerr () { echo 1>&2 "$@" } From 36e8246825df45cacc537e5e2a02935419c024da Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 12 Apr 2017 07:57:27 -0400 Subject: [PATCH 256/483] Workaround for brew test sbt brew test sbt doesn't detect java version correctly. This change makes the script a bit more safer. Fixes #150 --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index cb7a66a46..d626cf7f4 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -193,7 +193,7 @@ checkJava() { } copyRt() { - if [[ "$java_version" > "8" ]]; then + if [[ "$java_version" == "9" ]]; then rtexport=$(rt_export_file) java9_ext=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ -jar "$rtexport" --rt-ext-dir) From 70c725fc3bfb1be84ad69d34f3be764a5f0cdaed Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 12 Apr 2017 23:41:18 -0400 Subject: [PATCH 257/483] workaround sbt-native-packager issue --- build.sbt | 2 ++ project/build.properties | 3 ++- project/plugins.sbt | 2 +- src/debian/changelog | 8 ++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 3ece5978a..58c8d6c5a 100644 --- a/build.sbt +++ b/build.sbt @@ -2,6 +2,7 @@ import scala.util.control.Exception.catching import _root_.bintray.InternalBintrayKeys._ import _root_.bintray.{BintrayRepo, Bintray} import NativePackagerHelper._ +import com.typesafe.sbt.packager.SettingsHelper._ lazy val sbtOfflineInstall = sys.props.getOrElse("sbt.build.offline", sys.env.getOrElse("sbt.build.offline", "true")) match { @@ -86,6 +87,7 @@ val root = (project in file(".")). ) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs() }, debianChangelog in Debian := { Some(sourceDirectory.value / "debian" / "changelog") }, + addPackage(Debian, packageBin in Debian, "deb"), // RPM SPECIFIC version in Rpm := { val stable = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".") diff --git a/project/build.properties b/project/build.properties index 27e88aa11..6818e9c44 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1,2 @@ -sbt.version=0.13.13 +sbt.version=0.13.15 + diff --git a/project/plugins.sbt b/project/plugins.sbt index 74869e0ed..8c212a981 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.4") +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0-M8") libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.10" addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0") addSbtPlugin("com.eed3si9n" % "sbt-export-repo" % "0.1.0") diff --git a/src/debian/changelog b/src/debian/changelog index 810742dc3..bfd730ff9 100644 --- a/src/debian/changelog +++ b/src/debian/changelog @@ -1,3 +1,11 @@ +sbt (0.13.15) stable; urgency=low + + * sbt 0.13.15 removes the Maven version range when possible. + * Adds preliminary compatibility with JDK 9. Using this requires 0.13.15+ launcher. #2951 by @retronym + * Adds "local-preloaded" repository for offline installation + + -- Eugene Yokota Mon, 10 Apr 2017 00:00:00 +0000 + sbt (0.13.13) stable; urgency=low * The `new` command, which helps creating new build definitions. From c86f64b451502dbb50e420db8f5a35e1129fc757 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 18 Apr 2017 13:28:12 -0400 Subject: [PATCH 258/483] support for packaging sbt 1 --- build.sbt | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 58c8d6c5a..22eb6b40c 100644 --- a/build.sbt +++ b/build.sbt @@ -178,6 +178,7 @@ def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching( case Array(0, 11, 3, _*) => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.11.3-2/sbt-launch.jar" case Array(0, 11, x, _*) if x >= 3 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case Array(0, y, _*) if y >= 12 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" + case Array(1, _, _*) if v contains ("-20") => "http://repo.scala-sbt.org/scalasbt/maven-snapshots/org/scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case Array(1, _, _*) => "http://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" } @@ -239,14 +240,22 @@ def bintrayRelease(repo: BintrayRepo, pkg: String, version: String, log: Logger) lazy val scala210 = "2.10.6" -lazy val scala212 = "2.12.1" +lazy val scala212 = "2.12.2" lazy val scala210Jline = "org.scala-lang" % "jline" % scala210 -lazy val jansi = "org.fusesource.jansi" % "jansi" % "1.4" +lazy val jansi = { + if (sbtVersionToRelease startsWith "1.") "org.fusesource.jansi" % "jansi" % "1.4" + else "org.fusesource.jansi" % "jansi" % "1.4" +} lazy val scala212Jline = "jline" % "jline" % "2.14.1" lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6" lazy val scala212Compiler = "org.scala-lang" % "scala-compiler" % scala212 lazy val sbtActual = "org.scala-sbt" % "sbt" % sbtVersionToRelease +lazy val sbt013ExtraDeps = { + if (sbtVersionToRelease startsWith "0.13.") Seq(scala210Jline) + else Seq() +} + def downloadUrl(uri: URI, out: File): Unit = { import dispatch.classic._ @@ -262,11 +271,24 @@ lazy val dist = (project in file("dist")) .enablePlugins(ExportRepoPlugin) .settings( name := "dist", - scalaVersion := scala210, - libraryDependencies ++= Seq(sbtActual, scala210Jline, jansi, scala212Compiler, scala212Jline, scala212Xml), + scalaVersion := { + if (sbtVersionToRelease startsWith "0.13.") scala210 + else scala212 + }, + libraryDependencies ++= Seq(sbtActual, jansi, scala212Compiler, scala212Jline, scala212Xml) ++ sbt013ExtraDeps, exportRepo := { val old = exportRepo.value sbtVersionToRelease match { + case v if v.startsWith("1.0.") => + val zincBase = exportRepoDirectory.value / "org.scala-sbt" / "zinc_2.12" + val zincVersion = (zincBase * DirectoryFilter).get.head.getName + val utilBase = exportRepoDirectory.value / "org.scala-sbt" / "util-logging_2.12" + val utilVersion = (utilBase * DirectoryFilter).get.head.getName + val outbase = exportRepoDirectory.value / "org" / "scala-sbt" / "compiler-interface" / zincVersion + val uribase = s"https://oss.sonatype.org/content/repositories/public/org/scala-sbt/compiler-interface/$zincVersion/" + downloadUrl(uri(uribase + s"compiler-interface-${zincVersion}.jar"), outbase / s"compiler-interface-${zincVersion}.jar") + downloadUrl(uri(uribase + s"compiler-interface-${zincVersion}-sources.jar"), outbase / s"compiler-interface-${zincVersion}-sources.jar") + downloadUrl(uri(uribase + s"compiler-interface-${zincVersion}.pom"), outbase / s"compiler-interface-${zincVersion}.pom") case v if v.startsWith("0.13.") => val outbase = exportRepoDirectory.value / "org.scala-sbt" / "compiler-interface" / v val uribase = s"https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compiler-interface/$v/" From 58cf5f95ca129db69edeb710298e5a750d6bd097 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 26 Apr 2017 19:25:16 -0400 Subject: [PATCH 259/483] Remove Java requirements for Debian/Ubuntu package Ref sbt/sbt#2931 Ref sbt/sbt#3105 Requiring `"openjdk-8-jdk"` prevents sbt 0.13.15 update on Ubuntu 14.04 LTS "Trusty Tahr." Since there seems to be no reasonable way to depend on JDK 6, 7, or 8 without breaking some distro or use case, I'm going to remove the requirement here. --- build.sbt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 22eb6b40c..9cdb405db 100644 --- a/build.sbt +++ b/build.sbt @@ -78,7 +78,9 @@ val root = (project in file(".")). }, // DEBIAN SPECIFIC version in Debian := sbtVersionToRelease, - debianPackageDependencies in Debian ++= Seq("openjdk-8-jdk", "bash (>= 3.2)"), + // Used to have "openjdk-8-jdk" but that doesn't work on Ubuntu 14.04 https://github.com/sbt/sbt/issues/3105 + // before that we had java6-runtime-headless" and that was pulling in JDK9 on Ubuntu 16.04 https://github.com/sbt/sbt/issues/2931 + debianPackageDependencies in Debian ++= Seq("bash (>= 3.2)"), debianPackageRecommends in Debian += "git", linuxPackageMappings in Debian += { val bd = sourceDirectory.value From c35a487c9ecf111d3a338b50f10b057c27f07114 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 26 Apr 2017 20:08:26 -0400 Subject: [PATCH 260/483] debian build id --- build.sbt | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index 9cdb405db..09dbbfa9e 100644 --- a/build.sbt +++ b/build.sbt @@ -30,6 +30,7 @@ val bintrayLinuxPattern = "[module]/[revision]/[module]-[revision].[ext]" val bintrayGenericPattern = "[module]/[revision]/[module]/[revision]/[module]-[revision].[ext]" val bintrayReleaseAllStaged = TaskKey[Unit]("bintray-release-all-staged", "Release all staged artifacts on bintray.") val windowsBuildId = settingKey[Int]("build id for Windows installer") +val debianBuildId = settingKey[Int]("build id for Debian") // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. val root = (project in file(".")). @@ -77,7 +78,11 @@ val root = (project in file(".")). } yield link }, // DEBIAN SPECIFIC - version in Debian := sbtVersionToRelease, + version in Debian := { + if (debianBuildId.value == 0) sbtVersionToRelease + else sbtVersionToRelease + "." + debianBuildId.value + }, + debianBuildId := 2, // 0 // Used to have "openjdk-8-jdk" but that doesn't work on Ubuntu 14.04 https://github.com/sbt/sbt/issues/3105 // before that we had java6-runtime-headless" and that was pulling in JDK9 on Ubuntu 16.04 https://github.com/sbt/sbt/issues/2931 debianPackageDependencies in Debian ++= Seq("bash (>= 3.2)"), @@ -92,13 +97,15 @@ val root = (project in file(".")). addPackage(Debian, packageBin in Debian, "deb"), // RPM SPECIFIC version in Rpm := { - val stable = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".") + val stable0 = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".") + val stable = if (rpmRelease.value == "0") stable0 + else stable0 + "." + rpmRelease.value if (isExperimental) ((sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty)).toList match { case List(a, b, c, d) => List(0, 99, c, d).mkString(".") }) else stable }, - rpmRelease := "1", + rpmRelease := "2", rpmVendor := "lightbend", rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"), rpmLicense := Some("BSD"), @@ -155,13 +162,22 @@ val root = (project in file(".")). }, // Misccelaneous publishing stuff... - projectID in Debian := moduleID.value, + projectID in Debian := { + val m = moduleID.value + m.copy(revision = (version in Debian).value) + }, projectID in Windows := { val m = moduleID.value m.copy(revision = (version in Windows).value) }, - projectID in Rpm := moduleID.value, - projectID in Universal := moduleID.value + projectID in Rpm := { + val m = moduleID.value + m.copy(revision = (version in Rpm).value) + }, + projectID in Universal := { + val m = moduleID.value + m.copy(revision = (version in Universal).value) + } ) lazy val java9rtexport = (project in file("java9-rt-export")) From ef8011df0d4f6eaecbf7bfa651e001fb7853b29e Mon Sep 17 00:00:00 2001 From: tksk Date: Fri, 28 Apr 2017 02:26:49 +0900 Subject: [PATCH 261/483] fix: least java version check for syncing "preloaded" --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 1f72b990e..3625438d9 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -144,7 +144,7 @@ exit /B 0 :sync_preloaded set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org.scala-sbt\sbt\%INIT_SBT_VERSION%\jars\sbt.jar" -if /I "%JAVA_VERSION%" GEQ "8" ( +if /I "%JAVA_VERSION%" GEQ "1.8" ( where robocopy >nul 2>nul if %ERRORLEVEL% equ 0 ( echo %PRELOAD_SBT_JAR% From fb30f81f8961afefb69b97a7616e476a97637fed Mon Sep 17 00:00:00 2001 From: tksk Date: Fri, 28 Apr 2017 02:27:48 +0900 Subject: [PATCH 262/483] fix: recursive copying needs "/E" option --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 3625438d9..bf447dc98 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -151,7 +151,7 @@ if /I "%JAVA_VERSION%" GEQ "1.8" ( if not exist %PRELOAD_SBT_JAR% ( if exist "%SBT_HOME%\..\lib\local-preloaded\" ( echo 'about to robocopy' - robocopy "%SBT_HOME%\..\lib\local-preloaded\" "%UserProfile%\.sbt\preloaded" + robocopy "%SBT_HOME%\..\lib\local-preloaded" "%UserProfile%\.sbt\preloaded" /E ) ) ) From ab3de739d722b1b9c8f38e3321f3d1e8692be332 Mon Sep 17 00:00:00 2001 From: tksk Date: Fri, 28 Apr 2017 02:28:16 +0900 Subject: [PATCH 263/483] detect $init_sbt_version --- src/universal/bin/sbt-launch-lib.bash | 4 ++++ src/universal/bin/sbt.bat | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 2264868a2..04824bf19 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -170,6 +170,10 @@ process_args () { } syncPreloaded() { + if [[ "$init_sbt_version" == "" ]]; then + # FIXME: better $init_sbt_version detection + init_sbt_version="$(ls -1 "$sbt_home/lib/local-preloaded/org.scala-sbt/sbt/")" + fi [[ -f "$HOME/.sbt/preloaded/org.scala-sbt/sbt/$init_sbt_version/jars/sbt.jar" ]] || { # lib/local-preloaded exists (This is optional) [[ -d "$sbt_home/lib/local-preloaded/" ]] && { diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index bf447dc98..85f5f0951 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -143,6 +143,12 @@ if /I "%JAVA_VERSION%" GEQ "9" ( exit /B 0 :sync_preloaded +if "%INIT_SBT_VERSION%"=="" ( + rem FIXME: better %INIT_SBT_VERSION% detection + FOR /F "tokens=* USEBACKQ" %%F IN (`dir /b "%SBT_HOME%\..\lib\local-preloaded\org.scala-sbt\sbt" /B`) DO ( + SET INIT_SBT_VERSION=%%F + ) +) set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org.scala-sbt\sbt\%INIT_SBT_VERSION%\jars\sbt.jar" if /I "%JAVA_VERSION%" GEQ "1.8" ( where robocopy >nul 2>nul From a602ed760eb1ad0e9af6eca176443411fc47ba1a Mon Sep 17 00:00:00 2001 From: tksk Date: Fri, 5 May 2017 00:29:52 +0900 Subject: [PATCH 264/483] Fix missing placeholder `INIT_SBT_VERSION' --- src/universal/bin/sbt.bat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 85f5f0951..884248abc 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -53,6 +53,8 @@ rem We use the value of the JAVA_OPTS environment variable if defined, rather th set _JAVA_OPTS=%JAVA_OPTS% if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% +set INIT_SBT_VERSION= + :args_loop if "%~1" == "" goto args_end From b66b0ff7f69fc916e13ca098eb879ad0f374223e Mon Sep 17 00:00:00 2001 From: tksk Date: Fri, 5 May 2017 15:45:20 +0900 Subject: [PATCH 265/483] Fix: multiple execution of universal:stage task produces duplicated version strings --- build.sbt | 6 ++++-- src/universal/bin/sbt-launch-lib.bash | 2 +- src/universal/bin/sbt.bat | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 09dbbfa9e..90b7f7921 100644 --- a/build.sbt +++ b/build.sbt @@ -155,9 +155,11 @@ val root = (project in file(".")). val old = (stage in Universal).value val sd = (stagingDirectory in Universal).value val x = IO.read(sd / "bin" / "sbt-launch-lib.bash") - IO.write(sd / "bin" / "sbt-launch-lib.bash", x.replaceAllLiterally("declare init_sbt_version=", s"declare init_sbt_version=$sbtVersionToRelease")) + IO.write(sd / "bin" / "sbt-launch-lib.bash", x.replaceAllLiterally( + "declare init_sbt_version=_to_be_replaced", s"declare init_sbt_version=$sbtVersionToRelease")) val y = IO.read(sd / "bin" / "sbt.bat") - IO.write(sd / "bin" / "sbt.bat", y.replaceAllLiterally("set INIT_SBT_VERSION=", s"set INIT_SBT_VERSION=$sbtVersionToRelease")) + IO.write(sd / "bin" / "sbt.bat", y.replaceAllLiterally( + "set INIT_SBT_VERSION=_TO_BE_REPLACED", s"set INIT_SBT_VERSION=$sbtVersionToRelease")) old }, diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 04824bf19..59d8af3d6 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -12,7 +12,7 @@ declare -a scalac_args declare -a sbt_commands declare java_cmd=java declare java_version -declare init_sbt_version= +declare init_sbt_version=_to_be_replaced declare SCRIPT=$0 while [ -h "$SCRIPT" ] ; do diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 884248abc..6035dc357 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -53,7 +53,7 @@ rem We use the value of the JAVA_OPTS environment variable if defined, rather th set _JAVA_OPTS=%JAVA_OPTS% if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% -set INIT_SBT_VERSION= +set INIT_SBT_VERSION=_TO_BE_REPLACED :args_loop if "%~1" == "" goto args_end From 12e030b49aea5cccb1eee87b696f1c2515d5d57f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 10 May 2017 13:33:07 -0400 Subject: [PATCH 266/483] configure the public key ring --- build.sbt | 2 ++ project/plugins.sbt | 1 + 2 files changed, 3 insertions(+) diff --git a/build.sbt b/build.sbt index 09dbbfa9e..f9ea3b55f 100644 --- a/build.sbt +++ b/build.sbt @@ -46,6 +46,8 @@ val root = (project in file(".")). val _ = (clean in dist).value clean.value }, + pgpSecretRing := file(s"""${sys.props("user.home")}""") / ".ssh" / "scalasbt.key", + pgpPublicRing := file(s"""${sys.props("user.home")}""") / ".ssh" / "scalasbt.pub", publishToSettings, sbtLaunchJarUrl := downloadUrlForVersion(sbtVersionToRelease), sbtLaunchJarLocation := { target.value / "sbt-launch.jar" }, diff --git a/project/plugins.sbt b/project/plugins.sbt index 8c212a981..84b3b6e20 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,3 +2,4 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0-M8") libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.10" addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0") addSbtPlugin("com.eed3si9n" % "sbt-export-repo" % "0.1.0") +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.1") From 95f970634a8d04787049ecb15e4285c2ac6198a3 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 10 May 2017 14:07:04 -0400 Subject: [PATCH 267/483] Post installation script to run sbt about --- build.sbt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build.sbt b/build.sbt index f9ea3b55f..13372eb30 100644 --- a/build.sbt +++ b/build.sbt @@ -3,6 +3,7 @@ import _root_.bintray.InternalBintrayKeys._ import _root_.bintray.{BintrayRepo, Bintray} import NativePackagerHelper._ import com.typesafe.sbt.packager.SettingsHelper._ +import DebianConstants._ lazy val sbtOfflineInstall = sys.props.getOrElse("sbt.build.offline", sys.env.getOrElse("sbt.build.offline", "true")) match { @@ -97,6 +98,9 @@ val root = (project in file(".")). }, debianChangelog in Debian := { Some(sourceDirectory.value / "debian" / "changelog") }, addPackage(Debian, packageBin in Debian, "deb"), + maintainerScripts in Debian := maintainerScriptsAppend((maintainerScripts in Debian).value)( + Postinst -> s"/usr/share/sbt/bin/sbt about" + ), // RPM SPECIFIC version in Rpm := { val stable0 = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".") @@ -117,6 +121,9 @@ val root = (project in file(".")). // https://github.com/elastic/logstash/issues/6275#issuecomment-261359933 rpmRequirements := Seq(), rpmProvides := Seq("sbt"), + maintainerScripts in Rpm := maintainerScriptsAppend((maintainerScripts in Rpm).value)( + RpmConstants.Post -> s"/usr/share/sbt/bin/sbt about" + ), // WINDOWS SPECIFIC windowsBuildId := 0, From 080bd0d92f7e46127e3ba9b0fd038a8d0aa2f032 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 11 May 2017 00:11:11 -0400 Subject: [PATCH 268/483] package signer --- build.sbt | 12 ++++--- project/PackageSignerPlugin.scala | 60 +++++++++++++++++++++++++++++++ src/debian/changelog | 3 +- 3 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 project/PackageSignerPlugin.scala diff --git a/build.sbt b/build.sbt index 13372eb30..40149bbcb 100644 --- a/build.sbt +++ b/build.sbt @@ -7,9 +7,9 @@ import DebianConstants._ lazy val sbtOfflineInstall = sys.props.getOrElse("sbt.build.offline", sys.env.getOrElse("sbt.build.offline", "true")) match { - case "true" => true - case "1" => true - case _ => false + case "true" | "1" => true + case "false" | "0" => false + case _ => false } lazy val sbtVersionToRelease = sys.props.getOrElse("sbt.build.version", sys.env.getOrElse("sbt.build.version", { sys.error("-Dsbt.build.version must be set") @@ -47,6 +47,8 @@ val root = (project in file(".")). val _ = (clean in dist).value clean.value }, + useGpg := true, + usePgpKeyHex("642AC823"), pgpSecretRing := file(s"""${sys.props("user.home")}""") / ".ssh" / "scalasbt.key", pgpPublicRing := file(s"""${sys.props("user.home")}""") / ".ssh" / "scalasbt.pub", publishToSettings, @@ -85,7 +87,7 @@ val root = (project in file(".")). if (debianBuildId.value == 0) sbtVersionToRelease else sbtVersionToRelease + "." + debianBuildId.value }, - debianBuildId := 2, // 0 + debianBuildId := 3, // 0 // Used to have "openjdk-8-jdk" but that doesn't work on Ubuntu 14.04 https://github.com/sbt/sbt/issues/3105 // before that we had java6-runtime-headless" and that was pulling in JDK9 on Ubuntu 16.04 https://github.com/sbt/sbt/issues/2931 debianPackageDependencies in Debian ++= Seq("bash (>= 3.2)"), @@ -111,7 +113,7 @@ val root = (project in file(".")). }) else stable }, - rpmRelease := "2", + rpmRelease := "3", rpmVendor := "lightbend", rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"), rpmLicense := Some("BSD"), diff --git a/project/PackageSignerPlugin.scala b/project/PackageSignerPlugin.scala new file mode 100644 index 000000000..719aa322f --- /dev/null +++ b/project/PackageSignerPlugin.scala @@ -0,0 +1,60 @@ +import sbt._ +import Keys._ +import com.typesafe.sbt.SbtPgp +import com.typesafe.sbt.packager.universal.{ UniversalPlugin, UniversalDeployPlugin } +import com.typesafe.sbt.packager.debian.{ DebianPlugin, DebianDeployPlugin } +import com.typesafe.sbt.packager.rpm.{ RpmPlugin, RpmDeployPlugin } +import com.typesafe.sbt.pgp.gpgExtension + +object PackageSignerPlugin extends sbt.AutoPlugin { + override def trigger = allRequirements + override def requires = SbtPgp && UniversalDeployPlugin && DebianDeployPlugin && RpmDeployPlugin + + import com.typesafe.sbt.pgp.PgpKeys._ + import UniversalPlugin.autoImport._ + import DebianPlugin.autoImport._ + import RpmPlugin.autoImport._ + + override def projectSettings: Seq[Setting[_]] = + inConfig(Universal)(packageSignerSettings) ++ + inConfig(Debian)(packageSignerSettings) ++ + inConfig(Rpm)(packageSignerSettings) + + def subExtension(art: Artifact, ext: String): Artifact = + art.copy(extension = ext) + + def packageSignerSettings: Seq[Setting[_]] = Seq( + signedArtifacts := { + val artifacts = packagedArtifacts.value + val r = pgpSigner.value + val skipZ = (skip in pgpSigner).value + val s = streams.value + if (!skipZ) { + artifacts flatMap { case (art, f) => + Seq(art -> f, + subExtension(art, art.extension + gpgExtension) -> + r.sign(f, file(f.getAbsolutePath + gpgExtension), s)) + } + } + else artifacts + }, + publishSignedConfiguration := Classpaths.publishConfig( + signedArtifacts.value, + None, + resolverName = Classpaths.getPublishTo(publishTo.value).name, + checksums = (checksums in publish).value, + logging = ivyLoggingLevel.value, + overwrite = isSnapshot.value), + publishLocalSignedConfiguration := Classpaths.publishConfig( + signedArtifacts.value, + None, + resolverName = "local", + checksums = (checksums in publish).value, + logging = ivyLoggingLevel.value, + overwrite = isSnapshot.value), + publishSigned := Classpaths.publishTask(publishSignedConfiguration, deliver).value, + publishLocalSigned := Classpaths.publishTask(publishLocalSignedConfiguration, deliver).value + ) + +} + diff --git a/src/debian/changelog b/src/debian/changelog index bfd730ff9..835e1fd77 100644 --- a/src/debian/changelog +++ b/src/debian/changelog @@ -4,7 +4,7 @@ sbt (0.13.15) stable; urgency=low * Adds preliminary compatibility with JDK 9. Using this requires 0.13.15+ launcher. #2951 by @retronym * Adds "local-preloaded" repository for offline installation - -- Eugene Yokota Mon, 10 Apr 2017 00:00:00 +0000 + -- Eugene Yokota Mon, 10 Apr 2017 00:00:00 +0000 sbt (0.13.13) stable; urgency=low @@ -39,3 +39,4 @@ sbt (0.11.2-build-0100) * First debian package release -- Joshua Suereth 2011-11-29 + From 11edc53335591e5ea7292256c601443d5b2420af Mon Sep 17 00:00:00 2001 From: Jason Steenstra-Pickens Date: Thu, 1 Jun 2017 22:46:06 +1200 Subject: [PATCH 269/483] Remove carriage return characters when loading configuration files. Issue: sbt/sbt-launcher-package#165 --- src/universal/bin/sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 8ada3d5f4..004d4a4f6 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -135,7 +135,7 @@ process_my_args () { } loadConfigFile() { - cat "$1" | sed '/^\#/d' | while read line; do + cat "$1" | sed '/^\#/d;s/\r$//' | while read line; do eval echo $line done } From a616031ca3be90131161a6823c0cf4102045f70e Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Fri, 30 Jun 2017 16:31:28 +0200 Subject: [PATCH 270/483] Read last line of config files without EOL The last line in a configuration file may not have a terminating EOL character. This commit fixes the launcher script to read that line as well. Inspiration: https://stackoverflow.com/questions/10929453/read-a-file-line-by-line-assigning-the-value-to-a-variable --- src/universal/bin/sbt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 8ada3d5f4..6b927348f 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -135,7 +135,8 @@ process_my_args () { } loadConfigFile() { - cat "$1" | sed '/^\#/d' | while read line; do + # Make sure the last line is read even if it doesn't have a terminating \n + cat "$1" | sed '/^\#/d' | while read -r line || [[ -n "$line" ]]; do eval echo $line done } From c487e3166e5decfa2463a1155f216de7de217ee9 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 26 Jul 2017 14:57:58 +1000 Subject: [PATCH 271/483] Fix java version detection in bash script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `java -version` can include an extra line of output if `_JAVA_OPTTIONS` is set. This commit adds a grep step before sed to harden against this possibility. Before: ``` âš¡ (export _JAVA_OPTIONS=-Dfoo.bar; java -version 2>&1 | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') Picked up _JAVA_OPTIONS: -Dfoo.bar ``` After: ``` âš¡ (export _JAVA_OPTIONS=-Dfoo.bar; java -version 2>&1 | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') 1.8 ``` --- src/universal/bin/sbt-launch-lib.bash | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 59d8af3d6..cd1f6b6ea 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -157,7 +157,7 @@ process_args () { *) addResidual "$1" && shift ;; esac done - + is_function_defined process_my_args && { myargs=("${residual_args[@]}") residual_args=() @@ -165,7 +165,7 @@ process_args () { } ## parses 1.7, 1.8, 9, etc out of java version "1.8.0_91" - java_version=$("$java_cmd" -Xmx512M -version 2>&1 | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') + java_version=$("$java_cmd" -Xmx512M -version 2>&1 | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') vlog "[process_args] java_version = '$java_version'" } @@ -265,8 +265,8 @@ run() { ${java_args[@]} \ -jar "$sbt_jar" \ "${sbt_commands[@]}" \ - "${residual_args[@]}" - + "${residual_args[@]}" + exit_code=$? # Clean up the terminal from cygwin hacks. From 38e4fa9b7b536fcc1e03bf2f02c55e461112c497 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 26 Jul 2017 18:00:14 -0400 Subject: [PATCH 272/483] 0.13.16 build id --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index fa874c0da..bed0d58ad 100644 --- a/build.sbt +++ b/build.sbt @@ -87,7 +87,7 @@ val root = (project in file(".")). if (debianBuildId.value == 0) sbtVersionToRelease else sbtVersionToRelease + "." + debianBuildId.value }, - debianBuildId := 3, // 0 + debianBuildId := 0, // 0 // Used to have "openjdk-8-jdk" but that doesn't work on Ubuntu 14.04 https://github.com/sbt/sbt/issues/3105 // before that we had java6-runtime-headless" and that was pulling in JDK9 on Ubuntu 16.04 https://github.com/sbt/sbt/issues/2931 debianPackageDependencies in Debian ++= Seq("bash (>= 3.2)"), @@ -113,7 +113,7 @@ val root = (project in file(".")). }) else stable }, - rpmRelease := "3", + rpmRelease := "0", rpmVendor := "lightbend", rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"), rpmLicense := Some("BSD"), From d6d79bba6c01d64da3fb29fc4cdf149696b497de Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 10 Aug 2017 04:42:57 -0400 Subject: [PATCH 273/483] Fix variable substitution Fixes #173 --- build.sbt | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/build.sbt b/build.sbt index bed0d58ad..663d1a911 100644 --- a/build.sbt +++ b/build.sbt @@ -149,6 +149,27 @@ val root = (project in file(".")). // Universal ZIP download install. packageName in Universal := packageName.value, // needs to be set explicitly due to a bug in native-packager version in Universal := sbtVersionToRelease, + + mappings in Universal := { + val t = (target in Universal).value + val prev = (mappings in Universal).value + prev.toList map { + case (k, "bin/sbt-launch-lib.bash") => + val x = IO.read(k) + IO.write(t / "sbt-launch-lib.bash", x.replaceAllLiterally( + "declare init_sbt_version=_to_be_replaced", + s"""declare init_sbt_version="$sbtVersionToRelease"""")) + (t / "sbt-launch-lib.bash", "bin/sbt-launch-lib.bash") + case (k, "bin/sbt.bat") => + val x = IO.read(k) + IO.write(t / "sbt.bat", x.replaceAllLiterally( + "set INIT_SBT_VERSION=_TO_BE_REPLACED", + s"""set INIT_SBT_VERSION="$sbtVersionToRelease"""")) + (t / "sbt.bat", "bin/sbt.bat") + case (k, v) => (k, v) + } + }, + mappings in Universal ++= { val launchJar = sbtLaunchJar.value val rtExportJar = (packageBin in Compile in java9rtexport).value @@ -162,17 +183,6 @@ val root = (project in file(".")). } else Def.task { Seq[(File, String)]() } }).value, - stage in Universal := { - val old = (stage in Universal).value - val sd = (stagingDirectory in Universal).value - val x = IO.read(sd / "bin" / "sbt-launch-lib.bash") - IO.write(sd / "bin" / "sbt-launch-lib.bash", x.replaceAllLiterally( - "declare init_sbt_version=_to_be_replaced", s"declare init_sbt_version=$sbtVersionToRelease")) - val y = IO.read(sd / "bin" / "sbt.bat") - IO.write(sd / "bin" / "sbt.bat", y.replaceAllLiterally( - "set INIT_SBT_VERSION=_TO_BE_REPLACED", s"set INIT_SBT_VERSION=$sbtVersionToRelease")) - old - }, // Misccelaneous publishing stuff... projectID in Debian := { From 597060b08b0b718fb3a56ecd261a44205ef5cb87 Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Thu, 10 Aug 2017 05:26:03 -0400 Subject: [PATCH 274/483] Fix for building on Windows --- build.sbt | 10 ++++++---- project/plugins.sbt | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 663d1a911..22ed2d1d1 100644 --- a/build.sbt +++ b/build.sbt @@ -153,19 +153,21 @@ val root = (project in file(".")). mappings in Universal := { val t = (target in Universal).value val prev = (mappings in Universal).value + val BinBash = "bin" + java.io.File.separator + "sbt-launch-lib.bash" + val BinBat = "bin" + java.io.File.separator + "sbt.bat" prev.toList map { - case (k, "bin/sbt-launch-lib.bash") => + case (k, BinBash) => val x = IO.read(k) IO.write(t / "sbt-launch-lib.bash", x.replaceAllLiterally( "declare init_sbt_version=_to_be_replaced", s"""declare init_sbt_version="$sbtVersionToRelease"""")) - (t / "sbt-launch-lib.bash", "bin/sbt-launch-lib.bash") - case (k, "bin/sbt.bat") => + (t / "sbt-launch-lib.bash", BinBash) + case (k, BinBat) => val x = IO.read(k) IO.write(t / "sbt.bat", x.replaceAllLiterally( "set INIT_SBT_VERSION=_TO_BE_REPLACED", s"""set INIT_SBT_VERSION="$sbtVersionToRelease"""")) - (t / "sbt.bat", "bin/sbt.bat") + (t / "sbt.bat", BinBat) case (k, v) => (k, v) } }, diff --git a/project/plugins.sbt b/project/plugins.sbt index 84b3b6e20..67b671e94 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0-M8") +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0-M9") libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.10" addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0") addSbtPlugin("com.eed3si9n" % "sbt-export-repo" % "0.1.0") From ec086a891a7cc7dc61e099edaf12d43af516db06 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 10 Aug 2017 22:33:19 -0400 Subject: [PATCH 275/483] changelog --- src/debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/debian/changelog b/src/debian/changelog index 835e1fd77..d7947decf 100644 --- a/src/debian/changelog +++ b/src/debian/changelog @@ -1,3 +1,10 @@ +sbt (1.0.0) stable; urgency=low + + * sbt 1.0 uses Scala 2.12 for build definitions and plugins. This also requires JDK 8. + * See http://www.scala-sbt.org/1.x/docs/sbt-1.0-Release-Notes.html for the full list of changes. + + -- Eugene Yokota Fri, 11 Aug 2017 00:00:00 +0000 + sbt (0.13.15) stable; urgency=low * sbt 0.13.15 removes the Maven version range when possible. From 70aceedad7324c1e52954bef1a9b3fed8b8279ee Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 16 Aug 2017 01:08:14 -0400 Subject: [PATCH 276/483] Don't run sbt about as post install. Fixes sbt/sbt#3448 Fixes #176 --- build.sbt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 22ed2d1d1..2a7292432 100644 --- a/build.sbt +++ b/build.sbt @@ -82,12 +82,13 @@ val root = (project in file(".")). if !(link.destination endsWith "sbt-launch.jar") } yield link }, + // DEBIAN SPECIFIC + debianBuildId := 1, version in Debian := { if (debianBuildId.value == 0) sbtVersionToRelease else sbtVersionToRelease + "." + debianBuildId.value }, - debianBuildId := 0, // 0 // Used to have "openjdk-8-jdk" but that doesn't work on Ubuntu 14.04 https://github.com/sbt/sbt/issues/3105 // before that we had java6-runtime-headless" and that was pulling in JDK9 on Ubuntu 16.04 https://github.com/sbt/sbt/issues/2931 debianPackageDependencies in Debian ++= Seq("bash (>= 3.2)"), @@ -100,10 +101,9 @@ val root = (project in file(".")). }, debianChangelog in Debian := { Some(sourceDirectory.value / "debian" / "changelog") }, addPackage(Debian, packageBin in Debian, "deb"), - maintainerScripts in Debian := maintainerScriptsAppend((maintainerScripts in Debian).value)( - Postinst -> s"/usr/share/sbt/bin/sbt about" - ), + // RPM SPECIFIC + rpmRelease := "1", version in Rpm := { val stable0 = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".") val stable = if (rpmRelease.value == "0") stable0 @@ -113,7 +113,6 @@ val root = (project in file(".")). }) else stable }, - rpmRelease := "0", rpmVendor := "lightbend", rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"), rpmLicense := Some("BSD"), @@ -123,9 +122,6 @@ val root = (project in file(".")). // https://github.com/elastic/logstash/issues/6275#issuecomment-261359933 rpmRequirements := Seq(), rpmProvides := Seq("sbt"), - maintainerScripts in Rpm := maintainerScriptsAppend((maintainerScripts in Rpm).value)( - RpmConstants.Post -> s"/usr/share/sbt/bin/sbt about" - ), // WINDOWS SPECIFIC windowsBuildId := 0, From 3d194ebdbe75eee8b4abaa53ad1758e1bb808d35 Mon Sep 17 00:00:00 2001 From: Iurii Malchenko Date: Sat, 26 Aug 2017 02:23:26 +0300 Subject: [PATCH 277/483] Use /etc/sbt/sbtopts file if exists. --- src/universal/bin/sbt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 6b927348f..3109a3e2a 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -63,7 +63,8 @@ cygwinpath() { declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" declare -r sbt_opts_file=".sbtopts" -declare -r etc_sbt_opts_file="${sbt_home}/conf/sbtopts" +declare -r etc_sbt_opts_file="/etc/sbt/sbtopts" +declare -r dist_sbt_opts_file="${sbt_home}/conf/sbtopts" declare -r win_sbt_opts_file="${sbt_home}/conf/sbtconfig.txt" usage() { @@ -141,6 +142,9 @@ loadConfigFile() { done } +# Here we pull in the default settings configuration. +[[ -f "$dist_sbt_opts_file" ]] && set -- $(loadConfigFile "$dist_sbt_opts_file") "$@" + # Here we pull in the global settings configuration. [[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@" From 9eeb402a1513cde92f33e15197f990b19a4ba011 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 29 Aug 2017 17:34:24 -0400 Subject: [PATCH 278/483] Reset build number to 0 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 2a7292432..a0e109a4a 100644 --- a/build.sbt +++ b/build.sbt @@ -84,7 +84,7 @@ val root = (project in file(".")). }, // DEBIAN SPECIFIC - debianBuildId := 1, + debianBuildId := 0, version in Debian := { if (debianBuildId.value == 0) sbtVersionToRelease else sbtVersionToRelease + "." + debianBuildId.value @@ -103,7 +103,7 @@ val root = (project in file(".")). addPackage(Debian, packageBin in Debian, "deb"), // RPM SPECIFIC - rpmRelease := "1", + rpmRelease := "0", version in Rpm := { val stable0 = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".") val stable = if (rpmRelease.value == "0") stable0 From 32e8859df629e39958d095b1c932e26d1ed349b0 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 19 Sep 2017 13:33:07 +0200 Subject: [PATCH 279/483] Support Java 10 In bash, "10" < "1.6" returns false, because it's a string comparison. Use bc instead to compare decimal numbers. --- src/universal/bin/sbt-launch-lib.bash | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index cd1f6b6ea..abe9fb742 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -189,13 +189,14 @@ syncPreloaded() { checkJava() { local required_version="$1" # Now check to see if it's a good enough version + local good_enough="$(echo "$java_version >= $required_version" | bc)" if [[ "$java_version" == "" ]]; then echo echo No java installations was detected. echo Please go to http://www.java.com/getjava/ and download echo exit 1 - elif [[ "$java_version" < "$required_version" ]]; then + elif [[ "$good_enough" != "1" ]]; then echo echo The java installation you have is not up to date echo $script_name requires at least version $required_version+, you have @@ -209,7 +210,8 @@ checkJava() { } copyRt() { - if [[ "$java_version" == "9" ]]; then + local at_least_9="$(echo "$java_version >= 9" | bc)" + if [[ "$at_least_9" == "1" ]]; then rtexport=$(rt_export_file) java9_ext=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ -jar "$rtexport" --rt-ext-dir) From 66a105eb03bfccdb7ea7b96e1f21813050bf4b3c Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Sun, 24 Sep 2017 19:45:18 -0700 Subject: [PATCH 280/483] use newer version of bintray plugin for Scala community build friendliness. but also just generally a good thing --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 67b671e94..8c0785c95 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0-M9") libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.10" -addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0") +addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1") addSbtPlugin("com.eed3si9n" % "sbt-export-repo" % "0.1.0") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.1") From d251388f5374af268efd7f48f58e2ac191457654 Mon Sep 17 00:00:00 2001 From: Tim Harper Date: Tue, 26 Sep 2017 15:30:03 -0600 Subject: [PATCH 281/483] OS X compatible line-ending stripping BSD sed interprets sed 's/\r//' as "replace the literal letter r". A more compatible approach delegates the interpretation of this sequence to bash. Fixes #186 --- src/universal/bin/sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 70dfc912c..9070dab7c 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -137,7 +137,7 @@ process_my_args () { loadConfigFile() { # Make sure the last line is read even if it doesn't have a terminating \n - cat "$1" | sed '/^\#/d;s/\r$//' | while read -r line || [[ -n "$line" ]]; do + cat "$1" | sed $'/^\#/d;s/\r$//' | while read -r line || [[ -n "$line" ]]; do eval echo $line done } From 97f38b5a1d23b7e235ff9d175880ad450294fc08 Mon Sep 17 00:00:00 2001 From: Michael Stringer Date: Thu, 28 Sep 2017 20:00:33 +0100 Subject: [PATCH 282/483] Set -XX:+UseParallelGC on Java 9 --- src/universal/bin/sbt-launch-lib.bash | 16 ++++++++++++++++ src/universal/bin/sbt.bat | 11 +++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index abe9fb742..365574040 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -117,6 +117,21 @@ get_mem_opts () { fi } +get_gc_opts () { + local older_than_9="$(echo "$java_version < 9" | bc)" + + if [[ "$older_than_9" == "1" ]]; then + # don't need to worry about gc + echo "" + elif [[ "${JAVA_OPTS}" =~ Use.*GC ]] || [[ "${JAVA_TOOL_OPTIONS}" =~ Use.*GC ]] || [[ "${SBT_OPTS}" =~ Use.*GC ]] ; then + # GC arg has been passed in - don't change + echo "" + else + # Java 9+ so revert to old + echo "-XX:+UseParallelGC" + fi +} + require_arg () { local type="$1" local opt="$2" @@ -262,6 +277,7 @@ run() { # run sbt execRunner "$java_cmd" \ $(get_mem_opts $sbt_mem) \ + $(get_gc_opts) \ ${JAVA_OPTS} \ ${SBT_OPTS:-$default_sbt_opts} \ ${java_args[@]} \ diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 6035dc357..63788d2b1 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -1,12 +1,12 @@ @REM SBT launcher script -@REM +@REM @REM Environment: @REM JAVA_HOME - location of a JDK home dir (mandatory) @REM SBT_OPTS - JVM options (optional) @REM Configuration: @REM sbtconfig.txt found in the SBT_HOME. -@REM ZOMG! We need delayed expansion to build up CFG_OPTS later +@REM ZOMG! We need delayed expansion to build up CFG_OPTS later @setlocal enabledelayedexpansion @echo off @@ -141,6 +141,13 @@ if /I "%JAVA_VERSION%" GEQ "9" ( "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "%rtexport%" "%java9_rt%" ) set _JAVA_OPTS=!_JAVA_OPTS! -Dscala.ext.dirs="%java9_ext%" + + rem check to see if a GC has been set in the opts + echo !_JAVA_OPTS! | findstr /r "Use.*GC" >nul + if ERRORLEVEL 1 ( + rem don't have a GC set - revert to old GC + set _JAVA_OPTS=!_JAVA_OPTS! -XX:+UseParallelGC + ) ) exit /B 0 From eb69920e8138b8a9b9ea0dd5df976b66f2585b98 Mon Sep 17 00:00:00 2001 From: Tom Most Date: Fri, 27 Oct 2017 19:49:11 -0700 Subject: [PATCH 283/483] Add bc dependency in Debian/Ubuntu package --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index a0e109a4a..a077de6d0 100644 --- a/build.sbt +++ b/build.sbt @@ -91,7 +91,7 @@ val root = (project in file(".")). }, // Used to have "openjdk-8-jdk" but that doesn't work on Ubuntu 14.04 https://github.com/sbt/sbt/issues/3105 // before that we had java6-runtime-headless" and that was pulling in JDK9 on Ubuntu 16.04 https://github.com/sbt/sbt/issues/2931 - debianPackageDependencies in Debian ++= Seq("bash (>= 3.2)"), + debianPackageDependencies in Debian ++= Seq("bash (>= 3.2)", "bc"), debianPackageRecommends in Debian += "git", linuxPackageMappings in Debian += { val bd = sourceDirectory.value From da023352613dc8110ad6bf8dac46f71cc64a41b4 Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Fri, 10 Nov 2017 19:46:42 +0000 Subject: [PATCH 284/483] Changed references to downloading/installing/updating Java (JRE?) to refer to JDK. Updated download URLs. Fixed #115. --- src/universal/bin/sbt-launch-lib.bash | 10 +++++----- src/universal/bin/sbt.bat | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 365574040..a2dba7ce8 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -207,18 +207,18 @@ checkJava() { local good_enough="$(echo "$java_version >= $required_version" | bc)" if [[ "$java_version" == "" ]]; then echo - echo No java installations was detected. - echo Please go to http://www.java.com/getjava/ and download + echo "No Java Development Kit (JDK) installation was detected." + echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download. echo exit 1 elif [[ "$good_enough" != "1" ]]; then echo - echo The java installation you have is not up to date + echo "The Java Development Kit (JDK) installation you have is not up to date." echo $script_name requires at least version $required_version+, you have echo version $java_version echo - echo Please go to http://www.java.com/getjava/ and download - echo a valid Java Runtime and install before running $script_name. + echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download + echo a valid JDK and install before running $script_name. echo exit 1 fi diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 63788d2b1..8a43b1fb9 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -118,12 +118,12 @@ if /I "%JAVA_VERSION%" GEQ "%required_version%" ( exit /B 0 ) echo. -echo The java installation you have is not up to date +echo The Java Development Kit (JDK) installation you have is not up to date. echo sbt requires at least version %required_version%+, you have echo version %JAVA_VERSION% echo. -echo Please go to http://www.java.com/getjava/ and download -echo a valid Java Runtime and install before running sbt. +echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download +echo a valid JDK and install before running sbt. echo. exit /B 1 From 602b1387718220ff9cb23c783ca746649428e61e Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Sun, 12 Nov 2017 16:15:58 -0800 Subject: [PATCH 285/483] Updated README.md to add a Travis build status image --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 76a62c377..31b42a8cd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +# Build Status + +[![Build Status](https://travis-ci.org/sbt/sbt-launcher-package.svg?branch=master)](https://travis-ci.org/sbt/sbt-launcher-package) + sbt: the launcher ================== From 006a5eee23b512b66630b29309867d53dd6322a9 Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Wed, 15 Nov 2017 11:55:12 +0100 Subject: [PATCH 286/483] Ignore debug output when getting runtime jar path --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index a2dba7ce8..5071bd2aa 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -229,7 +229,7 @@ copyRt() { if [[ "$at_least_9" == "1" ]]; then rtexport=$(rt_export_file) java9_ext=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ - -jar "$rtexport" --rt-ext-dir) + -jar "$rtexport" --rt-ext-dir | grep -v Listening) java9_rt=$(echo "$java9_ext/rt.jar") vlog "[copyRt] java9_rt = '$java9_rt'" if [[ ! -f "$java9_rt" ]]; then From 8f276e95e0d5e50cb977fd2ee72aa375d941f7e5 Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Sun, 12 Nov 2017 20:43:51 -0500 Subject: [PATCH 287/483] Set compatible build properties, sbt version (1.0.3) to fix Travis build. Added required fakeroot package. Fixed #180. --- .travis.yml | 7 ++++++- project/build.properties | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b58de08cf..38409a5e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,11 @@ +dist: trusty +addons: + apt: + packages: + - fakeroot language: scala script: - - sbt -Dsbt.build.version=1.0.0-M1 ++$TRAVIS_SCALA_VERSION rpm:packageBin debian:packageBin universal:packageBin + - sbt -Dsbt.build.version=1.0.3 ++$TRAVIS_SCALA_VERSION rpm:packageBin debian:packageBin universal:packageBin scala: - 2.10.3 jdk: diff --git a/project/build.properties b/project/build.properties index 6818e9c44..3689a86a2 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1,2 @@ -sbt.version=0.13.15 +sbt.version=0.13.16 From 096a0d83b2e7b621bc775aaeccb5a5384c8230a5 Mon Sep 17 00:00:00 2001 From: Dale Wijnand <344610+dwijnand@users.noreply.github.com> Date: Thu, 16 Nov 2017 11:02:18 +0000 Subject: [PATCH 288/483] Update sbt.build.version in CONTRIBUTING too. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7597f6eb1..499d2e429 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Steps to publish ================ ``` -$ sbt -Dsbt.build.version=1.0.0-M1 -Dsbt.build.offline=true +$ sbt -Dsbt.build.version=1.0.3 -Dsbt.build.offline=true > universal:publish > debian:publish > rpm:publish From 6ad16c2b74db3e10ce6deb08aab358e931bc64bf Mon Sep 17 00:00:00 2001 From: Fulvio Valente Date: Thu, 16 Nov 2017 15:11:19 +0000 Subject: [PATCH 289/483] Use expr instead of bc when checking Java versions. Because expr is in coreutils, we can expect it to be present on systems unlike bc. Fixes #198 Fixes #192 --- build.sbt | 2 +- src/universal/bin/sbt-launch-lib.bash | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index a077de6d0..a0e109a4a 100644 --- a/build.sbt +++ b/build.sbt @@ -91,7 +91,7 @@ val root = (project in file(".")). }, // Used to have "openjdk-8-jdk" but that doesn't work on Ubuntu 14.04 https://github.com/sbt/sbt/issues/3105 // before that we had java6-runtime-headless" and that was pulling in JDK9 on Ubuntu 16.04 https://github.com/sbt/sbt/issues/2931 - debianPackageDependencies in Debian ++= Seq("bash (>= 3.2)", "bc"), + debianPackageDependencies in Debian ++= Seq("bash (>= 3.2)"), debianPackageRecommends in Debian += "git", linuxPackageMappings in Debian += { val bd = sourceDirectory.value diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 5071bd2aa..7504df246 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -118,7 +118,7 @@ get_mem_opts () { } get_gc_opts () { - local older_than_9="$(echo "$java_version < 9" | bc)" + local older_than_9="$(expr $java_version "<" 9)" if [[ "$older_than_9" == "1" ]]; then # don't need to worry about gc @@ -204,7 +204,7 @@ syncPreloaded() { checkJava() { local required_version="$1" # Now check to see if it's a good enough version - local good_enough="$(echo "$java_version >= $required_version" | bc)" + local good_enough="$(expr $java_version ">=" $required_version)" if [[ "$java_version" == "" ]]; then echo echo "No Java Development Kit (JDK) installation was detected." @@ -225,7 +225,7 @@ checkJava() { } copyRt() { - local at_least_9="$(echo "$java_version >= 9" | bc)" + local at_least_9="$(expr $java_version ">=" 9)" if [[ "$at_least_9" == "1" ]]; then rtexport=$(rt_export_file) java9_ext=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ From 6dbf7eb527aed320c2302f24de8f2fe9bd328a97 Mon Sep 17 00:00:00 2001 From: Dale Wijnand <344610+dwijnand@users.noreply.github.com> Date: Wed, 13 Dec 2017 23:22:39 +0000 Subject: [PATCH 290/483] Drop quotes in bat script --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index a0e109a4a..0ecd82e8f 100644 --- a/build.sbt +++ b/build.sbt @@ -162,7 +162,7 @@ val root = (project in file(".")). val x = IO.read(k) IO.write(t / "sbt.bat", x.replaceAllLiterally( "set INIT_SBT_VERSION=_TO_BE_REPLACED", - s"""set INIT_SBT_VERSION="$sbtVersionToRelease"""")) + s"""set INIT_SBT_VERSION=$sbtVersionToRelease""")) (t / "sbt.bat", BinBat) case (k, v) => (k, v) } From 73bd7a52841294c7bc4f262035f505413a6edb2d Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 13 Dec 2017 22:22:37 -0500 Subject: [PATCH 291/483] Add AppVeyor settings --- .appveyor.yml | 27 +++++++++++++++++++++++++++ citest/test.bat | 6 ++++++ 2 files changed, 33 insertions(+) create mode 100644 .appveyor.yml create mode 100644 citest/test.bat diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 000000000..6fe1b8bc8 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,27 @@ +build: off + +init: + - git config --global core.autocrlf input + +install: + - cinst jdk8 -params 'installdir=C:\\jdk8' + - cinst jdk9 -version 9.0.1.11 -params 'installdir=C:\\jdk9' + - SET JAVA_HOME=C:\jdk8 + - SET PATH=C:\jdk8\bin;%PATH% + + - ps: | + Add-Type -AssemblyName System.IO.Compression.FileSystem + if (!(Test-Path -Path "C:\sbt" )) { + (new-object System.Net.WebClient).DownloadFile( + 'https://cocl.us/sbt-0.13.16.zip', + 'C:\sbt-bin.zip' + ) + [System.IO.Compression.ZipFile]::ExtractToDirectory("C:\sbt-bin.zip", "C:\sbt") + } + - SET PATH=C:\sbt\sbt\bin;%PATH% + - SET SBT_OPTS=-XX:MaxPermSize=2g -Xmx4g -Dfile.encoding=UTF8 + +test_script: + - sbt "-Dsbt.build.version=1.0.4" universal:packageBin + - unzip target\universal\sbt.zip -d target\freshly-baked\ + - citest\test.bat diff --git a/citest/test.bat b/citest/test.bat new file mode 100644 index 000000000..30365c99d --- /dev/null +++ b/citest/test.bat @@ -0,0 +1,6 @@ +cd "%~dp0" + +SET JAVA_HOME=C:\jdk9 +SET PATH=C:\jdk9\bin;%PATH% + +"..\target\freshly-baked\sbt\bin\sbt" about From 49d85750afb271a552c034984273dc7d6bf92a91 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 14 Dec 2017 00:09:56 -0500 Subject: [PATCH 292/483] add test --- .appveyor.yml | 6 ++++-- citest/build.sbt | 31 +++++++++++++++++++++++++++++++ citest/project/build.properties | 1 + citest/test.bat | 12 +++++++++++- citest/test1.bat | 11 +++++++++++ citest/test2.bat | 11 +++++++++++ 6 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 citest/build.sbt create mode 100644 citest/project/build.properties create mode 100644 citest/test1.bat create mode 100644 citest/test2.bat diff --git a/.appveyor.yml b/.appveyor.yml index 6fe1b8bc8..a467cd4a4 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -23,5 +23,7 @@ install: test_script: - sbt "-Dsbt.build.version=1.0.4" universal:packageBin - - unzip target\universal\sbt.zip -d target\freshly-baked\ - - citest\test.bat + - cd citest + - test.bat + - test1.bat + - test2.bat diff --git a/citest/build.sbt b/citest/build.sbt new file mode 100644 index 000000000..63168c406 --- /dev/null +++ b/citest/build.sbt @@ -0,0 +1,31 @@ +lazy val check = taskKey[Unit]("") + +lazy val root = (project in file(".")) + .settings( + scalaVersion := "2.12.4", + name := "Hello", + check := { + val xs = IO.readLines(file("output.txt")).toVector + + println(xs) + + assert(xs(0) startsWith "Copying runtime jar.") + // echo of jar name + assert(xs(2) startsWith "[info] Loading project definition") + assert(xs(3) startsWith "[info] Loading settings from build.sbt") + assert(xs(4) startsWith "[info] Set current project to Hello") + assert(xs(5) startsWith "[info] This is sbt") + assert(xs(6) startsWith "[info] The current project") + assert(xs(7) startsWith "[info] The current project is built against Scala 2.12.4") + + val ys = IO.readLines(file("err.txt")).toVector + + println(ys) + + assert(ys.size == 4) + assert(ys(0) startsWith "Error: Unable to access jarfile") + assert(ys(1) startsWith "The filename, directory name, or volume label syntax is incorrect.") + assert(ys(2) startsWith "Error: Unable to access jarfile") + assert(ys(3) startsWith "Java HotSpot(TM) 64-Bit Server VM warning") + } + ) diff --git a/citest/project/build.properties b/citest/project/build.properties new file mode 100644 index 000000000..394cb75cf --- /dev/null +++ b/citest/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.0.4 diff --git a/citest/test.bat b/citest/test.bat index 30365c99d..609959707 100644 --- a/citest/test.bat +++ b/citest/test.bat @@ -1,6 +1,16 @@ +@echo on + cd "%~dp0" +mkdir freshly-baked +unzip ..\target\universal\sbt.zip -d freshly-baked + +SETLOCAL + SET JAVA_HOME=C:\jdk9 SET PATH=C:\jdk9\bin;%PATH% +SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 -"..\target\freshly-baked\sbt\bin\sbt" about +"freshly-baked\sbt\bin\sbt" about + +ENDLOCAL diff --git a/citest/test1.bat b/citest/test1.bat new file mode 100644 index 000000000..b02954cd9 --- /dev/null +++ b/citest/test1.bat @@ -0,0 +1,11 @@ +@echo on + +SETLOCAL + +SET JAVA_HOME=C:\jdk9 +SET PATH=C:\jdk9\bin;%PATH% +SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 + +"freshly-baked\sbt\bin\sbt" about 1> output.txt 2> err.txt + +ENDLOCAL diff --git a/citest/test2.bat b/citest/test2.bat new file mode 100644 index 000000000..b02598217 --- /dev/null +++ b/citest/test2.bat @@ -0,0 +1,11 @@ +@echo on + +SETLOCAL + +SET JAVA_HOME=C:\jdk9 +SET PATH=C:\jdk9\bin;%PATH% +SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 + +"freshly-baked\sbt\bin\sbt" check + +ENDLOCAL From f9b9d082f61fd3565c4b4c5dbf50b8e1fc362ac4 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 14 Dec 2017 02:23:25 -0500 Subject: [PATCH 293/483] use delayed expansion Fixes sbt/sbt#3804 Inside the if, it seems like bunch of variables were set to blank. Using delayed expansion seems to fix this. This is confirmed by the newly added test. --- citest/build.sbt | 22 +++++++++------------- src/universal/bin/sbt.bat | 15 +++++++-------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/citest/build.sbt b/citest/build.sbt index 63168c406..81b1532b6 100644 --- a/citest/build.sbt +++ b/citest/build.sbt @@ -9,23 +9,19 @@ lazy val root = (project in file(".")) println(xs) - assert(xs(0) startsWith "Copying runtime jar.") - // echo of jar name - assert(xs(2) startsWith "[info] Loading project definition") - assert(xs(3) startsWith "[info] Loading settings from build.sbt") - assert(xs(4) startsWith "[info] Set current project to Hello") - assert(xs(5) startsWith "[info] This is sbt") - assert(xs(6) startsWith "[info] The current project") - assert(xs(7) startsWith "[info] The current project is built against Scala 2.12.4") + assert(xs(0) startsWith "[info] Loading project definition") + assert(xs(1) startsWith "[info] Loading settings from build.sbt") + assert(xs(2) startsWith "[info] Set current project to Hello") + assert(xs(3) startsWith "[info] This is sbt") + assert(xs(4) startsWith "[info] The current project") + assert(xs(5) startsWith "[info] The current project is built against Scala 2.12.4") val ys = IO.readLines(file("err.txt")).toVector println(ys) - assert(ys.size == 4) - assert(ys(0) startsWith "Error: Unable to access jarfile") - assert(ys(1) startsWith "The filename, directory name, or volume label syntax is incorrect.") - assert(ys(2) startsWith "Error: Unable to access jarfile") - assert(ys(3) startsWith "Java HotSpot(TM) 64-Bit Server VM warning") + assert(ys.size == 2) + assert(ys(0) startsWith "Java HotSpot(TM) 64-Bit Server VM warning") + assert(ys(1) startsWith "Java HotSpot(TM) 64-Bit Server VM warning") } ) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 8a43b1fb9..2fec638ac 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -131,16 +131,15 @@ exit /B 1 if /I "%JAVA_VERSION%" GEQ "9" ( set rtexport="%SBT_HOME%java9-rt-export.jar" - "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "%rtexport%" --rt-ext-dir > "%TEMP%.\rtext.txt" + "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "!rtexport!" --rt-ext-dir > "%TEMP%.\rtext.txt" set /p java9_ext= < "%TEMP%.\rtext.txt" - set java9_rt=%java9_ext%\rt.jar + set java9_rt=!java9_ext!\rt.jar - if not exist "%java9_rt%" ( - echo Copying runtime jar. - mkdir "%java9_ext%" - "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "%rtexport%" "%java9_rt%" + if not exist "!java9_rt!" ( + mkdir "!java9_ext!" + "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "!rtexport!" "!java9_rt!" ) - set _JAVA_OPTS=!_JAVA_OPTS! -Dscala.ext.dirs="%java9_ext%" + set _JAVA_OPTS=!_JAVA_OPTS! -Dscala.ext.dirs="!java9_ext!" rem check to see if a GC has been set in the opts echo !_JAVA_OPTS! | findstr /r "Use.*GC" >nul @@ -162,7 +161,7 @@ set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org.scala-sbt\sbt\%INIT_SBT_VE if /I "%JAVA_VERSION%" GEQ "1.8" ( where robocopy >nul 2>nul if %ERRORLEVEL% equ 0 ( - echo %PRELOAD_SBT_JAR% + REM echo %PRELOAD_SBT_JAR% if not exist %PRELOAD_SBT_JAR% ( if exist "%SBT_HOME%\..\lib\local-preloaded\" ( echo 'about to robocopy' From 0e59118ded69ba85fc097b41bfbc59240d64d882 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 18 Dec 2017 22:27:19 -0500 Subject: [PATCH 294/483] Remove double quotes around rtexport See https://github.com/sbt/sbt/issues/3804#issuecomment-352602666 --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 2fec638ac..4384c7286 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -129,7 +129,7 @@ exit /B 1 :copyrt if /I "%JAVA_VERSION%" GEQ "9" ( - set rtexport="%SBT_HOME%java9-rt-export.jar" + set rtexport=%SBT_HOME%java9-rt-export.jar "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "!rtexport!" --rt-ext-dir > "%TEMP%.\rtext.txt" set /p java9_ext= < "%TEMP%.\rtext.txt" From f9295a6715bde001fca503fbcbd6f2938cab2f59 Mon Sep 17 00:00:00 2001 From: Marcos Pereira Date: Tue, 2 Jan 2018 18:15:07 -0200 Subject: [PATCH 295/483] Remove -Xmx512M flag when detecting java version The flag can cause problems when there is another configuration adding -Xms with a value bigger than 512M. The `java -version` command will fail and no java version will be detected, causing a failure in `checkJava`. --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 7504df246..b193889a3 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -180,7 +180,7 @@ process_args () { } ## parses 1.7, 1.8, 9, etc out of java version "1.8.0_91" - java_version=$("$java_cmd" -Xmx512M -version 2>&1 | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') + java_version=$("$java_cmd" -version 2>&1 | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') vlog "[process_args] java_version = '$java_version'" } From 901e5794b84008ea99dea718ee478e168595e451 Mon Sep 17 00:00:00 2001 From: Dale Wijnand <344610+dwijnand@users.noreply.github.com> Date: Thu, 4 Jan 2018 10:18:18 +0000 Subject: [PATCH 296/483] Set both Xms & Xmx when running java -version See the comments in #203. My choice of minimum memory is basically arbitrary. --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index b193889a3..22bdb132f 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -180,7 +180,7 @@ process_args () { } ## parses 1.7, 1.8, 9, etc out of java version "1.8.0_91" - java_version=$("$java_cmd" -version 2>&1 | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') + java_version=$("$java_cmd" -Xms128M -Xmx512M -version 2>&1 | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') vlog "[process_args] java_version = '$java_version'" } From f66161a14f6f15afd9e7609d7913de7daf5b4f7a Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Fri, 5 Jan 2018 15:55:14 -0500 Subject: [PATCH 297/483] line up Scala version and JLine --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 0ecd82e8f..15f0da0f4 100644 --- a/build.sbt +++ b/build.sbt @@ -278,14 +278,14 @@ def bintrayRelease(repo: BintrayRepo, pkg: String, version: String, log: Logger) repo.release(pkg, version, log) -lazy val scala210 = "2.10.6" -lazy val scala212 = "2.12.2" +lazy val scala210 = "2.10.7" +lazy val scala212 = "2.12.4" lazy val scala210Jline = "org.scala-lang" % "jline" % scala210 lazy val jansi = { if (sbtVersionToRelease startsWith "1.") "org.fusesource.jansi" % "jansi" % "1.4" else "org.fusesource.jansi" % "jansi" % "1.4" } -lazy val scala212Jline = "jline" % "jline" % "2.14.1" +lazy val scala212Jline = "jline" % "jline" % "2.14.5" lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6" lazy val scala212Compiler = "org.scala-lang" % "scala-compiler" % scala212 lazy val sbtActual = "org.scala-sbt" % "sbt" % sbtVersionToRelease From 13f2bafdf8ca9dacf9b0f291d846a906ca6e156b Mon Sep 17 00:00:00 2001 From: Phil Date: Fri, 5 Jan 2018 14:36:17 -0700 Subject: [PATCH 298/483] remove invisible carriage-return appended to java_version under cygwin --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 22bdb132f..828db86f0 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -180,7 +180,7 @@ process_args () { } ## parses 1.7, 1.8, 9, etc out of java version "1.8.0_91" - java_version=$("$java_cmd" -Xms128M -Xmx512M -version 2>&1 | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') + java_version=$("$java_cmd" -Xms128M -Xmx512M -version 2>&1 | tr '\r' '\n' | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') vlog "[process_args] java_version = '$java_version'" } From 3b39ff0554546bf9fe030f85b6376a9a325486d1 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 8 Jan 2018 09:08:12 -0500 Subject: [PATCH 299/483] Use more delayed expansion Fixes #206 When I use unzipped sbt.bat it seems to runs ok, but using the msi installer version, this variable seems to expand and causes: ``` \sbt\bin\java9-rt-export.jar was unexpected at this time. ``` --- citest/test.bat | 2 ++ src/universal/bin/sbt.bat | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/citest/test.bat b/citest/test.bat index 609959707..7d35a6ca6 100644 --- a/citest/test.bat +++ b/citest/test.bat @@ -7,6 +7,8 @@ unzip ..\target\universal\sbt.zip -d freshly-baked SETLOCAL +"freshly-baked\sbt\bin\sbt" about + SET JAVA_HOME=C:\jdk9 SET PATH=C:\jdk9\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 4384c7286..4e966daac 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -129,7 +129,7 @@ exit /B 1 :copyrt if /I "%JAVA_VERSION%" GEQ "9" ( - set rtexport=%SBT_HOME%java9-rt-export.jar + set rtexport=!SBT_HOME!java9-rt-export.jar "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "!rtexport!" --rt-ext-dir > "%TEMP%.\rtext.txt" set /p java9_ext= < "%TEMP%.\rtext.txt" From 417599b4634fe6a64e389a672771e9d72713a030 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 8 Jan 2018 10:17:38 -0500 Subject: [PATCH 300/483] Fixing test --- citest/build.sbt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/citest/build.sbt b/citest/build.sbt index 81b1532b6..3ff4eae20 100644 --- a/citest/build.sbt +++ b/citest/build.sbt @@ -16,12 +16,9 @@ lazy val root = (project in file(".")) assert(xs(4) startsWith "[info] The current project") assert(xs(5) startsWith "[info] The current project is built against Scala 2.12.4") - val ys = IO.readLines(file("err.txt")).toVector + val ys = IO.readLines(file("err.txt")).toVector.distinct - println(ys) - - assert(ys.size == 2) + assert(ys.size == 1, s"ys has more than one item: $ys") assert(ys(0) startsWith "Java HotSpot(TM) 64-Bit Server VM warning") - assert(ys(1) startsWith "Java HotSpot(TM) 64-Bit Server VM warning") } ) From e15633064b1e2475639ef8bb2442f75b376c698a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Mickevi=C4=8Dius?= Date: Sat, 3 Feb 2018 18:15:56 +0100 Subject: [PATCH 301/483] Handle JDK 10 version string --- src/universal/bin/sbt-launch-lib.bash | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 828db86f0..222e4dbb9 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -179,8 +179,14 @@ process_args () { process_my_args "${myargs[@]}" } - ## parses 1.7, 1.8, 9, etc out of java version "1.8.0_91" - java_version=$("$java_cmd" -Xms128M -Xmx512M -version 2>&1 | tr '\r' '\n' | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') + ## parses java version from the -version output line, e.g.: + ## java version "10-ea" 2018-03-20 --> 10 + ## openjdk version "9" --> 9 + ## java version "1.8.0_162" --> 1.8 + ## openjdk version "1.8.0_144" --> 1.8 + ## java version "1.7.0_151" --> 1.7 + ## java version "1.6.0_45" --> 1.6 + java_version=$("$java_cmd" -Xms128M -Xmx512M -version 2>&1 | tr '\r' '\n' | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*/\1\2/; 1q') vlog "[process_args] java_version = '$java_version'" } From 3a2a84163ef2eb66dbca03b0be8b40fff86189f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Mickevi=C4=8Dius?= Date: Mon, 5 Feb 2018 13:19:09 +0100 Subject: [PATCH 302/483] Unfreeze jdk9 appveyor package version --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index a467cd4a4..063d44854 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,7 +5,7 @@ init: install: - cinst jdk8 -params 'installdir=C:\\jdk8' - - cinst jdk9 -version 9.0.1.11 -params 'installdir=C:\\jdk9' + - cinst jdk9 -params 'installdir=C:\\jdk9' - SET JAVA_HOME=C:\jdk8 - SET PATH=C:\jdk8\bin;%PATH% From 09a7152b1dbe621e4c58e31b71c4699664ad9e61 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Tue, 6 Feb 2018 10:25:59 -0800 Subject: [PATCH 303/483] Whitelist java9-rt-ext- output in rt export process If -verbose:gc is set, there can be gc log output in this process that prevents the directory from being properly extracted. Rather than blacklist possible output strings, I think it makes more sense to whitelist the specific output line that we're looking for. --- .../main/java/io/github/retronym/java9rtexport/Export.java | 4 ++++ src/universal/bin/sbt-launch-lib.bash | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java b/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java index 6bb468531..806ab7d2b 100644 --- a/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java +++ b/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java @@ -29,6 +29,10 @@ public class Export { if (destination.equals("--rt-ext-dir")) { String v = System.getProperty("java.vendor") + "_" + System.getProperty("java.version"); v = v.replaceAll("\\W", "_").toLowerCase(); + /* + * The launch script greps for output starting with "java9-rt-ext-" so changing this + * string will require changing the grep command in sbt-launch-lib.bash. + */ Path rtExtDir = Paths.get(globalBase, "java9-rt-ext-" + v); System.out.println(rtExtDir.toString()); System.exit(0); diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 222e4dbb9..a29495388 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -234,8 +234,9 @@ copyRt() { local at_least_9="$(expr $java_version ">=" 9)" if [[ "$at_least_9" == "1" ]]; then rtexport=$(rt_export_file) + # The grep for java9-rt-ext- matches the filename prefix printed in Export.java java9_ext=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ - -jar "$rtexport" --rt-ext-dir | grep -v Listening) + -jar "$rtexport" --rt-ext-dir | grep java9-rt-ext-) java9_rt=$(echo "$java9_ext/rt.jar") vlog "[copyRt] java9_rt = '$java9_rt'" if [[ ! -f "$java9_rt" ]]; then From 769b3a46a2d36f12b73602fd45984c5b3c77fe92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Mickevi=C4=8Dius?= Date: Tue, 13 Feb 2018 14:30:34 +0200 Subject: [PATCH 304/483] Use not-yet-approved package version --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 063d44854..4800e33c2 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,7 +5,7 @@ init: install: - cinst jdk8 -params 'installdir=C:\\jdk8' - - cinst jdk9 -params 'installdir=C:\\jdk9' + - cinst jdk9 -version 9.0.4.11 -params 'installdir=C:\\jdk9' - SET JAVA_HOME=C:\jdk8 - SET PATH=C:\jdk8\bin;%PATH% From 06420a7c620de8d01e55441cbdebbb240a13ddeb Mon Sep 17 00:00:00 2001 From: TATSUNO Yasuhiro Date: Wed, 14 Feb 2018 18:06:22 +0900 Subject: [PATCH 305/483] Ignore comment in .jvmopts on Windows (#213) --- .appveyor.yml | 1 + citest/test3/.jvmopts | 3 +++ citest/test3/build.sbt | 24 ++++++++++++++++++++++++ citest/test3/test3.bat | 17 +++++++++++++++++ src/universal/bin/sbt.bat | 6 ++++-- 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 citest/test3/.jvmopts create mode 100644 citest/test3/build.sbt create mode 100644 citest/test3/test3.bat diff --git a/.appveyor.yml b/.appveyor.yml index 4800e33c2..c822f2293 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -27,3 +27,4 @@ test_script: - test.bat - test1.bat - test2.bat + - test3/test3.bat diff --git a/citest/test3/.jvmopts b/citest/test3/.jvmopts new file mode 100644 index 000000000..ecacefc9a --- /dev/null +++ b/citest/test3/.jvmopts @@ -0,0 +1,3 @@ +-XX:+CMSClassUnloadingEnabled +#-XX:ReservedCodeCacheSize=192m +#-Duser.timezone=GMT \ No newline at end of file diff --git a/citest/test3/build.sbt b/citest/test3/build.sbt new file mode 100644 index 000000000..3ff4eae20 --- /dev/null +++ b/citest/test3/build.sbt @@ -0,0 +1,24 @@ +lazy val check = taskKey[Unit]("") + +lazy val root = (project in file(".")) + .settings( + scalaVersion := "2.12.4", + name := "Hello", + check := { + val xs = IO.readLines(file("output.txt")).toVector + + println(xs) + + assert(xs(0) startsWith "[info] Loading project definition") + assert(xs(1) startsWith "[info] Loading settings from build.sbt") + assert(xs(2) startsWith "[info] Set current project to Hello") + assert(xs(3) startsWith "[info] This is sbt") + assert(xs(4) startsWith "[info] The current project") + assert(xs(5) startsWith "[info] The current project is built against Scala 2.12.4") + + val ys = IO.readLines(file("err.txt")).toVector.distinct + + assert(ys.size == 1, s"ys has more than one item: $ys") + assert(ys(0) startsWith "Java HotSpot(TM) 64-Bit Server VM warning") + } + ) diff --git a/citest/test3/test3.bat b/citest/test3/test3.bat new file mode 100644 index 000000000..8b3fe5a94 --- /dev/null +++ b/citest/test3/test3.bat @@ -0,0 +1,17 @@ +@echo on + +SETLOCAL + +SET JAVA_HOME=C:\jdk9 +SET PATH=C:\jdk9\bin;%PATH% +SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 + +SET BASE_DIR=%CD% +SET SCRIPT_DIR=%~dp0 + +CD %SCRIPT_DIR% +"%BASE_DIR%freshly-baked\sbt\bin\sbt" about 1> output.txt 2> err.txt +"%BASE_DIR%freshly-baked\sbt\bin\sbt" check +CD %BASE_DIR% + +ENDLOCAL diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 4e966daac..237accc05 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -35,9 +35,11 @@ IF DEFINED JAVA_HOME SET "PATH=%JAVA_HOME%\bin;%PATH%" rem users can set JAVA_OPTS via .jvmopts (sbt-extras style) IF EXIST .jvmopts FOR /F %%A IN (.jvmopts) DO ( - SET JAVA_OPTS=%%A !JAVA_OPTS! + SET _jvmopts_line=%%A + IF NOT "!_jvmopts_line:~0,1!"=="#" ( + SET JAVA_OPTS=%%A !JAVA_OPTS! + ) ) - rem We use the value of the JAVACMD environment variable if defined set _JAVACMD=%JAVACMD% From 5a0bde442dec7d9a1bdc35655541902fb873172a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Mickevi=C4=8Dius?= Date: Wed, 14 Feb 2018 14:00:36 +0200 Subject: [PATCH 306/483] Use only integers for versions --- src/universal/bin/sbt-launch-lib.bash | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 222e4dbb9..b8bcc06c4 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -106,12 +106,12 @@ get_mem_opts () { (( $codecache > 128 )) || codecache=128 (( $codecache < 512 )) || codecache=512 local class_metadata_size=$(( $codecache * 2 )) - local class_metadata_opt=$([[ "$java_version" < "1.8" ]] && echo "MaxPermSize" || echo "MaxMetaspaceSize") + local class_metadata_opt=$([[ "$java_version" < "8" ]] && echo "MaxPermSize" || echo "MaxMetaspaceSize") local arg_xms=$([[ "${java_args[@]}" == *-Xms* ]] && echo "" || echo "-Xms${mem}m") local arg_xmx=$([[ "${java_args[@]}" == *-Xmx* ]] && echo "" || echo "-Xmx${mem}m") local arg_rccs=$([[ "${java_args[@]}" == *-XX:ReservedCodeCacheSize* ]] && echo "" || echo "-XX:ReservedCodeCacheSize=${codecache}m") - local arg_meta=$([[ "${java_args[@]}" == *-XX:${class_metadata_opt}* && ! "$java_version" < "1.8" ]] && echo "" || echo "-XX:${class_metadata_opt}=${class_metadata_size}m") + local arg_meta=$([[ "${java_args[@]}" == *-XX:${class_metadata_opt}* && ! "$java_version" < "8" ]] && echo "" || echo "-XX:${class_metadata_opt}=${class_metadata_size}m") echo "${arg_xms} ${arg_xmx} ${arg_rccs} ${arg_meta}" fi @@ -179,14 +179,9 @@ process_args () { process_my_args "${myargs[@]}" } - ## parses java version from the -version output line, e.g.: - ## java version "10-ea" 2018-03-20 --> 10 - ## openjdk version "9" --> 9 - ## java version "1.8.0_162" --> 1.8 - ## openjdk version "1.8.0_144" --> 1.8 - ## java version "1.7.0_151" --> 1.7 - ## java version "1.6.0_45" --> 1.6 - java_version=$("$java_cmd" -Xms128M -Xmx512M -version 2>&1 | tr '\r' '\n' | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*/\1\2/; 1q') + ## parses java version from the -version output line + ## https://regex101.com/r/0r3kKb/1/tests + java_version=$("$java_cmd" -Xms128M -Xmx512M -version 2>&1 | tr '\r' '\n' | grep ' version "' | sed 's/.*version "\(1\.\)\?\([0-9]*\)\{0,1\}\(.*\)*/\2/; 1q') vlog "[process_args] java_version = '$java_version'" } @@ -268,7 +263,7 @@ run() { argumentCount=$# # TODO - java check should be configurable... - checkJava "1.6" + checkJava "6" # Java 9 support copyRt From 6f1e6c36d9ebdd0566a8b039c29424f50c01316e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 14 Feb 2018 18:49:11 -0500 Subject: [PATCH 307/483] cross JVM testing This continues to use Oracle JDK 8 for building, but adds test jobs using oraclejdk8, oraclejdk9, and oraclejdk10. --- .gitignore | 2 +- .travis.yml | 65 ++++++++++++++++++++++++--------- citest/Hello.scala | 5 +++ citest/install-jdk10.sh | 20 ++++++++++ citest/project/build.properties | 2 +- citest/test.sh | 22 +++++++++++ project/build.properties | 1 - 7 files changed, 97 insertions(+), 20 deletions(-) create mode 100644 citest/Hello.scala create mode 100755 citest/install-jdk10.sh create mode 100755 citest/test.sh diff --git a/.gitignore b/.gitignore index ebfcd37f5..87178428e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ src_managed .lib /template-project/project/boot *~ - +/citest/freshly-baked/ diff --git a/.travis.yml b/.travis.yml index 38409a5e0..186b785db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,53 @@ dist: trusty -addons: - apt: - packages: - - fakeroot + language: scala -script: - - sbt -Dsbt.build.version=1.0.3 ++$TRAVIS_SCALA_VERSION rpm:packageBin debian:packageBin universal:packageBin + +env: + global: + - SBT_VER=1.1.1 + +matrix: + include: + ## build using JDK 8, test using JDK 8 + - script: + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin + - cd citest && ./test.sh + + ## build using JDK 8, test using JDK 9 + - script: + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin + - jdk_switcher use oraclejdk9 + - cd citest && ./test.sh + + ## build using JDK 8, test using JDK 10 + - script: + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin + - citest/install-jdk10.sh + - cd citest && ./test.sh + + - script: + - sbt -Dsbt.build.version=$SBT_VER rpm:packageBin debian:packageBin + addons: + apt: + packages: + - fakeroot + - rpm + scala: - - 2.10.3 + - 2.10.7 + jdk: - oraclejdk8 -notifications: - email: - - sbt-dev-bot@googlegroups.com -before_install: - - cat /etc/hosts # optionally check the content *before* - - sudo hostname "$(hostname | cut -c1-63)" - - sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts - - cat /etc/hosts # optionally check the content *after* - - sudo apt-get update -qq - - sudo apt-get install -qq rpm + +# Undo _JAVA_OPTIONS environment variable +before_script: + - _JAVA_OPTIONS= + +cache: + directories: + - $HOME/.ivy2/cache + - $HOME/.sbt/boot + +before_cache: + - find $HOME/.ivy2 -name "ivydata-*.properties" -delete + - find $HOME/.sbt -name "*.lock" -delete diff --git a/citest/Hello.scala b/citest/Hello.scala new file mode 100644 index 000000000..b6b4d95ba --- /dev/null +++ b/citest/Hello.scala @@ -0,0 +1,5 @@ +package foo + +object Hello extends App { + println("hello") +} diff --git a/citest/install-jdk10.sh b/citest/install-jdk10.sh new file mode 100755 index 000000000..0693a6890 --- /dev/null +++ b/citest/install-jdk10.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# copied from https://github.com/junit-team/junit5/blob/master/src/install/install-jdk-10.sh + +set -e + +JDK_FEATURE=10 +TMP=$(curl -L jdk.java.net/${JDK_FEATURE}) # extract most recent "JDK_BUILD" number from web page source... +TMP="${TMP#*Most recent build: jdk-${JDK_FEATURE}+}" # remove everything before the number +TMP="${TMP%%<*}" # remove everything after the number +JDK_BUILD="$(echo -e "${TMP}" | tr -d '[:space:]')" # remove all whitespace +JDK_ARCHIVE=jdk-${JDK_FEATURE}+${JDK_BUILD}_linux-x64_bin.tar.gz + +cd ~ +wget http://download.java.net/java/jdk${JDK_FEATURE}/archive/${JDK_BUILD}/BCL/${JDK_ARCHIVE} +tar -xzf ${JDK_ARCHIVE} +export JAVA_HOME=~/jdk-${JDK_FEATURE} +export PATH=${JAVA_HOME}/bin:$PATH +cd - +java --version diff --git a/citest/project/build.properties b/citest/project/build.properties index 394cb75cf..31334bbd3 100644 --- a/citest/project/build.properties +++ b/citest/project/build.properties @@ -1 +1 @@ -sbt.version=1.0.4 +sbt.version=1.1.1 diff --git a/citest/test.sh b/citest/test.sh new file mode 100755 index 000000000..64d40c80a --- /dev/null +++ b/citest/test.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +## https://github.com/travis-ci/travis-ci/issues/8408 +export _JAVA_OPTIONS= + +## begin Java switching +## swtich to JDK 10 if we've downloaded it +if [ -d ~/jdk-10 ] +then + JAVA_HOME=~/jdk-10 +fi +## include JAVA_HOME into path +PATH=${JAVA_HOME}/bin:$PATH +java -version +## end of Java switching + +mkdir freshly-baked +unzip -qo ../target/universal/sbt.zip -d ./freshly-baked + +SBT_OPTS=-Dfile.encoding=UTF-8 + +./freshly-baked/sbt/bin/sbt about run diff --git a/project/build.properties b/project/build.properties index 3689a86a2..c091b86ca 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1 @@ sbt.version=0.13.16 - From 66b8670c59c425e309fc932cd4e214841a6ca641 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 15 Feb 2018 13:02:03 -0500 Subject: [PATCH 308/483] Add macOS testing --- .travis.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 186b785db..84a1ba6cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,18 +12,30 @@ matrix: - script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin - cd citest && ./test.sh + jdk: oraclejdk8 + + ## build using JDK 8, test using JDK 8, on macOS + - script: + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin + - cd citest && ./test.sh + ## https://github.com/travis-ci/travis-ci/issues/2316 + language: java + os: osx + osx_image: xcode9.2 ## build using JDK 8, test using JDK 9 - script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin - jdk_switcher use oraclejdk9 - cd citest && ./test.sh + jdk: oraclejdk8 ## build using JDK 8, test using JDK 10 - script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin - citest/install-jdk10.sh - cd citest && ./test.sh + jdk: oraclejdk8 - script: - sbt -Dsbt.build.version=$SBT_VER rpm:packageBin debian:packageBin @@ -32,16 +44,18 @@ matrix: packages: - fakeroot - rpm + jdk: oraclejdk8 scala: - 2.10.7 -jdk: - - oraclejdk8 - -# Undo _JAVA_OPTIONS environment variable -before_script: - - _JAVA_OPTIONS= +before_install: + # https://github.com/travis-ci/travis-ci/issues/8408 + - unset _JAVA_OPTIONS + - if [[ "$TRAVIS_OS_NAME" = "osx" ]]; then + brew update; + brew install sbt; + fi cache: directories: From 21cf71e384b8d3dba4c56d167837a9236d294c9d Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 15 Feb 2018 19:33:18 -0500 Subject: [PATCH 309/483] more portable jdk_version function I've reimplemented java version detection as a bash function. This no longer uses grep. Also this no longer uses `?` in sed, which doesn't work on macOS. Fixes https://github.com/sbt/sbt/issues/3873 --- src/universal/bin/sbt-launch-lib.bash | 30 ++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 00280ac5b..37127e7e2 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -146,6 +146,32 @@ is_function_defined() { declare -f "$1" > /dev/null } +# parses JDK version from the -version output line. +# 8 for 1.8.0_nn, 9 for 9-ea etc, and "no_java" for undetected +jdk_version() { + local result + local lines=$("$java_cmd" -Xms32M -Xmx32M -version 2>&1 | tr '\r' '\n') + local IFS=$'\n' + for line in $lines; do + if [[ (-z $result) && ($line = *"version \""*) ]] + then + local ver=$(echo $line | sed -e 's/.*version "\(.*\)"\(.*\)/\1/; 1q') + # on macOS sed doesn't support '?' + if [[ $ver = "1."* ]] + then + result=$(echo $ver | sed -e 's/1\.\([0-9]*\)\(.*\)/\1/; 1q') + else + result=$(echo $ver | sed -e 's/\([0-9]*\)\(.*\)/\1/; 1q') + fi + fi + done + if [[ -z $result ]] + then + result=no_java + fi + echo "$result" +} + process_args () { while [[ $# -gt 0 ]]; do case "$1" in @@ -179,9 +205,7 @@ process_args () { process_my_args "${myargs[@]}" } - ## parses java version from the -version output line - ## https://regex101.com/r/0r3kKb/1/tests - java_version=$("$java_cmd" -Xms128M -Xmx512M -version 2>&1 | tr '\r' '\n' | grep ' version "' | sed 's/.*version "\(1\.\)\?\([0-9]*\)\{0,1\}\(.*\)*/\2/; 1q') + java_version="$(jdk_version)" vlog "[process_args] java_version = '$java_version'" } From 3019b94da0f6146b9dab3f144c44321c84563e39 Mon Sep 17 00:00:00 2001 From: Friedrich von Never Date: Sat, 17 Feb 2018 21:56:09 +0700 Subject: [PATCH 310/483] Fix quotes in sbt.bat --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 237accc05..13087fe38 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -166,7 +166,7 @@ if /I "%JAVA_VERSION%" GEQ "1.8" ( REM echo %PRELOAD_SBT_JAR% if not exist %PRELOAD_SBT_JAR% ( if exist "%SBT_HOME%\..\lib\local-preloaded\" ( - echo 'about to robocopy' + echo "about to robocopy" robocopy "%SBT_HOME%\..\lib\local-preloaded" "%UserProfile%\.sbt\preloaded" /E ) ) From 94b27fcefad6db1f81f9e4c89acb3562ef560ae8 Mon Sep 17 00:00:00 2001 From: Deokhwan Kim Date: Sat, 17 Feb 2018 09:38:52 -0500 Subject: [PATCH 311/483] Confirm a user's intent if the current dir doesn't look like an sbt dir Fixes #212 --- src/universal/bin/sbt | 19 +++++++++++++++++++ src/universal/bin/sbt.bat | 28 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 9070dab7c..2be3f7c69 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -127,12 +127,31 @@ process_my_args () { -sbt-create) sbt_create=true && shift ;; + new) sbt_new=true && addResidual "$1" && shift ;; + *) addResidual "$1" && shift ;; esac done # Now, ensure sbt version is used. [[ "${sbt_version}XXX" != "XXX" ]] && addJava "-Dsbt.version=$sbt_version" + + # Confirm a user's intent if the current directory does not look like an sbt + # top-level directory and neither the -sbt-create option nor the "new" + # command was given. + [[ -f ./build.sbt || -d ./project || -n "$sbt_create" || -n "$sbt_new" ]] || { + echo "[warn] Neither build.sbt nor a 'project' directory in the current directory: $(pwd)" + while true; do + echo 'c) continue' + echo 'q) quit' + + read -p '? ' || exit 1 + case "$REPLY" in + c|C) break ;; + q|Q) exit 1 ;; + esac + done + } } loadConfigFile() { diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 237accc05..2569b4e6c 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -68,6 +68,9 @@ if "%~1" == "-jvm-debug" ( if not "%~1" == "!JVM_DEBUG_PORT!" ( set SBT_ARGS=!SBT_ARGS! %1 ) +) else if /I "%~1" == "new" ( + set sbt_new=true + set SBT_ARGS=!SBT_ARGS! %1 ) else ( set SBT_ARGS=!SBT_ARGS! %1 ) @@ -76,6 +79,31 @@ shift goto args_loop :args_end +rem Confirm a user's intent if the current directory does not look like an sbt +rem top-level directory and the "new" command was not given. +if not exist build.sbt ( + if not exist project\ ( + if not defined sbt_new ( + echo [warn] Neither build.sbt nor a 'project' directory in the current directory: %CD% + setlocal +:confirm + echo c^) continue + echo q^) quit + + set /P reply=?^ + if /I "!reply!" == "c" ( + goto confirm_end + ) else if /I "!reply!" == "q" ( + exit /B 1 + ) + + goto confirm +:confirm_end + endlocal + ) + ) +) + if defined JVM_DEBUG_PORT ( set _JAVA_OPTS=!_JAVA_OPTS! -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=!JVM_DEBUG_PORT! ) From 7d826e05d55b9c4931d16f95af8205193ca1a5a6 Mon Sep 17 00:00:00 2001 From: Mathias Bogaert Date: Fri, 16 Mar 2018 12:41:26 +0100 Subject: [PATCH 312/483] Support SBT 1.1+ for preloading the compiler interface --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 15f0da0f4..7cf7e4393 100644 --- a/build.sbt +++ b/build.sbt @@ -318,7 +318,7 @@ lazy val dist = (project in file("dist")) exportRepo := { val old = exportRepo.value sbtVersionToRelease match { - case v if v.startsWith("1.0.") => + case v if v.startsWith("1.") => val zincBase = exportRepoDirectory.value / "org.scala-sbt" / "zinc_2.12" val zincVersion = (zincBase * DirectoryFilter).get.head.getName val utilBase = exportRepoDirectory.value / "org.scala-sbt" / "util-logging_2.12" From a638ad49ac484ba87e512f6dfebf8aa83e4b3ad7 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 5 Apr 2018 20:47:18 -0400 Subject: [PATCH 313/483] Fix bash number comparison This adds JDK 10 and 11 testing on Linux --- .travis.yml | 8 +- citest/install-jdk.sh | 167 ++++++++++++++++++++++++++ citest/install-jdk10.sh | 20 --- src/universal/bin/sbt-launch-lib.bash | 6 +- 4 files changed, 174 insertions(+), 27 deletions(-) create mode 100755 citest/install-jdk.sh delete mode 100755 citest/install-jdk10.sh diff --git a/.travis.yml b/.travis.yml index 84a1ba6cd..b1f6cad6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,17 +23,17 @@ matrix: os: osx osx_image: xcode9.2 - ## build using JDK 8, test using JDK 9 + ## build using JDK 8, test using OpenJDK 10 - script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin - - jdk_switcher use oraclejdk9 + - citest/install-jdk.sh -F 10 - cd citest && ./test.sh jdk: oraclejdk8 - ## build using JDK 8, test using JDK 10 + ## build using JDK 8, test using OpenJDK 11 - script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin - - citest/install-jdk10.sh + - citest/install-jdk.sh -F 11 - cd citest && ./test.sh jdk: oraclejdk8 diff --git a/citest/install-jdk.sh b/citest/install-jdk.sh new file mode 100755 index 000000000..a22b44c29 --- /dev/null +++ b/citest/install-jdk.sh @@ -0,0 +1,167 @@ +#!/usr/bin/env bash + +# +# Install JDK for Linux +# +# This script determines the most recent early-access build number, +# downloads the JDK archive to the user home directory and extracts +# it there. +# +# Example usage +# +# install-jdk.sh -D | only gather and print variable values +# install-jdk.sh | install most recent (early-access) OpenJDK +# install-jdk.sh -W /usr/opt | install most recent (early-access) OpenJDK to /usr/opt +# install-jdk.sh -C | install most recent (early-access) OpenJDK with linked system CA certificates +# install-jdk.sh -F 9 | install most recent OpenJDK 9 +# install-jdk.sh -F 10 | install most recent OpenJDK 10 +# install-jdk.sh -F 11 | install most recent OpenJDK 11 +# install-jdk.sh -F 11 -L BCL | install most recent Oracle JDK 11 +# +# Options +# +# -D | Dry-run, only gather and print variable values +# -F f | Feature number of the JDK release [9|10|...|?] +# -L l | License of the JDK [GPL|BCL] +# -W w | Working directory and install path [${HOME}] +# -C | Use system CA certificates (currently only Debian/Ubuntu is supported) +# +# Exported environment variables +# +# JAVA_HOME is set to the extracted JDK directory +# PATH is prepended with ${JAVA_HOME}/bin +# +# (C) 2018 Christian Stein +# +# https://github.com/sormuras/bach/blob/master/install-jdk.sh +# +set -e + +VERSION='2018-04-05' +DRY_RUN='0' +LINK_SYSTEM_CACERTS='0' + +JDK_FEATURE='?' +JDK_BUILD='?' +JDK_LICENSE='GPL' +JDK_WORKSPACE=${HOME} +JDK_DOWNLOAD='https://download.java.net/java' +JDK_ORACLE='http://download.oracle.com/otn-pub/java/jdk' + +echo "install-jdk.sh (${VERSION})" + +# +# Parse command line options +# +while getopts ':F:L:W:CD' option; do + case "${option}" in + D) DRY_RUN='1';; + C) LINK_SYSTEM_CACERTS='1';; + F) JDK_FEATURE=${OPTARG};; + L) JDK_LICENSE=${OPTARG};; + W) JDK_WORKSPACE=${OPTARG};; + :) echo "Option -${OPTARG} requires an argument."; exit 1;; + \?) echo "Invalid option: -${OPTARG}"; exit 1;; + esac +done + +# +# Determine latest (early access or release candidate) number. +# +LATEST='11' +TMP=${LATEST} +while [ "${TMP}" != '99' ] +do + CODE=$(curl -o /dev/null --silent --head --write-out %{http_code} http://jdk.java.net/${TMP}) + if [ "${CODE}" -ge '400' ]; then + break + fi + LATEST=${TMP} + TMP=$[${TMP} +1] +done + +# +# Sanity checks. +# +if [ "${JDK_FEATURE}" == '?' ]; then + JDK_FEATURE=${LATEST} +fi +if [ "${JDK_FEATURE}" -lt '9' ] || [ "${JDK_FEATURE}" -gt "${LATEST}" ]; then + echo "Expected JDK_FEATURE number in range of [9..${LATEST}], but got: ${JDK_FEATURE}" + exit 1 +fi + +# +# Determine URL... +# +JDK_URL=$(wget -qO- http://jdk.java.net/${JDK_FEATURE} | grep -Eo 'href[[:space:]]*=[[:space:]]*"[^\"]+"' | grep -Eo '(http|https)://[^"]+') +if [ "${JDK_FEATURE}" == "${LATEST}" ]; then + JDK_URL=$(echo "${JDK_URL}" | grep -Eo "${JDK_DOWNLOAD}/.+/jdk${JDK_FEATURE}/.+/${JDK_LICENSE}/.*jdk-${JDK_FEATURE}.+linux-x64_bin.tar.gz$") +else + JDK_URL=$(echo "${JDK_URL}" | grep -Eo "${JDK_DOWNLOAD}/.+/jdk${JDK_FEATURE}/.+/.*jdk-${JDK_FEATURE}.+linux-x64_bin.tar.gz$") + if [ "${JDK_LICENSE}" == 'BCL' ]; then + case "${JDK_FEATURE}" in + 9) JDK_URL="${JDK_ORACLE}/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz";; + 10) JDK_URL="${JDK_ORACLE}/10+46/76eac37278c24557a3c4199677f19b62/jdk-10_linux-x64_bin.tar.gz";; + esac + fi +fi + +# +# Inspect URL properties. +# +JDK_ARCHIVE=$(basename ${JDK_URL}) +JDK_STATUS=$(curl -o /dev/null --silent --head --write-out %{http_code} ${JDK_URL}) + +# +# Print variables and exit if dry-run is active. +# +echo " FEATURE = ${JDK_FEATURE}" +echo " LICENSE = ${JDK_LICENSE}" +echo " ARCHIVE = ${JDK_ARCHIVE}" +echo " URL = ${JDK_URL} [${JDK_STATUS}]" +echo +if [ "${DRY_RUN}" == '1' ]; then + exit 0 +fi + +# +# Create any missing intermediate paths, switch to workspace, download, unpack, switch back. +# +mkdir -p ${JDK_WORKSPACE} +cd ${JDK_WORKSPACE} +wget --continue --header "Cookie: oraclelicense=accept-securebackup-cookie" ${JDK_URL} +file ${JDK_ARCHIVE} +JDK_HOME=$(tar --list --auto-compress --file ${JDK_ARCHIVE} | head -1 | cut -f1 -d"/") +tar --extract --auto-compress --file ${JDK_ARCHIVE} +cd ${OLDPWD} + +# +# Update environment variables. +# +export JAVA_HOME=${JDK_WORKSPACE}/${JDK_HOME} +export PATH=${JAVA_HOME}/bin:$PATH + +# +# Link to system certificates. +# - http://openjdk.java.net/jeps/319 +# - https://bugs.openjdk.java.net/browse/JDK-8196141 +# +if [ "${LINK_SYSTEM_CACERTS}" == '1' ]; then + mv "${JAVA_HOME}/lib/security/cacerts" "${JAVA_HOME}/lib/security/cacerts.jdk" + # TODO: Support for other distros than Debian/Ubuntu could be provided + ln -s /etc/ssl/certs/java/cacerts "${JAVA_HOME}/lib/security/cacerts" +fi + +# +# Test-drive. +# +echo +java --version +echo + +# +# Always print value of JAVA_HOME as last line. +# Usage from other scripts or shell: JAVA_HOME=$(./install-jdk.sh -L GPL | tail -n 1) +# +echo ${JAVA_HOME} diff --git a/citest/install-jdk10.sh b/citest/install-jdk10.sh deleted file mode 100755 index 0693a6890..000000000 --- a/citest/install-jdk10.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# copied from https://github.com/junit-team/junit5/blob/master/src/install/install-jdk-10.sh - -set -e - -JDK_FEATURE=10 -TMP=$(curl -L jdk.java.net/${JDK_FEATURE}) # extract most recent "JDK_BUILD" number from web page source... -TMP="${TMP#*Most recent build: jdk-${JDK_FEATURE}+}" # remove everything before the number -TMP="${TMP%%<*}" # remove everything after the number -JDK_BUILD="$(echo -e "${TMP}" | tr -d '[:space:]')" # remove all whitespace -JDK_ARCHIVE=jdk-${JDK_FEATURE}+${JDK_BUILD}_linux-x64_bin.tar.gz - -cd ~ -wget http://download.java.net/java/jdk${JDK_FEATURE}/archive/${JDK_BUILD}/BCL/${JDK_ARCHIVE} -tar -xzf ${JDK_ARCHIVE} -export JAVA_HOME=~/jdk-${JDK_FEATURE} -export PATH=${JAVA_HOME}/bin:$PATH -cd - -java --version diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 37127e7e2..c03c7a771 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -106,19 +106,19 @@ get_mem_opts () { (( $codecache > 128 )) || codecache=128 (( $codecache < 512 )) || codecache=512 local class_metadata_size=$(( $codecache * 2 )) - local class_metadata_opt=$([[ "$java_version" < "8" ]] && echo "MaxPermSize" || echo "MaxMetaspaceSize") + local class_metadata_opt=$((( $java_version < 8 )) && echo "MaxPermSize" || echo "MaxMetaspaceSize") local arg_xms=$([[ "${java_args[@]}" == *-Xms* ]] && echo "" || echo "-Xms${mem}m") local arg_xmx=$([[ "${java_args[@]}" == *-Xmx* ]] && echo "" || echo "-Xmx${mem}m") local arg_rccs=$([[ "${java_args[@]}" == *-XX:ReservedCodeCacheSize* ]] && echo "" || echo "-XX:ReservedCodeCacheSize=${codecache}m") - local arg_meta=$([[ "${java_args[@]}" == *-XX:${class_metadata_opt}* && ! "$java_version" < "8" ]] && echo "" || echo "-XX:${class_metadata_opt}=${class_metadata_size}m") + local arg_meta=$([[ "${java_args[@]}" == *-XX:${class_metadata_opt}* && ! (( $java_version < 8 )) ]] && echo "" || echo "-XX:${class_metadata_opt}=${class_metadata_size}m") echo "${arg_xms} ${arg_xmx} ${arg_rccs} ${arg_meta}" fi } get_gc_opts () { - local older_than_9="$(expr $java_version "<" 9)" + local older_than_9=$(( $java_version < 9 )) if [[ "$older_than_9" == "1" ]]; then # don't need to worry about gc From b2fdb7685fc05f202f3b88536e4b07d61eb06419 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 5 Apr 2018 20:53:11 -0400 Subject: [PATCH 314/483] Fix Java version detection on Windows Fixes https://github.com/sbt/sbt/issues/4055 Adds JDK 10 testing on Windows --- .appveyor.yml | 4 ++-- citest/test.bat | 4 ++-- citest/test1.bat | 4 ++-- citest/test2.bat | 4 ++-- citest/test3/test3.bat | 4 ++-- src/universal/bin/sbt.bat | 33 +++++++++++++++++---------------- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index c822f2293..ef6d53c05 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,7 +5,7 @@ init: install: - cinst jdk8 -params 'installdir=C:\\jdk8' - - cinst jdk9 -version 9.0.4.11 -params 'installdir=C:\\jdk9' + - cinst jdk10 -params 'installdir=C:\\jdk10' - SET JAVA_HOME=C:\jdk8 - SET PATH=C:\jdk8\bin;%PATH% @@ -22,7 +22,7 @@ install: - SET SBT_OPTS=-XX:MaxPermSize=2g -Xmx4g -Dfile.encoding=UTF8 test_script: - - sbt "-Dsbt.build.version=1.0.4" universal:packageBin + - sbt "-Dsbt.build.version=1.1.2" universal:packageBin - cd citest - test.bat - test1.bat diff --git a/citest/test.bat b/citest/test.bat index 7d35a6ca6..f1a372b55 100644 --- a/citest/test.bat +++ b/citest/test.bat @@ -9,8 +9,8 @@ SETLOCAL "freshly-baked\sbt\bin\sbt" about -SET JAVA_HOME=C:\jdk9 -SET PATH=C:\jdk9\bin;%PATH% +SET JAVA_HOME=C:\jdk10 +SET PATH=C:\jdk10\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 "freshly-baked\sbt\bin\sbt" about diff --git a/citest/test1.bat b/citest/test1.bat index b02954cd9..a0bbd1169 100644 --- a/citest/test1.bat +++ b/citest/test1.bat @@ -2,8 +2,8 @@ SETLOCAL -SET JAVA_HOME=C:\jdk9 -SET PATH=C:\jdk9\bin;%PATH% +SET JAVA_HOME=C:\jdk10 +SET PATH=C:\jdk10\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 "freshly-baked\sbt\bin\sbt" about 1> output.txt 2> err.txt diff --git a/citest/test2.bat b/citest/test2.bat index b02598217..4a7301ee9 100644 --- a/citest/test2.bat +++ b/citest/test2.bat @@ -2,8 +2,8 @@ SETLOCAL -SET JAVA_HOME=C:\jdk9 -SET PATH=C:\jdk9\bin;%PATH% +SET JAVA_HOME=C:\jdk10 +SET PATH=C:\jdk10\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 "freshly-baked\sbt\bin\sbt" check diff --git a/citest/test3/test3.bat b/citest/test3/test3.bat index 8b3fe5a94..e70f4e38c 100644 --- a/citest/test3/test3.bat +++ b/citest/test3/test3.bat @@ -2,8 +2,8 @@ SETLOCAL -SET JAVA_HOME=C:\jdk9 -SET PATH=C:\jdk9\bin;%PATH% +SET JAVA_HOME=C:\jdk10 +SET PATH=C:\jdk10\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 SET BASE_DIR=%CD% diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 13087fe38..ff8507716 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -99,24 +99,25 @@ goto end goto :eof :process -rem parses 1.7, 1.8, 9, etc out of java version "1.8.0_91" -"%_JAVACMD%" -Xmx512M -version 2> "%TEMP%\out.txt" +rem Parses x out of 1.x; for example 8 out of java version 1.8.0_xx +rem Otherwise, parses the major version; 9 out of java version 9-ea set JAVA_VERSION=0 ->nul findstr /c:"version \"9" "%TEMP%\out.txt" -if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=9) ->nul findstr /c:"version \"1.8" "%TEMP%\out.txt" -if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.8) ->nul findstr /c:"version \"1.7" "%TEMP%\out.txt" -if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.7) ->nul findstr /c:"version \"1.6" "%TEMP%\out.txt" -if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.6) ->nul findstr /c:"version \"1.5" "%TEMP%\out.txt" -if /I %ERRORLEVEL% EQU 0 (set JAVA_VERSION=1.5) +for /f "tokens=3" %%g in ('%_JAVACMD% -Xms32M -Xmx32M -version 2^>^&1 ^| findstr /i "version"') do ( + set JAVA_VERSION=%%g +) +set JAVA_VERSION=%JAVA_VERSION:"=% +for /f "delims=.-_ tokens=1-2" %%v in ("%JAVA_VERSION%") do ( + if /I "%%v" EQU "1" ( + set JAVA_VERSION=%%w + ) else ( + set JAVA_VERSION=%%v + ) +) exit /B 0 :checkjava -set required_version=1.6 -if /I "%JAVA_VERSION%" GEQ "%required_version%" ( +set required_version=6 +if /I %JAVA_VERSION% GEQ %required_version% ( exit /B 0 ) echo. @@ -130,7 +131,7 @@ echo. exit /B 1 :copyrt -if /I "%JAVA_VERSION%" GEQ "9" ( +if /I %JAVA_VERSION% GEQ 9 ( set rtexport=!SBT_HOME!java9-rt-export.jar "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "!rtexport!" --rt-ext-dir > "%TEMP%.\rtext.txt" @@ -160,7 +161,7 @@ if "%INIT_SBT_VERSION%"=="" ( ) ) set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org.scala-sbt\sbt\%INIT_SBT_VERSION%\jars\sbt.jar" -if /I "%JAVA_VERSION%" GEQ "1.8" ( +if /I %JAVA_VERSION% GEQ 8 ( where robocopy >nul 2>nul if %ERRORLEVEL% equ 0 ( REM echo %PRELOAD_SBT_JAR% From 8727faa8b37066c7570457931854195d285675c0 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 6 Apr 2018 08:26:28 -0400 Subject: [PATCH 315/483] forward -debug to sbt `-debug` is a legitimate command since 0.13.13, but it's been impossible to use it because Bash eats it. This allows log level to be set to debug level. (similar to `-warn` setting to warn level) Ref https://github.com/sbt/sbt/pull/2742 --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index c03c7a771..2a106a225 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -177,7 +177,7 @@ process_args () { case "$1" in -h|-help) usage; exit 1 ;; -v|-verbose) verbose=1 && shift ;; - -d|-debug) debug=1 && shift ;; + -d|-debug) debug=1 && addSbt "-debug" && shift ;; -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; From d70c78d02b2901be54a3f68b789661162afbc435 Mon Sep 17 00:00:00 2001 From: Jean-Luc Deprez Date: Tue, 10 Apr 2018 16:12:28 +0200 Subject: [PATCH 316/483] - Java version detection broken, when path to JDK contains spaces. Allways outputs: sbt requires at least version 6+, you have version 0 - the quoted version word for findstr doesn't seem to work in the for-command statement, quotes not needed for a single word. --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index ff8507716..2171de9f4 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -102,7 +102,7 @@ goto :eof rem Parses x out of 1.x; for example 8 out of java version 1.8.0_xx rem Otherwise, parses the major version; 9 out of java version 9-ea set JAVA_VERSION=0 -for /f "tokens=3" %%g in ('%_JAVACMD% -Xms32M -Xmx32M -version 2^>^&1 ^| findstr /i "version"') do ( +for /f "tokens=3" %%g in ('"%_JAVACMD%" -Xms32M -Xmx32M -version 2^>^&1 ^| findstr /i version') do ( set JAVA_VERSION=%%g ) set JAVA_VERSION=%JAVA_VERSION:"=% From 6ffec60e4b8ba7ec39758b384cd2f7ce4036aeda Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Fri, 20 Apr 2018 11:07:23 +1200 Subject: [PATCH 317/483] sbt.bat: JAVACMD is not quoted in version check This fixes a failed version check for a path containing spaces. --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index ff8507716..7862b1e8e 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -102,7 +102,7 @@ goto :eof rem Parses x out of 1.x; for example 8 out of java version 1.8.0_xx rem Otherwise, parses the major version; 9 out of java version 9-ea set JAVA_VERSION=0 -for /f "tokens=3" %%g in ('%_JAVACMD% -Xms32M -Xmx32M -version 2^>^&1 ^| findstr /i "version"') do ( +for /f "tokens=3" %%g in ('"%_JAVACMD%" -Xms32M -Xmx32M -version 2^>^&1 ^| findstr /i "version"') do ( set JAVA_VERSION=%%g ) set JAVA_VERSION=%JAVA_VERSION:"=% From aeab95905478d618f7a592d3507f95270948e235 Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Fri, 4 May 2018 17:27:02 +0200 Subject: [PATCH 318/483] Add uploader script --- upload/sbt-upload.sh | 317 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 317 insertions(+) create mode 100755 upload/sbt-upload.sh diff --git a/upload/sbt-upload.sh b/upload/sbt-upload.sh new file mode 100755 index 000000000..b51ffd1b9 --- /dev/null +++ b/upload/sbt-upload.sh @@ -0,0 +1,317 @@ +#!/usr/bin/env bash + +# +# This script will upload an sbt distribution (tar/tgz/msi and +# checksump files) to IBM Cloud Object Storage with the correct +# permissions, and prepare the shortened URLs on the "piccolo.link" +# Polr server. +# + +# +# Required env vars: +# +# S3KEY -- API Key for the sbt-distribution-archive bucket +# S3SECRET -- Secret corresponding to the API Key +# +# POLR_USERNAME -- Username for the polr shortener +# POLR_PASSWORD -- Password for the polr shortener +# + +S3KEY='...' +S3SECRET='...' +POLR_USERNAME='...' +POLR_PASSWORD='...' + +# Where to find the above information: +# - for S3KEY/S3SECRET, you need the API credentials for the +# 'sbt-downloads' buckets on IBM's COS. Please ask @cunei for +# details. +# +# Once you have S3KEY/S3SECRET, you can (and should) use those +# values also in your favorite S3 GUI browser (like CyberDuck +# or DragonDisk), in order to verify that the files are correctly +# uploaded, or to perform maintenance within the storage bucket. +# +# Note: do *not* use an S3 GUI to upload files, since that will set +# the permissions incorrectly, and the CDN will be unable to access +# the files. +# +# - for POLR_USERNAME/POLR_PASSWORD, you will need the credentials +# on "piccolo.link" for the user "lightbend-tools". Ask @cunei +# for details. Note: do not create a personal account to generate +# the short URLs: they are linked to the user that creates them +# and they would not appear in the "lightbend-tools" dashboard. +# + +# Once you have set correctly the four vars above, please call +# this script as follows: +# +# If your files have this directory structure: +# +# here +# here/v0.13.15 +# here/v0.13.15/sbt-0.13.15.msi +# here/v0.13.15/sbt-0.13.15.zip.asc +# here/v0.13.15/sbt-0.13.15.tgz.asc +# here/v0.13.15/sbt-0.13.15.tgz +# here/v0.13.15/sbt-0.13.15.zip +# here/v0.13.15/sbt-0.13.15.msi.asc +# +# +# then "cd here", then: +# +# $ .../sbt-upload.sh v0.13.15 [v0.13.16 ...] +# +# Where one or more directories are specified. Each directory name +# must be the letter 'v' plus a release version. The files within +# each directory can be named arbitrarily, and live in any +# subdirectory. +# +# Please note that the script will try to store temporary cookies +# and other info in a directory called "cookies", which will be +# created in the same directory as this script. +# +#-------------------------------------------------------------- +# +set -o pipefail + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +usageAndExit() { + echo 'Usage: "'${0##*/}' [ ...]"' + echo "where the final path component of each RELEASEDIR" + echo "must be 'v' plus"' a release number, for example: "v0.13.15".' + echo 'This script will leave some cookie files in a directory' + echo 'called "cookies", in the same location as the script.' + exit 1 +} + + +if [[ "$#" < 1 ]] +then + usageAndExit +fi +RELEASE_DIRS=("${@:1}") +for RELEASE_DIR in "${RELEASE_DIRS[@]}" +do + RELEASE_TAG="$(basename "$RELEASE_DIR")" + if [[ "${RELEASE_TAG:0:1}" != 'v' || ! -d "${RELEASE_DIR}" ]] + then + usageAndExit + fi +done + + +POLR_DOMAIN_NAME="${POLR_DOMAIN_NAME:-piccolo.link}" +POLR_URL="https://$POLR_DOMAIN_NAME" +POLR_LOGIN_URL="$POLR_URL/login" +POLR_SHORTEN_URL="$POLR_URL/shorten" + +# Let's try to login into Polr + +# Prepare a work directory to store the cookies into +COOKIEDIR="${SCRIPTDIR}/cookies" +mkdir -p "${COOKIEDIR}" +HOME_COOKIES_PATH="${COOKIEDIR}/home-cookies" +LOGIN_COOKIES_PATH="${COOKIEDIR}/login-cookies" +CSRF_TOKEN_PATH="${COOKIEDIR}/csrf-token" + +# Access home page to get tokens. +RESPONSE="$( + curl -si "$POLR_URL" \ + --cookie-jar "$HOME_COOKIES_PATH" +)" +CODE="$(echo "$RESPONSE" | head -1 | awk '{print $2}')" +if [ -z "$CODE" -o "$CODE" -ne 200 ] +then + echo "ERROR: Could not load $POLR_URL; aborting." + echo -e "Response:\n$RESPONSE" + exit 1 +fi + +TOKEN="$(echo "$RESPONSE" | grep "_token" | \ + sed -E "s/.+value='([a-zA-Z0-9]+)'.+/\1/")" +if [ -z "$TOKEN" ] +then + echo "ERROR: Could not find auth token; aborting." + exit 1 +fi + +# Save CSRF token. +CSRF_TOKEN="$(echo "$RESPONSE" | grep "csrf-token" | \ + sed -E 's/.+content="([a-zA-Z0-9]+)".+/\1/')" +if [ -z "$CSRF_TOKEN" ] +then + echo "ERROR: Could not find CSRF token; aborting." + exit 1 +fi + +echo "$CSRF_TOKEN" > "$CSRF_TOKEN_PATH" + +# Login and save cookie. +RESPONSE="$( + curl -siX POST "$POLR_LOGIN_URL" \ + --cookie "$HOME_COOKIES_PATH" \ + --cookie-jar "$LOGIN_COOKIES_PATH" \ + -d "username=$POLR_USERNAME" \ + -d "password=$POLR_PASSWORD" \ + -d "_token=$TOKEN" \ + -d "login='Sign In'" +)" +CODE="$(echo "$RESPONSE" | head -1 | awk '{print $2}')" +if [ -z "$CODE" -o "$CODE" -ne 302 ] +then + echo "ERROR: Login failed; aborting." + echo -e "Response:\n$RESPONSE" + exit 1 +fi + +# +# OK! Now, let's process the files +# + +# +# Call this upload routine with: +# 1) relative path to the file from current dir. Do NOT use '..' or '.' in this path +# for example: uploadS3 "v1.1.4/sbt-1.1.4.tgz" +# assuming the file is in /v1.1.4/sbt-1.1.4.tgz +# +# The file will be placed in the appropriate S3 bucket, and will be visible +# as: https://sbt-downloads.cdnedge.bluemix.net/releases/v1.1.4/sbt-1.1.4.tgz +# +uploadS3() { + S3FILEPATH="$1" + if [[ -z "$S3FILEPATH" ]] + then + echo "Internal error! Please report." + return 1 + fi + S3BUCKET="sbt-distribution-archives" + S3HOST="s3-api.us-geo.objectstorage.softlayer.net" + S3RELATIVEPATH="/${S3BUCKET}/releases/${S3FILEPATH}" + S3CONTENTTYPE="$(file --brief --mime-type "$S3FILEPATH")" + S3NOWDATE="$(date -R)" + S3STRINGTOSIGN="PUT\n\n${S3CONTENTTYPE}\n${S3NOWDATE}\nx-amz-acl:public-read\n${S3RELATIVEPATH}" + S3SIGNATURE="$(echo -en ${S3STRINGTOSIGN} | openssl sha1 -hmac ${S3SECRET} -binary | base64)" + echo "Uploading $S3FILEPATH" + curl -X PUT -T "${S3FILEPATH}" \ + -H "Host: ${S3HOST}" \ + -H "Date: ${S3NOWDATE}" \ + -H "Content-Type: ${S3CONTENTTYPE}" \ + -H "x-amz-acl: public-read" \ + -H "Authorization: AWS ${S3KEY}:${S3SIGNATURE}" \ + "https://${S3HOST}${S3RELATIVEPATH}" + if [ $? -ne 0 ] + then + echo "Sorry, could not upload this file." + return 1 + fi +} + +shorten() { + # Arguments + URL="$1" + ENDING="$2" + TAGS=("${@:3}") + +# echo "Short requested: ${ENDING} -- tags: ${TAGS[@]}" +# Retrieve the CSRF token +# CSRF_TOKEN="$(cat "$CSRF_TOKEN_PATH")" + + TAG_LIST="" + if [ "${#TAGS[@]}" -gt 0 ]; then + for TAG in "${TAGS[@]}"; do # tag_list%5B%5D=$TAG + TAG_LIST="$TAG_LIST -d tag_list[]=$TAG" + done + fi + + RESPONSE="$( + curl -siX POST "$POLR_SHORTEN_URL" \ + --cookie "$LOGIN_COOKIES_PATH" \ + -H "X-CSRF-TOKEN: $CSRF_TOKEN" \ + --data-urlencode "link-url=$URL" \ + -d "custom-ending=$ENDING" \ + $TAG_LIST + )" + + CODE="$(echo "$RESPONSE" | head -n 1 | awk '{print $2}')" + if [ "$CODE" -ne 200 ] + then + echo "Could not shorten to: '$ENDING', creating a different link." + return 1 + fi + + SHORT_URL="$( + echo "$RESPONSE" | \ + egrep "value='http[s]?://$POLR_DOMAIN_NAME/" | \ + sed -E "s@.+value='(http[s]?://$POLR_DOMAIN_NAME/[-_\.0-9a-zA-Z]+)'.+@\1@" + )" + + echo "--> $SHORT_URL" | sed 's@http://@https://@' +} + +for RELEASE_DIR in "${RELEASE_DIRS[@]}" +do + RELEASE_TAG="$(basename "$RELEASE_DIR")" + cd "$(dirname "$RELEASE_DIR")" + find "$RELEASE_TAG" -type f -print | while read + do + echo + uploadS3 "$REPLY" + if [ $? -eq 0 ] + then + URL="https://sbt-downloads.cdnedge.bluemix.net/releases/${REPLY}" + echo "--> $URL" + # + # let's calculate the Polr tags. + # + # In Polr the tags can only be combined with 'or', therefore + # we need to subdivide them according to the combinations that + # might be needed. + # + # We add these tags: + # - if it is an 'asc' checksum file, "${TAG}_asc", "asc" + # - if it is a tar/tgz/tar.gz/txz/tar.xz/zip/msi/deb/rpm/dmg, "${TAG}_bin", "bin" + # - if it is another file, "${TAG}_other", "other" + # In any case, we add "${TAG}" + # + # so that: + # 1) "${TAG}_asc" + "${TAG}_bin" + "${TAG}_other" are the statistics + # for the entire "${TAG}" release + # 2) "bin" are all of the archives downloads + # 3) "bin" + "asc" + "other" are all of the downloads + # + if [[ "${REPLY}" == *.asc ]] + then + KIND="asc" + elif [[ "${REPLY}" == *.tar || \ + "${REPLY}" == *.tgz || \ + "${REPLY}" == *.tar.gz || \ + "${REPLY}" == *.txz || \ + "${REPLY}" == *.tar.xz || \ + "${REPLY}" == *.zip || \ + "${REPLY}" == *.msi || \ + "${REPLY}" == *.deb || \ + "${REPLY}" == *.rpm || \ + "${REPLY}" == *.dmg ]] + then + KIND="bin" + else + KIND="other" + fi + # First we try to shorten using just the file name. + # If that fails, we use an encoding of the entire path. + SHORT1="$(basename "$REPLY")" + shorten "$URL" "$SHORT1" "${RELEASE_TAG}_${KIND}" "${RELEASE_TAG}" "${KIND}" + if [[ $? != 0 ]] + then + SHORT2="${REPLY//\//_}" + shorten "$URL" "$SHORT2" "${RELEASE_TAG}_${KIND}" "${RELEASE_TAG}" "${KIND}" + if [[ $? != 0 ]] + then + echo "Sorry, could not create a short link." + fi + fi + fi + done +done From 27a9d90659dc717b712b20a1c1a52674dbddf7f0 Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Mon, 7 May 2018 17:17:29 +0200 Subject: [PATCH 319/483] Allow env vars defaults, rename S3 vars --- upload/sbt-upload.sh | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/upload/sbt-upload.sh b/upload/sbt-upload.sh index b51ffd1b9..cf4b53c83 100755 --- a/upload/sbt-upload.sh +++ b/upload/sbt-upload.sh @@ -10,24 +10,26 @@ # # Required env vars: # -# S3KEY -- API Key for the sbt-distribution-archive bucket -# S3SECRET -- Secret corresponding to the API Key +# SBT_DEPLOY_S3KEY -- API Key for the sbt-distribution-archive bucket +# SBT_DEPLOY_S3SECRET -- Secret corresponding to the API Key # # POLR_USERNAME -- Username for the polr shortener # POLR_PASSWORD -- Password for the polr shortener # - -S3KEY='...' -S3SECRET='...' -POLR_USERNAME='...' -POLR_PASSWORD='...' +# These environment vars can be either defined by the caller, or directly +# in the following lines, in place of the "your..." constants below. +# +SBT_DEPLOY_S3KEY="${SBT_DEPLOY_S3KEY:-yourSbtDeployS3key}" +SBT_DEPLOY_S3SECRET="${SBT_DEPLOY_S3SECRET:-yourSbtDeployS3secret}" +POLR_USERNAME="${POLR_USERNAME:-yourPolrUsername}" +POLR_PASSWORD="${POLR_PASSWORD:-yourPolrPassword}" # Where to find the above information: -# - for S3KEY/S3SECRET, you need the API credentials for the +# - for SBT_DEPLOY_S3KEY/SBT_DEPLOY_S3SECRET, you need the API credentials for the # 'sbt-downloads' buckets on IBM's COS. Please ask @cunei for # details. # -# Once you have S3KEY/S3SECRET, you can (and should) use those +# Once you have SBT_DEPLOY_S3KEY/SBT_DEPLOY_S3SECRET, you can (and should) use those # values also in your favorite S3 GUI browser (like CyberDuck # or DragonDisk), in order to verify that the files are correctly # uploaded, or to perform maintenance within the storage bucket. @@ -192,14 +194,14 @@ uploadS3() { S3CONTENTTYPE="$(file --brief --mime-type "$S3FILEPATH")" S3NOWDATE="$(date -R)" S3STRINGTOSIGN="PUT\n\n${S3CONTENTTYPE}\n${S3NOWDATE}\nx-amz-acl:public-read\n${S3RELATIVEPATH}" - S3SIGNATURE="$(echo -en ${S3STRINGTOSIGN} | openssl sha1 -hmac ${S3SECRET} -binary | base64)" + S3SIGNATURE="$(echo -en ${S3STRINGTOSIGN} | openssl sha1 -hmac ${SBT_DEPLOY_S3SECRET} -binary | base64)" echo "Uploading $S3FILEPATH" curl -X PUT -T "${S3FILEPATH}" \ -H "Host: ${S3HOST}" \ -H "Date: ${S3NOWDATE}" \ -H "Content-Type: ${S3CONTENTTYPE}" \ -H "x-amz-acl: public-read" \ - -H "Authorization: AWS ${S3KEY}:${S3SIGNATURE}" \ + -H "Authorization: AWS ${SBT_DEPLOY_S3KEY}:${S3SIGNATURE}" \ "https://${S3HOST}${S3RELATIVEPATH}" if [ $? -ne 0 ] then From d76459db699ab36d0d05418c8a8993c0e95822fa Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 9 May 2018 01:01:13 -0400 Subject: [PATCH 320/483] bump Scala 2.12.6 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 7cf7e4393..69aef56f3 100644 --- a/build.sbt +++ b/build.sbt @@ -279,13 +279,13 @@ def bintrayRelease(repo: BintrayRepo, pkg: String, version: String, log: Logger) lazy val scala210 = "2.10.7" -lazy val scala212 = "2.12.4" +lazy val scala212 = "2.12.6" lazy val scala210Jline = "org.scala-lang" % "jline" % scala210 lazy val jansi = { if (sbtVersionToRelease startsWith "1.") "org.fusesource.jansi" % "jansi" % "1.4" else "org.fusesource.jansi" % "jansi" % "1.4" } -lazy val scala212Jline = "jline" % "jline" % "2.14.5" +lazy val scala212Jline = "jline" % "jline" % "2.14.6" lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6" lazy val scala212Compiler = "org.scala-lang" % "scala-compiler" % scala212 lazy val sbtActual = "org.scala-sbt" % "sbt" % sbtVersionToRelease From c91c7984c908d05e1a2a4cc414a5c97fc40eb13c Mon Sep 17 00:00:00 2001 From: Jimin Hsieh Date: Wed, 30 May 2018 19:53:35 +0800 Subject: [PATCH 321/483] Bump sbt version --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index c091b86ca..133a8f197 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.16 +sbt.version=0.13.17 From 67fec3812c69e8cb4cd26bb59673dbe6fb023537 Mon Sep 17 00:00:00 2001 From: Jimin Hsieh Date: Wed, 30 May 2018 19:55:03 +0800 Subject: [PATCH 322/483] Bump license year --- LICENSE.txt | 2 +- src/debian/usr/share/doc/sbt/copyright | 2 +- src/linux/usr/share/doc/sbt/copyright | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 7f3a9b61e..563beedc6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,5 @@ // Generated from http://www.opensource.org/licenses/bsd-license.php -Copyright (c) 2011 - 2017, Paul Phillips, Lightbend, and other contributors. +Copyright (c) 2011 - 2018, Paul Phillips, Lightbend, and other contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/src/debian/usr/share/doc/sbt/copyright b/src/debian/usr/share/doc/sbt/copyright index 53987e201..f05b46cfb 100644 --- a/src/debian/usr/share/doc/sbt/copyright +++ b/src/debian/usr/share/doc/sbt/copyright @@ -10,7 +10,7 @@ https://github.com/sbt/sbt-launcher-package The entire code base may be distributed under the terms of the BSD license, which appears immediately below. -Copyright (c) 2011 - 2017, Paul Phillips, Lightbend, and other contributors. +Copyright (c) 2011 - 2018, Paul Phillips, Lightbend, and other contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/src/linux/usr/share/doc/sbt/copyright b/src/linux/usr/share/doc/sbt/copyright index 53987e201..f05b46cfb 100644 --- a/src/linux/usr/share/doc/sbt/copyright +++ b/src/linux/usr/share/doc/sbt/copyright @@ -10,7 +10,7 @@ https://github.com/sbt/sbt-launcher-package The entire code base may be distributed under the terms of the BSD license, which appears immediately below. -Copyright (c) 2011 - 2017, Paul Phillips, Lightbend, and other contributors. +Copyright (c) 2011 - 2018, Paul Phillips, Lightbend, and other contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: From bc8ed20787af6a24ef22354363e7e8dd57d528a0 Mon Sep 17 00:00:00 2001 From: Jimin Hsieh Date: Wed, 30 May 2018 22:46:28 +0800 Subject: [PATCH 323/483] Show default sbt memory size: 1024m --- src/universal/bin/sbt | 4 ++-- src/universal/bin/sbt-launch-lib.bash | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 9070dab7c..8b236bfa9 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -69,7 +69,7 @@ declare -r win_sbt_opts_file="${sbt_home}/conf/sbtconfig.txt" usage() { cat < path to global settings/plugins directory (default: ~/.sbt) -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) -ivy path to local Ivy repository (default: ~/.ivy2) - -mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) + -mem set memory options (default: $sbt_default_mem, which is $(get_mem_opts)) -no-share use all local caches; no sharing -no-global uses global caches, but does not use global ~/.sbt directory. -jvm-debug Turn on JVM debugging, open at the given port. diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 2a106a225..3be1f7e3d 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -13,6 +13,7 @@ declare -a sbt_commands declare java_cmd=java declare java_version declare init_sbt_version=_to_be_replaced +declare sbt_default_mem=1024 declare SCRIPT=$0 while [ -h "$SCRIPT" ] ; do @@ -101,7 +102,7 @@ get_mem_opts () { else # a ham-fisted attempt to move some memory settings in concert # so they need not be messed around with individually. - local mem=${1:-1024} + local mem=${1:-$sbt_default_mem} local codecache=$(( $mem / 8 )) (( $codecache > 128 )) || codecache=128 (( $codecache < 512 )) || codecache=512 From 46783d0cf5451432718f14ae6f8e3c2315abaa6c Mon Sep 17 00:00:00 2001 From: Jimin Hsieh Date: Wed, 30 May 2018 22:58:30 +0800 Subject: [PATCH 324/483] Update current `sbt -help` --- README.md | 73 ++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 31b42a8cd..29bc8962c 100644 --- a/README.md +++ b/README.md @@ -42,48 +42,45 @@ well as a snapshot version of scala, then run the sbt "about" command. [info] sbt, sbt plugins, and build definitions are using Scala 2.9.1 Current -help output: +```bash +Usage: sbt [options] - Usage: sbt [options] + -h | -help print this message + -v | -verbose this runner is chattier + -d | -debug set sbt log level to debug + -no-colors disable ANSI color codes + -sbt-create start sbt even if current directory contains no sbt project + -sbt-dir path to global settings/plugins directory (default: ~/.sbt) + -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) + -ivy path to local Ivy repository (default: ~/.ivy2) + -mem set memory options (default: 1024, which is -Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m -XX:MaxMetaspaceSize=256m) + -no-share use all local caches; no sharing + -no-global uses global caches, but does not use global ~/.sbt directory. + -jvm-debug Turn on JVM debugging, open at the given port. + -batch Disable interactive mode - -h | -help print this message - -v | -verbose this runner is chattier - -d | -debug set sbt log level to debug - -no-colors disable ANSI color codes - -sbt-create start sbt even if current directory contains no sbt project - -sbt-dir path to global settings/plugins directory (default: ~/.sbt) - -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) - -ivy path to local Ivy repository (default: ~/.ivy2) - -mem set memory options (default: 1536, which is -Xms1536m -Xmx1536m -XX:MaxPermSize=384m -XX:ReservedCodeCacheSize=192m) - -no-share use all local caches; no sharing - -offline put sbt in offline mode - -jvm-debug Turn on JVM debugging, open at the given port. + # sbt version (default: from project/build.properties if present, else latest release) + -sbt-version use the specified version of sbt + -sbt-jar use the specified jar as the sbt launcher + -sbt-rc use an RC version of sbt + -sbt-snapshot use a snapshot version of sbt - # sbt version (default: from project/build.properties if present, else latest release) - -sbt-version use the specified version of sbt - -sbt-jar use the specified jar as the sbt launcher - -sbt-rc use an RC version of sbt - -sbt-snapshot use a snapshot version of sbt - - # scala version (default: latest release) - -28 use 2.8.2 - -29 use 2.9.1 - -210 use 2.10.0-SNAPSHOT - -scala-home use the scala build at the specified directory - -scala-version use the specified version of scala - - # java version (default: java from PATH, currently java version "1.6.0_29") - -java-home alternate JAVA_HOME - - # jvm options and output control - JAVA_OPTS environment variable, if unset uses "-Dfile.encoding=UTF8" - SBT_OPTS environment variable, if unset uses "-XX:+CMSClassUnloadingEnabled" - .sbtopts if this file exists in the sbt root, it is prepended to the runner args - -Dkey=val pass -Dkey=val directly to the java runtime - -J-X pass option -X directly to the java runtime (-J is stripped) - - In the case of duplicated or conflicting options, the order above - shows precedence: JAVA_OPTS lowest, command line options highest. + # java version (default: java from PATH, currently openjdk version "1.8.0_172") + -java-home alternate JAVA_HOME + # jvm options and output control + JAVA_OPTS environment variable, if unset uses "" + .jvmopts if this file exists in the current directory, its contents + are appended to JAVA_OPTS + SBT_OPTS environment variable, if unset uses "" + .sbtopts if this file exists in the current directory, its contents + are prepended to the runner args + /usr/local/etc/sbtopts if this file exists, it is prepended to the runner args + -Dkey=val pass -Dkey=val directly to the java runtime + -J-X pass option -X directly to the java runtime + (-J is stripped) + -S-X add -X to sbt's scalacOptions (-S is stripped) +``` ## Native Packages ## From 1277e55c29002962e24f9d48dcfc875f623d128e Mon Sep 17 00:00:00 2001 From: Jimin Hsieh Date: Wed, 30 May 2018 22:37:25 +0800 Subject: [PATCH 325/483] Fix `sbt -help` throw `syntax error` --- src/universal/bin/sbt-launch-lib.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 3be1f7e3d..e7155a148 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -107,6 +107,9 @@ get_mem_opts () { (( $codecache > 128 )) || codecache=128 (( $codecache < 512 )) || codecache=512 local class_metadata_size=$(( $codecache * 2 )) + if [[ -z $java_version ]]; then + java_version=$(jdk_version) + fi local class_metadata_opt=$((( $java_version < 8 )) && echo "MaxPermSize" || echo "MaxMetaspaceSize") local arg_xms=$([[ "${java_args[@]}" == *-Xms* ]] && echo "" || echo "-Xms${mem}m") From 50886976134b28fc564d3eb4f8436079c8b6cb16 Mon Sep 17 00:00:00 2001 From: Jimin Hsieh Date: Wed, 30 May 2018 23:20:09 +0800 Subject: [PATCH 326/483] Add build status of AppVeyor --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 29bc8962c..02c9d90f2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Build Status [![Build Status](https://travis-ci.org/sbt/sbt-launcher-package.svg?branch=master)](https://travis-ci.org/sbt/sbt-launcher-package) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/sbt/sbt-launcher-package?branch=master&svg=true&retina=true)](https://ci.appveyor.com/project/sbt/sbt-launcher-package) sbt: the launcher ================== From 23b90f23a94efbff2205106b906cd7997cea3b43 Mon Sep 17 00:00:00 2001 From: Jimin Hsieh Date: Thu, 31 May 2018 16:37:25 +0800 Subject: [PATCH 327/483] Use default path of `sbtopts` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02c9d90f2..7e19fa695 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Usage: sbt [options] SBT_OPTS environment variable, if unset uses "" .sbtopts if this file exists in the current directory, its contents are prepended to the runner args - /usr/local/etc/sbtopts if this file exists, it is prepended to the runner args + /etc/sbt/sbtopts if this file exists, it is prepended to the runner args -Dkey=val pass -Dkey=val directly to the java runtime -J-X pass option -X directly to the java runtime (-J is stripped) From ea93158ae3e76e1abb6dd383e4d88fccd6bc9410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=A9=E6=9D=BE=20=E7=AB=9C=E4=B9=9F?= Date: Tue, 19 Jun 2018 01:13:31 +0900 Subject: [PATCH 328/483] Handle SBT_OPTS in bash --- src/universal/bin/sbt-launch-lib.bash | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index e7155a148..a69bff1d8 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -253,6 +253,24 @@ checkJava() { fi } +convertSbtOpts () { + while [[ $# -gt 0 ]]; do + case "$1" in + -no-colors) converted_opts="${converted_opts} -Dsbt.log.noformat=true" && shift ;; + -no-share) converted_opts="${converted_opts} $noshare_opts" && shift ;; + -no-global) converted_opts="${converted_opts} -Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;; + -sbt-boot) require_arg path "$1" "$2" && converted_opts="${converted_opts} -Dsbt.boot.directory=$2" && shift 2 ;; + -sbt-dir) require_arg path "$1" "$2" && converted_opts="${converted_opts} -Dsbt.global.base=$2" && shift 2 ;; + -debug-inc) converted_opts="${converted_opts} -Dxsbt.inc.debug=true" && shift ;; + -batch) exec =" 9)" if [[ "$at_least_9" == "1" ]]; then @@ -294,6 +312,14 @@ run() { # TODO - java check should be configurable... checkJava "6" + # handle SBT_OPTS options + if [ -n "$SBT_OPTS" ]; then + converted_opts="" + arrayed_sbt_opts=($SBT_OPTS) + convertSbtOpts ${arrayed_sbt_opts[@]} + SBT_OPTS=$converted_opts + fi + # Java 9 support copyRt From 53e008a25d6f32a67e62f4bf0cd21f0c08aac92c Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 30 Jul 2018 18:43:53 -0400 Subject: [PATCH 329/483] Revert "Handle SBT_OPTS in bash" This reverts commit ea93158ae3e76e1abb6dd383e4d88fccd6bc9410. --- src/universal/bin/sbt-launch-lib.bash | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index a69bff1d8..e7155a148 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -253,24 +253,6 @@ checkJava() { fi } -convertSbtOpts () { - while [[ $# -gt 0 ]]; do - case "$1" in - -no-colors) converted_opts="${converted_opts} -Dsbt.log.noformat=true" && shift ;; - -no-share) converted_opts="${converted_opts} $noshare_opts" && shift ;; - -no-global) converted_opts="${converted_opts} -Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;; - -sbt-boot) require_arg path "$1" "$2" && converted_opts="${converted_opts} -Dsbt.boot.directory=$2" && shift 2 ;; - -sbt-dir) require_arg path "$1" "$2" && converted_opts="${converted_opts} -Dsbt.global.base=$2" && shift 2 ;; - -debug-inc) converted_opts="${converted_opts} -Dxsbt.inc.debug=true" && shift ;; - -batch) exec =" 9)" if [[ "$at_least_9" == "1" ]]; then @@ -312,14 +294,6 @@ run() { # TODO - java check should be configurable... checkJava "6" - # handle SBT_OPTS options - if [ -n "$SBT_OPTS" ]; then - converted_opts="" - arrayed_sbt_opts=($SBT_OPTS) - convertSbtOpts ${arrayed_sbt_opts[@]} - SBT_OPTS=$converted_opts - fi - # Java 9 support copyRt From 4a8b1b97dbdda45eb10b0dfe08a8898f83cd10f3 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 30 Jul 2018 18:52:45 -0400 Subject: [PATCH 330/483] Test more SBT_OPTS --- citest/test.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/citest/test.sh b/citest/test.sh index 64d40c80a..5569842aa 100755 --- a/citest/test.sh +++ b/citest/test.sh @@ -17,6 +17,10 @@ java -version mkdir freshly-baked unzip -qo ../target/universal/sbt.zip -d ./freshly-baked -SBT_OPTS=-Dfile.encoding=UTF-8 +export SBT_OPTS=-Dfile.encoding=UTF-8 + +./freshly-baked/sbt/bin/sbt about run + +export SBT_OPTS="-Dfile.encoding=UTF-8 -Xms2048M -Xmx2048M -Xss2M -XX:MaxPermSize=512M" ./freshly-baked/sbt/bin/sbt about run From a82c8341982245141697a496a1b71a0b0336005a Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 8 Oct 2018 12:02:19 -0400 Subject: [PATCH 331/483] Scala 2.12.7 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 69aef56f3..d18d259b8 100644 --- a/build.sbt +++ b/build.sbt @@ -279,7 +279,7 @@ def bintrayRelease(repo: BintrayRepo, pkg: String, version: String, log: Logger) lazy val scala210 = "2.10.7" -lazy val scala212 = "2.12.6" +lazy val scala212 = "2.12.7" lazy val scala210Jline = "org.scala-lang" % "jline" % scala210 lazy val jansi = { if (sbtVersionToRelease startsWith "1.") "org.fusesource.jansi" % "jansi" % "1.4" From 88229e03ba1be0fc944b90c38031210c14ea4fb1 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 9 Oct 2018 18:44:41 -0400 Subject: [PATCH 332/483] Fix test on openjdk11 --- .travis.yml | 22 +++--- citest/install-jdk.sh | 167 ------------------------------------------ citest/test.sh | 8 -- 3 files changed, 12 insertions(+), 185 deletions(-) delete mode 100755 citest/install-jdk.sh diff --git a/.travis.yml b/.travis.yml index b1f6cad6d..451d7b8a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,12 @@ +sudo: false dist: trusty +group: stable language: scala env: global: - - SBT_VER=1.1.1 + - SBT_VER=1.2.4 matrix: include: @@ -23,17 +25,16 @@ matrix: os: osx osx_image: xcode9.2 - ## build using JDK 8, test using OpenJDK 10 - - script: - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin - - citest/install-jdk.sh -F 10 - - cd citest && ./test.sh - jdk: oraclejdk8 - ## build using JDK 8, test using OpenJDK 11 - - script: + - env: + - TRAVIS_JDK=openjdk@1.11.0 + - JABBA_HOME=/home/travis/.jabba + before_install: + - unset _JAVA_OPTIONS + - curl -sL https://raw.githubusercontent.com/shyiko/jabba/0.10.1/install.sh | bash && . ~/.jabba/jabba.sh + script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin - - citest/install-jdk.sh -F 11 + - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" && java -Xmx32m -version - cd citest && ./test.sh jdk: oraclejdk8 @@ -61,6 +62,7 @@ cache: directories: - $HOME/.ivy2/cache - $HOME/.sbt/boot + - $HOME/.jabba/jdk before_cache: - find $HOME/.ivy2 -name "ivydata-*.properties" -delete diff --git a/citest/install-jdk.sh b/citest/install-jdk.sh deleted file mode 100755 index a22b44c29..000000000 --- a/citest/install-jdk.sh +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/env bash - -# -# Install JDK for Linux -# -# This script determines the most recent early-access build number, -# downloads the JDK archive to the user home directory and extracts -# it there. -# -# Example usage -# -# install-jdk.sh -D | only gather and print variable values -# install-jdk.sh | install most recent (early-access) OpenJDK -# install-jdk.sh -W /usr/opt | install most recent (early-access) OpenJDK to /usr/opt -# install-jdk.sh -C | install most recent (early-access) OpenJDK with linked system CA certificates -# install-jdk.sh -F 9 | install most recent OpenJDK 9 -# install-jdk.sh -F 10 | install most recent OpenJDK 10 -# install-jdk.sh -F 11 | install most recent OpenJDK 11 -# install-jdk.sh -F 11 -L BCL | install most recent Oracle JDK 11 -# -# Options -# -# -D | Dry-run, only gather and print variable values -# -F f | Feature number of the JDK release [9|10|...|?] -# -L l | License of the JDK [GPL|BCL] -# -W w | Working directory and install path [${HOME}] -# -C | Use system CA certificates (currently only Debian/Ubuntu is supported) -# -# Exported environment variables -# -# JAVA_HOME is set to the extracted JDK directory -# PATH is prepended with ${JAVA_HOME}/bin -# -# (C) 2018 Christian Stein -# -# https://github.com/sormuras/bach/blob/master/install-jdk.sh -# -set -e - -VERSION='2018-04-05' -DRY_RUN='0' -LINK_SYSTEM_CACERTS='0' - -JDK_FEATURE='?' -JDK_BUILD='?' -JDK_LICENSE='GPL' -JDK_WORKSPACE=${HOME} -JDK_DOWNLOAD='https://download.java.net/java' -JDK_ORACLE='http://download.oracle.com/otn-pub/java/jdk' - -echo "install-jdk.sh (${VERSION})" - -# -# Parse command line options -# -while getopts ':F:L:W:CD' option; do - case "${option}" in - D) DRY_RUN='1';; - C) LINK_SYSTEM_CACERTS='1';; - F) JDK_FEATURE=${OPTARG};; - L) JDK_LICENSE=${OPTARG};; - W) JDK_WORKSPACE=${OPTARG};; - :) echo "Option -${OPTARG} requires an argument."; exit 1;; - \?) echo "Invalid option: -${OPTARG}"; exit 1;; - esac -done - -# -# Determine latest (early access or release candidate) number. -# -LATEST='11' -TMP=${LATEST} -while [ "${TMP}" != '99' ] -do - CODE=$(curl -o /dev/null --silent --head --write-out %{http_code} http://jdk.java.net/${TMP}) - if [ "${CODE}" -ge '400' ]; then - break - fi - LATEST=${TMP} - TMP=$[${TMP} +1] -done - -# -# Sanity checks. -# -if [ "${JDK_FEATURE}" == '?' ]; then - JDK_FEATURE=${LATEST} -fi -if [ "${JDK_FEATURE}" -lt '9' ] || [ "${JDK_FEATURE}" -gt "${LATEST}" ]; then - echo "Expected JDK_FEATURE number in range of [9..${LATEST}], but got: ${JDK_FEATURE}" - exit 1 -fi - -# -# Determine URL... -# -JDK_URL=$(wget -qO- http://jdk.java.net/${JDK_FEATURE} | grep -Eo 'href[[:space:]]*=[[:space:]]*"[^\"]+"' | grep -Eo '(http|https)://[^"]+') -if [ "${JDK_FEATURE}" == "${LATEST}" ]; then - JDK_URL=$(echo "${JDK_URL}" | grep -Eo "${JDK_DOWNLOAD}/.+/jdk${JDK_FEATURE}/.+/${JDK_LICENSE}/.*jdk-${JDK_FEATURE}.+linux-x64_bin.tar.gz$") -else - JDK_URL=$(echo "${JDK_URL}" | grep -Eo "${JDK_DOWNLOAD}/.+/jdk${JDK_FEATURE}/.+/.*jdk-${JDK_FEATURE}.+linux-x64_bin.tar.gz$") - if [ "${JDK_LICENSE}" == 'BCL' ]; then - case "${JDK_FEATURE}" in - 9) JDK_URL="${JDK_ORACLE}/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz";; - 10) JDK_URL="${JDK_ORACLE}/10+46/76eac37278c24557a3c4199677f19b62/jdk-10_linux-x64_bin.tar.gz";; - esac - fi -fi - -# -# Inspect URL properties. -# -JDK_ARCHIVE=$(basename ${JDK_URL}) -JDK_STATUS=$(curl -o /dev/null --silent --head --write-out %{http_code} ${JDK_URL}) - -# -# Print variables and exit if dry-run is active. -# -echo " FEATURE = ${JDK_FEATURE}" -echo " LICENSE = ${JDK_LICENSE}" -echo " ARCHIVE = ${JDK_ARCHIVE}" -echo " URL = ${JDK_URL} [${JDK_STATUS}]" -echo -if [ "${DRY_RUN}" == '1' ]; then - exit 0 -fi - -# -# Create any missing intermediate paths, switch to workspace, download, unpack, switch back. -# -mkdir -p ${JDK_WORKSPACE} -cd ${JDK_WORKSPACE} -wget --continue --header "Cookie: oraclelicense=accept-securebackup-cookie" ${JDK_URL} -file ${JDK_ARCHIVE} -JDK_HOME=$(tar --list --auto-compress --file ${JDK_ARCHIVE} | head -1 | cut -f1 -d"/") -tar --extract --auto-compress --file ${JDK_ARCHIVE} -cd ${OLDPWD} - -# -# Update environment variables. -# -export JAVA_HOME=${JDK_WORKSPACE}/${JDK_HOME} -export PATH=${JAVA_HOME}/bin:$PATH - -# -# Link to system certificates. -# - http://openjdk.java.net/jeps/319 -# - https://bugs.openjdk.java.net/browse/JDK-8196141 -# -if [ "${LINK_SYSTEM_CACERTS}" == '1' ]; then - mv "${JAVA_HOME}/lib/security/cacerts" "${JAVA_HOME}/lib/security/cacerts.jdk" - # TODO: Support for other distros than Debian/Ubuntu could be provided - ln -s /etc/ssl/certs/java/cacerts "${JAVA_HOME}/lib/security/cacerts" -fi - -# -# Test-drive. -# -echo -java --version -echo - -# -# Always print value of JAVA_HOME as last line. -# Usage from other scripts or shell: JAVA_HOME=$(./install-jdk.sh -L GPL | tail -n 1) -# -echo ${JAVA_HOME} diff --git a/citest/test.sh b/citest/test.sh index 5569842aa..2b08afcae 100755 --- a/citest/test.sh +++ b/citest/test.sh @@ -3,14 +3,6 @@ ## https://github.com/travis-ci/travis-ci/issues/8408 export _JAVA_OPTIONS= -## begin Java switching -## swtich to JDK 10 if we've downloaded it -if [ -d ~/jdk-10 ] -then - JAVA_HOME=~/jdk-10 -fi -## include JAVA_HOME into path -PATH=${JAVA_HOME}/bin:$PATH java -version ## end of Java switching From b8dbe42ece35ac7064e15d5de15b2f81ce0bf818 Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Tue, 9 Oct 2018 19:04:20 +0300 Subject: [PATCH 333/483] Use `preloaded` from `-sbt-dir` Fixes sbt/sbt#3598. --- src/universal/bin/sbt | 2 +- src/universal/bin/sbt-launch-lib.bash | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index cca77be05..e1882460f 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -121,7 +121,7 @@ process_my_args () { -no-share) addJava "$noshare_opts" && shift ;; -no-global) addJava "-Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;; -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; - -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;; + -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && sbt_dir="$2" && shift 2 ;; -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; -batch) exec /dev/null 2>&1 && { - mkdir -p "$HOME/.sbt/preloaded" - rsync -a --ignore-existing "$sbt_home/lib/local-preloaded/" "$HOME/.sbt/preloaded" + mkdir -p "$sbt_dir/preloaded" + rsync -a --ignore-existing "$sbt_home/lib/local-preloaded/" "$sbt_dir/preloaded" } } } @@ -277,6 +278,12 @@ copyRt() { } run() { + # process the combined args, then reset "$@" to the residuals + process_args "$@" + set -- "${residual_args[@]}" + argumentCount=$# + + # Copy preloaded repo to sbt_dir (if rsync is available) syncPreloaded # no jar? download it. @@ -286,11 +293,6 @@ run() { exit 1 } - # process the combined args, then reset "$@" to the residuals - process_args "$@" - set -- "${residual_args[@]}" - argumentCount=$# - # TODO - java check should be configurable... checkJava "6" From c8219f8396143161b24d3eafe44fd24d2d025567 Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Tue, 9 Oct 2018 23:51:34 +0300 Subject: [PATCH 334/483] Improve logic for finding preloaded directory --- src/universal/bin/sbt | 2 +- src/universal/bin/sbt-launch-lib.bash | 50 +++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index e1882460f..cca77be05 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -121,7 +121,7 @@ process_my_args () { -no-share) addJava "$noshare_opts" && shift ;; -no-global) addJava "-Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;; -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; - -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && sbt_dir="$2" && shift 2 ;; + -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;; -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; -batch) exec /dev/null 2>&1 && { - mkdir -p "$sbt_dir/preloaded" - rsync -a --ignore-existing "$sbt_home/lib/local-preloaded/" "$sbt_dir/preloaded" + mkdir -p "$target_preloaded" + rsync -a --ignore-existing "$source_preloaded" "$preloaded" } } } @@ -283,7 +319,7 @@ run() { set -- "${residual_args[@]}" argumentCount=$# - # Copy preloaded repo to sbt_dir (if rsync is available) + # Copy preloaded repo to user's preloaded directory syncPreloaded # no jar? download it. From 9c19799b73c297b88d4ea626e0c44430ddcb4be2 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 17 Oct 2018 01:56:57 -0400 Subject: [PATCH 335/483] Revert "Improve logic for finding preloaded directory" This reverts commit c8219f8396143161b24d3eafe44fd24d2d025567. --- src/universal/bin/sbt | 2 +- src/universal/bin/sbt-launch-lib.bash | 50 ++++----------------------- 2 files changed, 8 insertions(+), 44 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index cca77be05..e1882460f 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -121,7 +121,7 @@ process_my_args () { -no-share) addJava "$noshare_opts" && shift ;; -no-global) addJava "-Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;; -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; - -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;; + -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && sbt_dir="$2" && shift 2 ;; -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; -batch) exec /dev/null 2>&1 && { - mkdir -p "$target_preloaded" - rsync -a --ignore-existing "$source_preloaded" "$preloaded" + mkdir -p "$sbt_dir/preloaded" + rsync -a --ignore-existing "$sbt_home/lib/local-preloaded/" "$sbt_dir/preloaded" } } } @@ -319,7 +283,7 @@ run() { set -- "${residual_args[@]}" argumentCount=$# - # Copy preloaded repo to user's preloaded directory + # Copy preloaded repo to sbt_dir (if rsync is available) syncPreloaded # no jar? download it. From 1d806c9cf303ba58f6e7d7bc876586cedada2881 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 17 Oct 2018 01:57:08 -0400 Subject: [PATCH 336/483] Revert "Use `preloaded` from `-sbt-dir`" This reverts commit b8dbe42ece35ac7064e15d5de15b2f81ce0bf818. --- src/universal/bin/sbt | 2 +- src/universal/bin/sbt-launch-lib.bash | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index e1882460f..cca77be05 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -121,7 +121,7 @@ process_my_args () { -no-share) addJava "$noshare_opts" && shift ;; -no-global) addJava "-Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;; -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; - -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && sbt_dir="$2" && shift 2 ;; + -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;; -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; -batch) exec /dev/null 2>&1 && { - mkdir -p "$sbt_dir/preloaded" - rsync -a --ignore-existing "$sbt_home/lib/local-preloaded/" "$sbt_dir/preloaded" + mkdir -p "$HOME/.sbt/preloaded" + rsync -a --ignore-existing "$sbt_home/lib/local-preloaded/" "$HOME/.sbt/preloaded" } } } @@ -278,12 +277,6 @@ copyRt() { } run() { - # process the combined args, then reset "$@" to the residuals - process_args "$@" - set -- "${residual_args[@]}" - argumentCount=$# - - # Copy preloaded repo to sbt_dir (if rsync is available) syncPreloaded # no jar? download it. @@ -293,6 +286,11 @@ run() { exit 1 } + # process the combined args, then reset "$@" to the residuals + process_args "$@" + set -- "${residual_args[@]}" + argumentCount=$# + # TODO - java check should be configurable... checkJava "6" From b791da704cb8dd7b0919473a16fb9e5fbc0b2adc Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Wed, 17 Oct 2018 12:57:21 +0300 Subject: [PATCH 337/483] Use `preloaded` from `-sbt-dir` --- citest/test.sh | 17 +++++++- src/universal/bin/sbt-launch-lib.bash | 58 ++++++++++++++++++++++----- 2 files changed, 63 insertions(+), 12 deletions(-) diff --git a/citest/test.sh b/citest/test.sh index 2b08afcae..4c8450464 100755 --- a/citest/test.sh +++ b/citest/test.sh @@ -1,12 +1,12 @@ #!/bin/bash ## https://github.com/travis-ci/travis-ci/issues/8408 -export _JAVA_OPTIONS= +unset _JAVA_OPTIONS java -version ## end of Java switching -mkdir freshly-baked +mkdir -p freshly-baked unzip -qo ../target/universal/sbt.zip -d ./freshly-baked export SBT_OPTS=-Dfile.encoding=UTF-8 @@ -16,3 +16,16 @@ export SBT_OPTS=-Dfile.encoding=UTF-8 export SBT_OPTS="-Dfile.encoding=UTF-8 -Xms2048M -Xmx2048M -Xss2M -XX:MaxPermSize=512M" ./freshly-baked/sbt/bin/sbt about run + +env HOME=./target/home1 ./freshly-baked/sbt/bin/sbt about +test -d ./target/home1/.sbt/preloaded || echo "expected to find preloaded in ./target/home1/.sbt" + +env HOME=./target/home2 ./freshly-baked/sbt/bin/sbt -sbt-dir ./target/home2/alternate-sbt about +test -d ./target/home2/alternate-sbt/preloaded || echo "expected to find preloaded in ./target/home2/alternate-sbt" + +env HOME=./target/home3 ./freshly-baked/sbt/bin/sbt -J-Dsbt.preloaded=./target/home3/alternate-preloaded about +test -d ./target/home3/alternate-preloaded || echo "expected to find preloaded in ./target/home3/alternate-preloaded" + +env HOME=./target/home4 ./freshly-baked/sbt/bin/sbt -J-Dsbt.global.base=./target/home4/global-base about +test -d ./target/home4/global-base || echo "expected to find preloaded in ./target/home4/global-base" + diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index e7155a148..e2905182c 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -213,17 +213,54 @@ process_args () { vlog "[process_args] java_version = '$java_version'" } +# Extracts the preloaded directory from either -Dsbt.preloaded or -Dsbt.global.base +# properties by looking at: +# - _JAVA_OPTIONS environment variable, +# - SBT_OPTS environment variable, +# - JAVA_OPTS environment variable and +# - properties set by command-line options +# in that order. The last one will be chosen such that `sbt.preloaded` is +# always preferred over `sbt.global.base`. +getPreloaded() { + local -a _java_options_array + local -a sbt_opts_array + local -a java_opts_array + read -a _java_options_array <<< "$_JAVA_OPTIONS" + read -a sbt_opts_array <<< "$SBT_OPTS" + read -a java_opts_array <<< "$JAVA_OPTS" + + local args_to_check=( + "${_java_options_array[@]}" + "${sbt_opts_array[@]}" + "${java_opts_array[@]}" + "${java_args[@]}") + local via_global_base="$HOME/.sbt/preloaded" + local via_explicit="" + + for opt in "${args_to_check[@]}"; do + if [[ "$opt" == -Dsbt.preloaded=* ]]; then + via_explicit="${opt#-Dsbt.preloaded=}" + elif [[ "$opt" == -Dsbt.global.base=* ]]; then + via_global_base="${opt#-Dsbt.global.base=}/preloaded" + fi + done + + echo "${via_explicit:-${via_global_base}}" +} + syncPreloaded() { + local source_preloaded="$sbt_home/lib/local-preloaded" + local target_preloaded="$(getPreloaded)" if [[ "$init_sbt_version" == "" ]]; then # FIXME: better $init_sbt_version detection - init_sbt_version="$(ls -1 "$sbt_home/lib/local-preloaded/org.scala-sbt/sbt/")" + init_sbt_version="$(ls -1 "$source_preloaded/org.scala-sbt/sbt/")" fi - [[ -f "$HOME/.sbt/preloaded/org.scala-sbt/sbt/$init_sbt_version/jars/sbt.jar" ]] || { + [[ -f "$target_preloaded/org.scala-sbt/sbt/$init_sbt_version/jars/sbt.jar" ]] || { # lib/local-preloaded exists (This is optional) - [[ -d "$sbt_home/lib/local-preloaded/" ]] && { + [[ -d "$source_preloaded" ]] && { command -v rsync >/dev/null 2>&1 && { - mkdir -p "$HOME/.sbt/preloaded" - rsync -a --ignore-existing "$sbt_home/lib/local-preloaded/" "$HOME/.sbt/preloaded" + mkdir -p "$target_preloaded" + rsync -a --ignore-existing "$source_preloaded" "$target_preloaded" } } } @@ -277,6 +314,12 @@ copyRt() { } run() { + # process the combined args, then reset "$@" to the residuals + process_args "$@" + set -- "${residual_args[@]}" + argumentCount=$# + + # Copy preloaded repo to user's preloaded directory syncPreloaded # no jar? download it. @@ -286,11 +329,6 @@ run() { exit 1 } - # process the combined args, then reset "$@" to the residuals - process_args "$@" - set -- "${residual_args[@]}" - argumentCount=$# - # TODO - java check should be configurable... checkJava "6" From 018034a090d9af3122ff2a18663f47f5d08b6a51 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 18 Oct 2018 16:50:30 -0400 Subject: [PATCH 338/483] JDK11 on Windows --- .appveyor.yml | 4 ++-- citest/test.bat | 4 ++-- citest/test1.bat | 4 ++-- citest/test2.bat | 4 ++-- citest/test3/test3.bat | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index ef6d53c05..b18d73b07 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,7 +5,7 @@ init: install: - cinst jdk8 -params 'installdir=C:\\jdk8' - - cinst jdk10 -params 'installdir=C:\\jdk10' + - cinst jdk11 -params 'installdir=C:\\jdk11' - SET JAVA_HOME=C:\jdk8 - SET PATH=C:\jdk8\bin;%PATH% @@ -13,7 +13,7 @@ install: Add-Type -AssemblyName System.IO.Compression.FileSystem if (!(Test-Path -Path "C:\sbt" )) { (new-object System.Net.WebClient).DownloadFile( - 'https://cocl.us/sbt-0.13.16.zip', + 'https://piccolo.link/sbt-0.13.17.zip', 'C:\sbt-bin.zip' ) [System.IO.Compression.ZipFile]::ExtractToDirectory("C:\sbt-bin.zip", "C:\sbt") diff --git a/citest/test.bat b/citest/test.bat index f1a372b55..9234e6201 100644 --- a/citest/test.bat +++ b/citest/test.bat @@ -9,8 +9,8 @@ SETLOCAL "freshly-baked\sbt\bin\sbt" about -SET JAVA_HOME=C:\jdk10 -SET PATH=C:\jdk10\bin;%PATH% +SET JAVA_HOME=C:\jdk11 +SET PATH=C:\jdk11\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 "freshly-baked\sbt\bin\sbt" about diff --git a/citest/test1.bat b/citest/test1.bat index a0bbd1169..4036c2593 100644 --- a/citest/test1.bat +++ b/citest/test1.bat @@ -2,8 +2,8 @@ SETLOCAL -SET JAVA_HOME=C:\jdk10 -SET PATH=C:\jdk10\bin;%PATH% +SET JAVA_HOME=C:\jdk11 +SET PATH=C:\jdk11\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 "freshly-baked\sbt\bin\sbt" about 1> output.txt 2> err.txt diff --git a/citest/test2.bat b/citest/test2.bat index 4a7301ee9..2c42c7288 100644 --- a/citest/test2.bat +++ b/citest/test2.bat @@ -2,8 +2,8 @@ SETLOCAL -SET JAVA_HOME=C:\jdk10 -SET PATH=C:\jdk10\bin;%PATH% +SET JAVA_HOME=C:\jdk11 +SET PATH=C:\jdk11\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 "freshly-baked\sbt\bin\sbt" check diff --git a/citest/test3/test3.bat b/citest/test3/test3.bat index e70f4e38c..38b1bde4f 100644 --- a/citest/test3/test3.bat +++ b/citest/test3/test3.bat @@ -2,8 +2,8 @@ SETLOCAL -SET JAVA_HOME=C:\jdk10 -SET PATH=C:\jdk10\bin;%PATH% +SET JAVA_HOME=C:\jdk11 +SET PATH=C:\jdk11\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 SET BASE_DIR=%CD% From b8b354233955b38744a7b0826f08308da3f31e67 Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Mon, 3 Dec 2018 22:13:08 +0200 Subject: [PATCH 339/483] Fix rsync source path designation in preloaded; fixes #246 --- citest/test.sh | 13 +++++++++---- src/universal/bin/sbt-launch-lib.bash | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/citest/test.sh b/citest/test.sh index 4c8450464..4699a876a 100755 --- a/citest/test.sh +++ b/citest/test.sh @@ -17,15 +17,20 @@ export SBT_OPTS="-Dfile.encoding=UTF-8 -Xms2048M -Xmx2048M -Xss2M -XX:MaxPermSiz ./freshly-baked/sbt/bin/sbt about run +fail() { + echo "$@" >&2 + exit 1 +} + env HOME=./target/home1 ./freshly-baked/sbt/bin/sbt about -test -d ./target/home1/.sbt/preloaded || echo "expected to find preloaded in ./target/home1/.sbt" +test -d ./target/home1/.sbt/preloaded/org.scala-sbt || fail "expected to find preloaded in ./target/home1/.sbt" env HOME=./target/home2 ./freshly-baked/sbt/bin/sbt -sbt-dir ./target/home2/alternate-sbt about -test -d ./target/home2/alternate-sbt/preloaded || echo "expected to find preloaded in ./target/home2/alternate-sbt" +test -d ./target/home2/alternate-sbt/preloaded/org.scala-sbt || fail "expected to find preloaded in ./target/home2/alternate-sbt" env HOME=./target/home3 ./freshly-baked/sbt/bin/sbt -J-Dsbt.preloaded=./target/home3/alternate-preloaded about -test -d ./target/home3/alternate-preloaded || echo "expected to find preloaded in ./target/home3/alternate-preloaded" +test -d ./target/home3/alternate-preloaded/org.scala-sbt || fail "expected to find preloaded in ./target/home3/alternate-preloaded" env HOME=./target/home4 ./freshly-baked/sbt/bin/sbt -J-Dsbt.global.base=./target/home4/global-base about -test -d ./target/home4/global-base || echo "expected to find preloaded in ./target/home4/global-base" +test -d ./target/home4/global-base/preloaded/org.scala-sbt || fail "expected to find preloaded in ./target/home4/global-base" diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index e2905182c..f272947d3 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -249,7 +249,7 @@ getPreloaded() { } syncPreloaded() { - local source_preloaded="$sbt_home/lib/local-preloaded" + local source_preloaded="$sbt_home/lib/local-preloaded/" local target_preloaded="$(getPreloaded)" if [[ "$init_sbt_version" == "" ]]; then # FIXME: better $init_sbt_version detection From 0e8655fd5d602ccaae9f1cf2f533eb6644f97fe7 Mon Sep 17 00:00:00 2001 From: fredge Date: Thu, 13 Dec 2018 12:11:08 +0900 Subject: [PATCH 340/483] fix #248. Move setting JVM's debug option after executing `:copyrt` label, in order to avoid unintended debug string written to `rtext.txt` --- src/universal/bin/sbt.bat | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 6c510e8bd..fbe0704e2 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -104,16 +104,16 @@ if not exist build.sbt ( ) ) -if defined JVM_DEBUG_PORT ( - set _JAVA_OPTS=!_JAVA_OPTS! -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=!JVM_DEBUG_PORT! -) - call :process call :checkjava call :copyrt +if defined JVM_DEBUG_PORT ( + set _JAVA_OPTS=!_JAVA_OPTS! -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=!JVM_DEBUG_PORT! +) + call :sync_preloaded call :run %SBT_ARGS% From 50e541e4040e587dc86431ca88a2323f8e9edcd0 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 7 Jan 2019 19:09:05 -0500 Subject: [PATCH 341/483] gzip deb so we can publish to Bintray --- build.sbt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index d18d259b8..bbcb335da 100644 --- a/build.sbt +++ b/build.sbt @@ -101,7 +101,8 @@ val root = (project in file(".")). }, debianChangelog in Debian := { Some(sourceDirectory.value / "debian" / "changelog") }, addPackage(Debian, packageBin in Debian, "deb"), - + debianNativeBuildOptions in Debian := Seq("-Zgzip", "-z3"), + // RPM SPECIFIC rpmRelease := "0", version in Rpm := { From 2d21c0fd2a67641f63e8e4f4f4b68772ae41fad1 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Mon, 4 Feb 2019 20:38:10 -0800 Subject: [PATCH 342/483] Simplify the debug in execRunner and fix the $java_args[@] expansion, fixes #253 --- src/universal/bin/sbt-launch-lib.bash | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index f272947d3..ce022f7db 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -57,14 +57,10 @@ rt_export_file () { } execRunner () { - # print the arguments one to a line, quoting any containing spaces + # print the arguments one to a line, shell-quoted [[ $verbose || $debug ]] && echo "# Executing command line:" && { - for arg; do - if printf "%s\n" "$arg" | grep -q ' '; then - printf "\"%s\"\n" "$arg" - else - printf "%s\n" "$arg" - fi + for arg in "$@"; do + printf "%q\n" "$arg" done echo "" } @@ -348,7 +344,7 @@ run() { $(get_gc_opts) \ ${JAVA_OPTS} \ ${SBT_OPTS:-$default_sbt_opts} \ - ${java_args[@]} \ + "${java_args[@]}" \ -jar "$sbt_jar" \ "${sbt_commands[@]}" \ "${residual_args[@]}" From 9780c6218f2199f7dd998b1ef6ab9699109b7a76 Mon Sep 17 00:00:00 2001 From: Stefan Wachter Date: Wed, 6 Feb 2019 17:48:39 +0100 Subject: [PATCH 343/483] unset immediatly exit flag (set +e) in launch script --- src/universal/bin/sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index cca77be05..dd16fa77a 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -1,5 +1,6 @@ #!/usr/bin/env bash +set +e ### ------------------------------- ### ### Helper methods for BASH scripts ### From 4d772b4745b948cf0a0e12ec2c8f117b3a34bea7 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 22 Feb 2019 15:25:28 -0500 Subject: [PATCH 344/483] Concatenate bin/sbt-launch-lib.bash and bin/sbt --- build.sbt | 10 +- src/universal/bin/sbt | 384 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 356 insertions(+), 38 deletions(-) diff --git a/build.sbt b/build.sbt index bbcb335da..a7e2c61aa 100644 --- a/build.sbt +++ b/build.sbt @@ -78,11 +78,10 @@ val root = (project in file(".")). val links = linuxPackageSymlinks.value for { link <- links - if !(link.destination endsWith "sbt-launch-lib.bash") if !(link.destination endsWith "sbt-launch.jar") } yield link }, - + // DEBIAN SPECIFIC debianBuildId := 0, version in Debian := { @@ -150,15 +149,8 @@ val root = (project in file(".")). mappings in Universal := { val t = (target in Universal).value val prev = (mappings in Universal).value - val BinBash = "bin" + java.io.File.separator + "sbt-launch-lib.bash" val BinBat = "bin" + java.io.File.separator + "sbt.bat" prev.toList map { - case (k, BinBash) => - val x = IO.read(k) - IO.write(t / "sbt-launch-lib.bash", x.replaceAllLiterally( - "declare init_sbt_version=_to_be_replaced", - s"""declare init_sbt_version="$sbtVersionToRelease"""")) - (t / "sbt-launch-lib.bash", BinBash) case (k, BinBat) => val x = IO.read(k) IO.write(t / "sbt.bat", x.replaceAllLiterally( diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index dd16fa77a..bd2405991 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -1,38 +1,20 @@ #!/usr/bin/env bash set +e +declare -a residual_args +declare -a java_args +declare -a scalac_args +declare -a sbt_commands +declare java_cmd=java +declare java_version +declare init_sbt_version=_to_be_replaced +declare sbt_default_mem=1024 +declare default_sbt_opts="" ### ------------------------------- ### ### Helper methods for BASH scripts ### ### ------------------------------- ### -realpath () { -( - TARGET_FILE="$1" - FIX_CYGPATH="$2" - - cd "$(dirname "$TARGET_FILE")" - TARGET_FILE=$(basename "$TARGET_FILE") - - COUNT=0 - while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ] - do - TARGET_FILE=$(readlink "$TARGET_FILE") - cd "$(dirname "$TARGET_FILE")" - TARGET_FILE=$(basename "$TARGET_FILE") - COUNT=$(($COUNT + 1)) - done - - # make sure we grab the actual windows path, instead of cygwin's path. - if [[ "x$FIX_CYGPATH" != "x" ]]; then - echo "$(cygwinpath "$(pwd -P)/$TARGET_FILE")" - else - echo "$(pwd -P)/$TARGET_FILE" - fi -) -} - - # Uses uname to detect if we're in the odd cygwin environment. is_cygwin() { local os=$(uname -s) @@ -47,7 +29,6 @@ is_cygwin() { # TODO - Use nicer bash-isms here. CYGWIN_FLAG=$(if is_cygwin; then echo true; else echo false; fi) - # This can fix cygwin style /cygdrive paths so we get the # windows style paths. cygwinpath() { @@ -59,8 +40,353 @@ cygwinpath() { fi } -. "$(dirname "$(realpath "$0")")/sbt-launch-lib.bash" +declare SCRIPT=$0 +while [ -h "$SCRIPT" ] ; do + ls=$(ls -ld "$SCRIPT") + # Drop everything prior to -> + link=$(expr "$ls" : '.*-> \(.*\)$') + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=$(dirname "$SCRIPT")/"$link" + fi +done +declare -r sbt_bin_dir="$(dirname "$SCRIPT")" +declare -r sbt_home="$(dirname "$sbt_bin_dir")" + +echoerr () { + echo 1>&2 "$@" +} +vlog () { + [[ $verbose || $debug ]] && echoerr "$@" +} +dlog () { + [[ $debug ]] && echoerr "$@" +} + +jar_file () { + echo "$(cygwinpath "${sbt_home}/bin/sbt-launch.jar")" +} + +acquire_sbt_jar () { + sbt_jar="$(jar_file)" + + if [[ ! -f "$sbt_jar" ]]; then + echoerr "Could not find launcher jar: $sbt_jar" + exit 2 + fi +} + +rt_export_file () { + echo "${sbt_bin_dir}/java9-rt-export.jar" +} + +execRunner () { + # print the arguments one to a line, quoting any containing spaces + [[ $verbose || $debug ]] && echo "# Executing command line:" && { + for arg; do + if printf "%s\n" "$arg" | grep -q ' '; then + printf "\"%s\"\n" "$arg" + else + printf "%s\n" "$arg" + fi + done + echo "" + } + + # THis used to be exec, but we loose the ability to re-hook stty then + # for cygwin... Maybe we should flag the feature here... + "$@" +} + +addJava () { + dlog "[addJava] arg = '$1'" + java_args=( "${java_args[@]}" "$1" ) +} +addSbt () { + dlog "[addSbt] arg = '$1'" + sbt_commands=( "${sbt_commands[@]}" "$1" ) +} +addResidual () { + dlog "[residual] arg = '$1'" + residual_args=( "${residual_args[@]}" "$1" ) +} +addDebugger () { + addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$1" +} + +get_mem_opts () { + # if we detect any of these settings in ${JAVA_OPTS} or ${JAVA_TOOL_OPTIONS} we need to NOT output our settings. + # The reason is the Xms/Xmx, if they don't line up, cause errors. + if [[ "${JAVA_OPTS}" == *-Xmx* ]] || [[ "${JAVA_OPTS}" == *-Xms* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxPermSize* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${JAVA_OPTS}" == *-XX:ReservedCodeCacheSize* ]]; then + echo "" + elif [[ "${JAVA_TOOL_OPTIONS}" == *-Xmx* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-Xms* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxPermSize* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-XX:ReservedCodeCacheSize* ]]; then + echo "" + elif [[ "${SBT_OPTS}" == *-Xmx* ]] || [[ "${SBT_OPTS}" == *-Xms* ]] || [[ "${SBT_OPTS}" == *-XX:MaxPermSize* ]] || [[ "${SBT_OPTS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${SBT_OPTS}" == *-XX:ReservedCodeCacheSize* ]]; then + echo "" + else + # a ham-fisted attempt to move some memory settings in concert + # so they need not be messed around with individually. + local mem=${1:-$sbt_default_mem} + local codecache=$(( $mem / 8 )) + (( $codecache > 128 )) || codecache=128 + (( $codecache < 512 )) || codecache=512 + local class_metadata_size=$(( $codecache * 2 )) + if [[ -z $java_version ]]; then + java_version=$(jdk_version) + fi + local class_metadata_opt=$((( $java_version < 8 )) && echo "MaxPermSize" || echo "MaxMetaspaceSize") + + local arg_xms=$([[ "${java_args[@]}" == *-Xms* ]] && echo "" || echo "-Xms${mem}m") + local arg_xmx=$([[ "${java_args[@]}" == *-Xmx* ]] && echo "" || echo "-Xmx${mem}m") + local arg_rccs=$([[ "${java_args[@]}" == *-XX:ReservedCodeCacheSize* ]] && echo "" || echo "-XX:ReservedCodeCacheSize=${codecache}m") + local arg_meta=$([[ "${java_args[@]}" == *-XX:${class_metadata_opt}* && ! (( $java_version < 8 )) ]] && echo "" || echo "-XX:${class_metadata_opt}=${class_metadata_size}m") + + echo "${arg_xms} ${arg_xmx} ${arg_rccs} ${arg_meta}" + fi +} + +get_gc_opts () { + local older_than_9=$(( $java_version < 9 )) + + if [[ "$older_than_9" == "1" ]]; then + # don't need to worry about gc + echo "" + elif [[ "${JAVA_OPTS}" =~ Use.*GC ]] || [[ "${JAVA_TOOL_OPTIONS}" =~ Use.*GC ]] || [[ "${SBT_OPTS}" =~ Use.*GC ]] ; then + # GC arg has been passed in - don't change + echo "" + else + # Java 9+ so revert to old + echo "-XX:+UseParallelGC" + fi +} + +require_arg () { + local type="$1" + local opt="$2" + local arg="$3" + if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then + echo "$opt requires <$type> argument" + exit 1 + fi +} + +is_function_defined() { + declare -f "$1" > /dev/null +} + +# parses JDK version from the -version output line. +# 8 for 1.8.0_nn, 9 for 9-ea etc, and "no_java" for undetected +jdk_version() { + local result + local lines=$("$java_cmd" -Xms32M -Xmx32M -version 2>&1 | tr '\r' '\n') + local IFS=$'\n' + for line in $lines; do + if [[ (-z $result) && ($line = *"version \""*) ]] + then + local ver=$(echo $line | sed -e 's/.*version "\(.*\)"\(.*\)/\1/; 1q') + # on macOS sed doesn't support '?' + if [[ $ver = "1."* ]] + then + result=$(echo $ver | sed -e 's/1\.\([0-9]*\)\(.*\)/\1/; 1q') + else + result=$(echo $ver | sed -e 's/\([0-9]*\)\(.*\)/\1/; 1q') + fi + fi + done + if [[ -z $result ]] + then + result=no_java + fi + echo "$result" +} + +process_args () { + while [[ $# -gt 0 ]]; do + case "$1" in + -h|-help) usage; exit 1 ;; + -v|-verbose) verbose=1 && shift ;; + -d|-debug) debug=1 && addSbt "-debug" && shift ;; + + -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; + -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; + -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; + -batch) exec /dev/null 2>&1 && { + mkdir -p "$target_preloaded" + rsync -a --ignore-existing "$source_preloaded" "$target_preloaded" + } + } + } +} + +# Detect that we have java installed. +checkJava() { + local required_version="$1" + # Now check to see if it's a good enough version + local good_enough="$(expr $java_version ">=" $required_version)" + if [[ "$java_version" == "" ]]; then + echo + echo "No Java Development Kit (JDK) installation was detected." + echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download. + echo + exit 1 + elif [[ "$good_enough" != "1" ]]; then + echo + echo "The Java Development Kit (JDK) installation you have is not up to date." + echo $script_name requires at least version $required_version+, you have + echo version $java_version + echo + echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download + echo a valid JDK and install before running $script_name. + echo + exit 1 + fi +} + +copyRt() { + local at_least_9="$(expr $java_version ">=" 9)" + if [[ "$at_least_9" == "1" ]]; then + rtexport=$(rt_export_file) + # The grep for java9-rt-ext- matches the filename prefix printed in Export.java + java9_ext=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ + -jar "$rtexport" --rt-ext-dir | grep java9-rt-ext-) + java9_rt=$(echo "$java9_ext/rt.jar") + vlog "[copyRt] java9_rt = '$java9_rt'" + if [[ ! -f "$java9_rt" ]]; then + echo Copying runtime jar. + mkdir -p "$java9_ext" + execRunner "$java_cmd" \ + ${JAVA_OPTS} \ + ${SBT_OPTS:-$default_sbt_opts} \ + ${java_args[@]} \ + -jar "$rtexport" \ + "${java9_rt}" + fi + addJava "-Dscala.ext.dirs=${java9_ext}" + fi +} + +run() { + # process the combined args, then reset "$@" to the residuals + process_args "$@" + set -- "${residual_args[@]}" + argumentCount=$# + + # Copy preloaded repo to user's preloaded directory + syncPreloaded + + # no jar? download it. + [[ -f "$sbt_jar" ]] || acquire_sbt_jar "$sbt_version" || { + # still no jar? uh-oh. + echo "Download failed. Obtain the sbt-launch.jar manually and place it at $sbt_jar" + exit 1 + } + + # TODO - java check should be configurable... + checkJava "6" + + # Java 9 support + copyRt + + #If we're in cygwin, we should use the windows config, and terminal hacks + if [[ "$CYGWIN_FLAG" == "true" ]]; then + stty -icanon min 1 -echo > /dev/null 2>&1 + addJava "-Djline.terminal=jline.UnixTerminal" + addJava "-Dsbt.cygwin=true" + fi + + # run sbt + execRunner "$java_cmd" \ + $(get_mem_opts $sbt_mem) \ + $(get_gc_opts) \ + ${JAVA_OPTS} \ + ${SBT_OPTS:-$default_sbt_opts} \ + ${java_args[@]} \ + -jar "$sbt_jar" \ + "${sbt_commands[@]}" \ + "${residual_args[@]}" + + exit_code=$? + + # Clean up the terminal from cygwin hacks. + if [[ "$CYGWIN_FLAG" == "true" ]]; then + stty icanon echo > /dev/null 2>&1 + fi + exit $exit_code +} declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" declare -r sbt_opts_file=".sbtopts" From 3f9e91aa4f865a5faa2db5390de21cc3e696c4ab Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 22 Feb 2019 16:01:17 -0500 Subject: [PATCH 345/483] Default to -Dfile.encoding=UTF-8 Fixes #236 --- citest/test.sh | 2 +- src/universal/bin/sbt | 15 +++++++++------ src/universal/bin/sbt.bat | 4 ++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/citest/test.sh b/citest/test.sh index 4699a876a..53c9c6db6 100755 --- a/citest/test.sh +++ b/citest/test.sh @@ -11,7 +11,7 @@ unzip -qo ../target/universal/sbt.zip -d ./freshly-baked export SBT_OPTS=-Dfile.encoding=UTF-8 -./freshly-baked/sbt/bin/sbt about run +./freshly-baked/sbt/bin/sbt about run -v export SBT_OPTS="-Dfile.encoding=UTF-8 -Xms2048M -Xmx2048M -Xss2M -XX:MaxPermSize=512M" diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index bd2405991..094134a1d 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -9,7 +9,8 @@ declare java_cmd=java declare java_version declare init_sbt_version=_to_be_replaced declare sbt_default_mem=1024 -declare default_sbt_opts="" +declare -r default_sbt_opts="" +declare -r default_java_opts="-Dfile.encoding=UTF-8" ### ------------------------------- ### ### Helper methods for BASH scripts ### @@ -422,7 +423,7 @@ Usage: `basename "$0"` [options] -java-home alternate JAVA_HOME # jvm options and output control - JAVA_OPTS environment variable, if unset uses "$java_opts" + JAVA_OPTS environment variable, if unset uses "$default_java_opts" .jvmopts if this file exists in the current directory, its contents are appended to JAVA_OPTS SBT_OPTS environment variable, if unset uses "$default_sbt_opts" @@ -459,7 +460,7 @@ process_my_args () { *) addResidual "$1" && shift ;; esac done - + # Now, ensure sbt version is used. [[ "${sbt_version}XXX" != "XXX" ]] && addJava "-Dsbt.version=$sbt_version" @@ -494,11 +495,13 @@ loadConfigFile() { # Here we pull in the global settings configuration. [[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@" -# Pull in the project-level config file, if it exists. +# Pull in the project-level config file, if it exists. [[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@" -# Pull in the project-level java config, if it exists. +# Pull in the project-level java config, if it exists. [[ -f ".jvmopts" ]] && export JAVA_OPTS="$JAVA_OPTS $(loadConfigFile .jvmopts)" -run "$@" +# Pull in default JAVA_OPTS +[[ -z "${JAVA_OPTS// }" ]] && export JAVA_OPTS="$default_java_opts" +run "$@" diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index fbe0704e2..f7f1dd7fb 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -13,6 +13,8 @@ set SBT_HOME=%~dp0 set SBT_ARGS= +set DEFAULT_JAVA_OPTS=-Dfile.encoding=UTF-8 + rem FIRST we load the config file of extra options. set FN=%SBT_HOME%\..\conf\sbtconfig.txt set CFG_OPTS= @@ -55,6 +57,8 @@ rem We use the value of the JAVA_OPTS environment variable if defined, rather th set _JAVA_OPTS=%JAVA_OPTS% if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% +if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%DEFAULT_JAVA_OPTS% + set INIT_SBT_VERSION=_TO_BE_REPLACED :args_loop From 88b8386d154a739c538c79f79e877f7d6f8c70dc Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 22 Feb 2019 17:48:37 -0500 Subject: [PATCH 346/483] Update integration test --- .travis.yml | 4 +- build.sbt | 13 + .../src/test/scala/InheritInput.scala | 17 + .../src/test/scala/PowerAssertions.scala | 7 + integration-test/src/test/scala/Process.scala | 216 +++++++++ .../src/test/scala/ProcessImpl.scala | 433 ++++++++++++++++++ .../src/test/scala/RunnerTest.scala | 24 + integration-test/src/test/scala/SyncVar.scala | 38 ++ src/test/scala/RunnerTest.scala | 51 --- 9 files changed, 750 insertions(+), 53 deletions(-) create mode 100644 integration-test/src/test/scala/InheritInput.scala create mode 100644 integration-test/src/test/scala/PowerAssertions.scala create mode 100644 integration-test/src/test/scala/Process.scala create mode 100644 integration-test/src/test/scala/ProcessImpl.scala create mode 100644 integration-test/src/test/scala/RunnerTest.scala create mode 100644 integration-test/src/test/scala/SyncVar.scala delete mode 100644 src/test/scala/RunnerTest.scala diff --git a/.travis.yml b/.travis.yml index 451d7b8a9..aaaa5cf4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ matrix: include: ## build using JDK 8, test using JDK 8 - script: - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin integrationTest/test - cd citest && ./test.sh jdk: oraclejdk8 @@ -33,7 +33,7 @@ matrix: - unset _JAVA_OPTIONS - curl -sL https://raw.githubusercontent.com/shyiko/jabba/0.10.1/install.sh | bash && . ~/.jabba/jabba.sh script: - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin integrationTest/test - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" && java -Xmx32m -version - cd citest && ./test.sh jdk: oraclejdk8 diff --git a/build.sbt b/build.sbt index a7e2c61aa..96777b968 100644 --- a/build.sbt +++ b/build.sbt @@ -68,6 +68,7 @@ val root = (project in file(".")). // TODO - GPG Trust validation. file }, + // GENERAL LINUX PACKAGING STUFFS maintainer := "Eugene Yokota ", packageSummary := "sbt, the interactive build tool", @@ -194,6 +195,18 @@ val root = (project in file(".")). } ) +lazy val integrationTest = (project in file("integration-test")) + .settings( + name := "integration-test", + scalaVersion := "2.12.8", + libraryDependencies ++= Seq( + "io.monix" %% "minitest" % "2.3.2" % Test, + "com.eed3si9n.expecty" %% "expecty" % "0.11.0" % Test, + "org.scala-sbt" %% "io" % "1.2.2" % Test + ), + testFrameworks += new TestFramework("minitest.runner.Framework") + ) + lazy val java9rtexport = (project in file("java9-rt-export")) .settings( name := "java9-rt-export", diff --git a/integration-test/src/test/scala/InheritInput.scala b/integration-test/src/test/scala/InheritInput.scala new file mode 100644 index 000000000..d8304926d --- /dev/null +++ b/integration-test/src/test/scala/InheritInput.scala @@ -0,0 +1,17 @@ +package sbt.internal + +import java.lang.{ ProcessBuilder => JProcessBuilder } + +private[sbt] object InheritInput { + def apply(p: JProcessBuilder): Boolean = (redirectInput, inherit) match { + case (Some(m), Some(f)) => + m.invoke(p, f); true + case _ => false + } + + private[this] val pbClass = Class.forName("java.lang.ProcessBuilder") + private[this] val redirectClass = pbClass.getClasses find (_.getSimpleName == "Redirect") + + private[this] val redirectInput = redirectClass map (pbClass.getMethod("redirectInput", _)) + private[this] val inherit = redirectClass map (_ getField "INHERIT" get null) +} diff --git a/integration-test/src/test/scala/PowerAssertions.scala b/integration-test/src/test/scala/PowerAssertions.scala new file mode 100644 index 000000000..eb3671b76 --- /dev/null +++ b/integration-test/src/test/scala/PowerAssertions.scala @@ -0,0 +1,7 @@ +package example.test + +import com.eed3si9n.expecty.Expecty + +trait PowerAssertions { + lazy val assert: Expecty = new Expecty() +} diff --git a/integration-test/src/test/scala/Process.scala b/integration-test/src/test/scala/Process.scala new file mode 100644 index 000000000..40798e209 --- /dev/null +++ b/integration-test/src/test/scala/Process.scala @@ -0,0 +1,216 @@ +package sbt.internal + +import java.lang.{ Process => JProcess, ProcessBuilder => JProcessBuilder } +import java.io.{ Closeable, File, IOException } +import java.io.{ BufferedReader, InputStream, InputStreamReader, OutputStream, PipedInputStream, PipedOutputStream } +import java.net.URL + +trait ProcessExtra { + import Process._ + implicit def builderToProcess(builder: JProcessBuilder): ProcessBuilder = apply(builder) + implicit def fileToProcess(file: File): FilePartialBuilder = apply(file) + implicit def urlToProcess(url: URL): URLPartialBuilder = apply(url) + + implicit def buildersToProcess[T](builders: Seq[T])(implicit convert: T => SourcePartialBuilder): Seq[SourcePartialBuilder] = applySeq(builders) + + implicit def stringToProcess(command: String): ProcessBuilder = apply(command) + implicit def stringSeqToProcess(command: Seq[String]): ProcessBuilder = apply(command) +} + +/** Methods for constructing simple commands that can then be combined. */ +object Process extends ProcessExtra { + def apply(command: String): ProcessBuilder = apply(command, None) + + def apply(command: Seq[String]): ProcessBuilder = apply(command.toArray, None) + + def apply(command: String, arguments: Seq[String]): ProcessBuilder = apply(command :: arguments.toList, None) + /** create ProcessBuilder with working dir set to File and extra environment variables */ + def apply(command: String, cwd: File, extraEnv: (String, String)*): ProcessBuilder = + apply(command, Some(cwd), extraEnv: _*) + /** create ProcessBuilder with working dir set to File and extra environment variables */ + def apply(command: Seq[String], cwd: File, extraEnv: (String, String)*): ProcessBuilder = + apply(command, Some(cwd), extraEnv: _*) + /** create ProcessBuilder with working dir optionally set to File and extra environment variables */ + def apply(command: String, cwd: Option[File], extraEnv: (String, String)*): ProcessBuilder = { + apply(command.split("""\s+"""), cwd, extraEnv: _*) + // not smart to use this on windows, because CommandParser uses \ to escape ". + /*CommandParser.parse(command) match { + case Left(errorMsg) => error(errorMsg) + case Right((cmd, args)) => apply(cmd :: args, cwd, extraEnv : _*) + }*/ + } + /** create ProcessBuilder with working dir optionally set to File and extra environment variables */ + def apply(command: Seq[String], cwd: Option[File], extraEnv: (String, String)*): ProcessBuilder = { + val jpb = new JProcessBuilder(command.toArray: _*) + cwd.foreach(jpb directory _) + extraEnv.foreach { case (k, v) => jpb.environment.put(k, v) } + apply(jpb) + } + def apply(builder: JProcessBuilder): ProcessBuilder = new SimpleProcessBuilder(builder) + def apply(file: File): FilePartialBuilder = new FileBuilder(file) + def apply(url: URL): URLPartialBuilder = new URLBuilder(url) + + def applySeq[T](builders: Seq[T])(implicit convert: T => SourcePartialBuilder): Seq[SourcePartialBuilder] = builders.map(convert) + + def apply(value: Boolean): ProcessBuilder = apply(value.toString, if (value) 0 else 1) + def apply(name: String, exitValue: => Int): ProcessBuilder = new DummyProcessBuilder(name, exitValue) + + def cat(file: SourcePartialBuilder, files: SourcePartialBuilder*): ProcessBuilder = cat(file :: files.toList) + def cat(files: Seq[SourcePartialBuilder]): ProcessBuilder = + { + require(files.nonEmpty) + files.map(_.cat).reduceLeft(_ #&& _) + } +} + +trait SourcePartialBuilder extends NotNull { + /** Writes the output stream of this process to the given file. */ + def #>(f: File): ProcessBuilder = toFile(f, false) + /** Appends the output stream of this process to the given file. */ + def #>>(f: File): ProcessBuilder = toFile(f, true) + /** + * Writes the output stream of this process to the given OutputStream. The + * argument is call-by-name, so the stream is recreated, written, and closed each + * time this process is executed. + */ + def #>(out: => OutputStream): ProcessBuilder = #>(new OutputStreamBuilder(out)) + def #>(b: ProcessBuilder): ProcessBuilder = new PipedProcessBuilder(toSource, b, false, ExitCodes.firstIfNonzero) + private def toFile(f: File, append: Boolean) = #>(new FileOutput(f, append)) + def cat = toSource + protected def toSource: ProcessBuilder +} +trait SinkPartialBuilder extends NotNull { + /** Reads the given file into the input stream of this process. */ + def #<(f: File): ProcessBuilder = #<(new FileInput(f)) + /** Reads the given URL into the input stream of this process. */ + def #<(f: URL): ProcessBuilder = #<(new URLInput(f)) + /** + * Reads the given InputStream into the input stream of this process. The + * argument is call-by-name, so the stream is recreated, read, and closed each + * time this process is executed. + */ + def #<(in: => InputStream): ProcessBuilder = #<(new InputStreamBuilder(in)) + def #<(b: ProcessBuilder): ProcessBuilder = new PipedProcessBuilder(b, toSink, false, ExitCodes.firstIfNonzero) + protected def toSink: ProcessBuilder +} + +trait URLPartialBuilder extends SourcePartialBuilder +trait FilePartialBuilder extends SinkPartialBuilder with SourcePartialBuilder { + def #<<(f: File): ProcessBuilder + def #<<(u: URL): ProcessBuilder + def #<<(i: => InputStream): ProcessBuilder + def #<<(p: ProcessBuilder): ProcessBuilder +} + +/** + * Represents a process that is running or has finished running. + * It may be a compound process with several underlying native processes (such as 'a #&& b`). + */ +trait Process extends NotNull { + /** Blocks until this process exits and returns the exit code.*/ + def exitValue(): Int + /** Destroys this process. */ + def destroy(): Unit +} +/** Represents a runnable process. */ +trait ProcessBuilder extends SourcePartialBuilder with SinkPartialBuilder { + /** + * Starts the process represented by this builder, blocks until it exits, and returns the output as a String. Standard error is + * sent to the console. If the exit code is non-zero, an exception is thrown. + */ + def !! : String + /** + * Starts the process represented by this builder, blocks until it exits, and returns the output as a String. Standard error is + * sent to the provided ProcessLogger. If the exit code is non-zero, an exception is thrown. + */ + def !!(log: ProcessLogger): String + /** + * Starts the process represented by this builder. The output is returned as a Stream that blocks when lines are not available + * but the process has not completed. Standard error is sent to the console. If the process exits with a non-zero value, + * the Stream will provide all lines up to termination and then throw an exception. + */ + def lines: Stream[String] + /** + * Starts the process represented by this builder. The output is returned as a Stream that blocks when lines are not available + * but the process has not completed. Standard error is sent to the provided ProcessLogger. If the process exits with a non-zero value, + * the Stream will provide all lines up to termination but will not throw an exception. + */ + def lines(log: ProcessLogger): Stream[String] + /** + * Starts the process represented by this builder. The output is returned as a Stream that blocks when lines are not available + * but the process has not completed. Standard error is sent to the console. If the process exits with a non-zero value, + * the Stream will provide all lines up to termination but will not throw an exception. + */ + def lines_! : Stream[String] + /** + * Starts the process represented by this builder. The output is returned as a Stream that blocks when lines are not available + * but the process has not completed. Standard error is sent to the provided ProcessLogger. If the process exits with a non-zero value, + * the Stream will provide all lines up to termination but will not throw an exception. + */ + def lines_!(log: ProcessLogger): Stream[String] + /** + * Starts the process represented by this builder, blocks until it exits, and returns the exit code. Standard output and error are + * sent to the console. + */ + def ! : Int + /** + * Starts the process represented by this builder, blocks until it exits, and returns the exit code. Standard output and error are + * sent to the given ProcessLogger. + */ + def !(log: ProcessLogger): Int + /** + * Starts the process represented by this builder, blocks until it exits, and returns the exit code. Standard output and error are + * sent to the console. The newly started process reads from standard input of the current process. + */ + def !< : Int + /** + * Starts the process represented by this builder, blocks until it exits, and returns the exit code. Standard output and error are + * sent to the given ProcessLogger. The newly started process reads from standard input of the current process. + */ + def !<(log: ProcessLogger): Int + /** Starts the process represented by this builder. Standard output and error are sent to the console.*/ + def run(): Process + /** Starts the process represented by this builder. Standard output and error are sent to the given ProcessLogger.*/ + def run(log: ProcessLogger): Process + /** Starts the process represented by this builder. I/O is handled by the given ProcessIO instance.*/ + def run(io: ProcessIO): Process + /** + * Starts the process represented by this builder. Standard output and error are sent to the console. + * The newly started process reads from standard input of the current process if `connectInput` is true. + */ + def run(connectInput: Boolean): Process + /** + * Starts the process represented by this builder, blocks until it exits, and returns the exit code. Standard output and error are + * sent to the given ProcessLogger. + * The newly started process reads from standard input of the current process if `connectInput` is true. + */ + def run(log: ProcessLogger, connectInput: Boolean): Process + + def runBuffered(log: ProcessLogger, connectInput: Boolean): Process + + /** Constructs a command that runs this command first and then `other` if this command succeeds.*/ + def #&&(other: ProcessBuilder): ProcessBuilder + /** Constructs a command that runs this command first and then `other` if this command does not succeed.*/ + def #||(other: ProcessBuilder): ProcessBuilder + /** + * Constructs a command that will run this command and pipes the output to `other`. + * `other` must be a simple command. + * The exit code will be that of `other` regardless of whether this command succeeds. + */ + def #|(other: ProcessBuilder): ProcessBuilder + /** Constructs a command that will run this command and then `other`. The exit code will be the exit code of `other`.*/ + def ###(other: ProcessBuilder): ProcessBuilder + + def canPipeTo: Boolean +} +/** Each method will be called in a separate thread.*/ +final class ProcessIO(val writeInput: OutputStream => Unit, val processOutput: InputStream => Unit, val processError: InputStream => Unit, val inheritInput: JProcessBuilder => Boolean) extends NotNull { + def withOutput(process: InputStream => Unit): ProcessIO = new ProcessIO(writeInput, process, processError, inheritInput) + def withError(process: InputStream => Unit): ProcessIO = new ProcessIO(writeInput, processOutput, process, inheritInput) + def withInput(write: OutputStream => Unit): ProcessIO = new ProcessIO(write, processOutput, processError, inheritInput) +} +trait ProcessLogger { + def info(s: => String): Unit + def error(s: => String): Unit + def buffer[T](f: => T): T +} diff --git a/integration-test/src/test/scala/ProcessImpl.scala b/integration-test/src/test/scala/ProcessImpl.scala new file mode 100644 index 000000000..7c8e4bc01 --- /dev/null +++ b/integration-test/src/test/scala/ProcessImpl.scala @@ -0,0 +1,433 @@ +package sbt.internal + +import java.lang.{ Process => JProcess, ProcessBuilder => JProcessBuilder } +import java.io.{ BufferedReader, Closeable, InputStream, InputStreamReader, IOException, OutputStream, PrintStream } +import java.io.{ FilterInputStream, FilterOutputStream, PipedInputStream, PipedOutputStream } +import java.io.{ File, FileInputStream, FileOutputStream } +import java.net.URL + +/** Runs provided code in a new Thread and returns the Thread instance. */ +private object Spawn { + def apply(f: => Unit): Thread = apply(f, false) + def apply(f: => Unit, daemon: Boolean): Thread = + { + val thread = new Thread() { override def run() = { f } } + thread.setDaemon(daemon) + thread.start() + thread + } +} +private object Future { + def apply[T](f: => T): () => T = + { + val result = new SyncVar[Either[Throwable, T]] + def run(): Unit = + try { result.set(Right(f)) } + catch { case e: Exception => result.set(Left(e)) } + Spawn(run) + () => + result.get match { + case Right(value) => value + case Left(exception) => throw exception + } + } +} + +object BasicIO { + def apply(buffer: StringBuffer, log: Option[ProcessLogger], withIn: Boolean) = new ProcessIO(input(withIn), processFully(buffer), getErr(log), inheritInput(withIn)) + def apply(log: ProcessLogger, withIn: Boolean) = new ProcessIO(input(withIn), processInfoFully(log), processErrFully(log), inheritInput(withIn)) + + def getErr(log: Option[ProcessLogger]) = log match { case Some(lg) => processErrFully(lg); case None => toStdErr } + + private def processErrFully(log: ProcessLogger) = processFully(s => log.error(s)) + private def processInfoFully(log: ProcessLogger) = processFully(s => log.info(s)) + + def closeOut = (_: OutputStream).close() + final val BufferSize = 8192 + final val Newline = System.getProperty("line.separator") + + def close(c: java.io.Closeable) = try { c.close() } catch { case _: java.io.IOException => () } + def processFully(buffer: Appendable): InputStream => Unit = processFully(appendLine(buffer)) + def processFully(processLine: String => Unit): InputStream => Unit = + in => + { + val reader = new BufferedReader(new InputStreamReader(in)) + processLinesFully(processLine)(reader.readLine) + reader.close() + } + def processLinesFully(processLine: String => Unit)(readLine: () => String): Unit = { + def readFully(): Unit = { + val line = readLine() + if (line != null) { + processLine(line) + readFully() + } + } + readFully() + } + def connectToIn(o: OutputStream): Unit = transferFully(Uncloseable protect System.in, o) + def input(connect: Boolean): OutputStream => Unit = if (connect) connectToIn else closeOut + def standard(connectInput: Boolean): ProcessIO = standard(input(connectInput), inheritInput(connectInput)) + def standard(in: OutputStream => Unit, inheritIn: JProcessBuilder => Boolean): ProcessIO = new ProcessIO(in, toStdOut, toStdErr, inheritIn) + + def toStdErr = (in: InputStream) => transferFully(in, System.err) + def toStdOut = (in: InputStream) => transferFully(in, System.out) + + def transferFully(in: InputStream, out: OutputStream): Unit = + try { transferFullyImpl(in, out) } + catch { case _: InterruptedException => () } + + private[this] def appendLine(buffer: Appendable): String => Unit = + line => + { + buffer.append(line) + buffer.append(Newline) + } + + private[this] def transferFullyImpl(in: InputStream, out: OutputStream): Unit = { + val continueCount = 1 //if(in.isInstanceOf[PipedInputStream]) 1 else 0 + val buffer = new Array[Byte](BufferSize) + def read(): Unit = { + val byteCount = in.read(buffer) + if (byteCount >= continueCount) { + out.write(buffer, 0, byteCount) + out.flush() + read + } + } + read + in.close() + } + + def inheritInput(connect: Boolean) = { p: JProcessBuilder => if (connect) InheritInput(p) else false } +} +private[sbt] object ExitCodes { + def ignoreFirst: (Int, Int) => Int = (a, b) => b + def firstIfNonzero: (Int, Int) => Int = (a, b) => if (a != 0) a else b +} + +private[sbt] abstract class AbstractProcessBuilder extends ProcessBuilder with SinkPartialBuilder with SourcePartialBuilder { + def #&&(other: ProcessBuilder): ProcessBuilder = new AndProcessBuilder(this, other) + def #||(other: ProcessBuilder): ProcessBuilder = new OrProcessBuilder(this, other) + def #|(other: ProcessBuilder): ProcessBuilder = + { + require(other.canPipeTo, "Piping to multiple processes is not supported.") + new PipedProcessBuilder(this, other, false, exitCode = ExitCodes.ignoreFirst) + } + def ###(other: ProcessBuilder): ProcessBuilder = new SequenceProcessBuilder(this, other) + + protected def toSource = this + protected def toSink = this + + def run(): Process = run(false) + def run(connectInput: Boolean): Process = run(BasicIO.standard(connectInput)) + def run(log: ProcessLogger): Process = run(log, false) + def run(log: ProcessLogger, connectInput: Boolean): Process = run(BasicIO(log, connectInput)) + + private[this] def getString(log: Option[ProcessLogger], withIn: Boolean): String = + { + val buffer = new StringBuffer + val code = this ! BasicIO(buffer, log, withIn) + if (code == 0) buffer.toString else sys.error("Nonzero exit value: " + code) + } + def !! = getString(None, false) + def !!(log: ProcessLogger) = getString(Some(log), false) + def !!< = getString(None, true) + def !!<(log: ProcessLogger) = getString(Some(log), true) + + def lines: Stream[String] = lines(false, true, None) + def lines(log: ProcessLogger): Stream[String] = lines(false, true, Some(log)) + def lines_! : Stream[String] = lines(false, false, None) + def lines_!(log: ProcessLogger): Stream[String] = lines(false, false, Some(log)) + + private[this] def lines(withInput: Boolean, nonZeroException: Boolean, log: Option[ProcessLogger]): Stream[String] = + { + val streamed = Streamed[String](nonZeroException) + val process = run(new ProcessIO(BasicIO.input(withInput), BasicIO.processFully(streamed.process), BasicIO.getErr(log), BasicIO.inheritInput(withInput))) + Spawn { streamed.done(process.exitValue()) } + streamed.stream() + } + + def ! = run(false).exitValue() + def !< = run(true).exitValue() + def !(log: ProcessLogger) = runBuffered(log, false).exitValue() + def !<(log: ProcessLogger) = runBuffered(log, true).exitValue() + def runBuffered(log: ProcessLogger, connectInput: Boolean) = + log.buffer { run(log, connectInput) } + def !(io: ProcessIO) = run(io).exitValue() + + def canPipeTo = false +} + +private[sbt] class URLBuilder(url: URL) extends URLPartialBuilder with SourcePartialBuilder { + protected def toSource = new URLInput(url) +} +private[sbt] class FileBuilder(base: File) extends FilePartialBuilder with SinkPartialBuilder with SourcePartialBuilder { + protected def toSource = new FileInput(base) + protected def toSink = new FileOutput(base, false) + def #<<(f: File): ProcessBuilder = #<<(new FileInput(f)) + def #<<(u: URL): ProcessBuilder = #<<(new URLInput(u)) + def #<<(s: => InputStream): ProcessBuilder = #<<(new InputStreamBuilder(s)) + def #<<(b: ProcessBuilder): ProcessBuilder = new PipedProcessBuilder(b, new FileOutput(base, true), false, ExitCodes.firstIfNonzero) +} + +private abstract class BasicBuilder extends AbstractProcessBuilder { + protected[this] def checkNotThis(a: ProcessBuilder) = require(a != this, "Compound process '" + a + "' cannot contain itself.") + final def run(io: ProcessIO): Process = + { + val p = createProcess(io) + p.start() + p + } + protected[this] def createProcess(io: ProcessIO): BasicProcess +} +private abstract class BasicProcess extends Process { + def start(): Unit +} + +private abstract class CompoundProcess extends BasicProcess { + def destroy(): Unit = destroyer() + def exitValue() = getExitValue().getOrElse(sys.error("No exit code: process destroyed.")) + + def start() = getExitValue + + protected lazy val (getExitValue, destroyer) = + { + val code = new SyncVar[Option[Int]]() + code.set(None) + val thread = Spawn(code.set(runAndExitValue())) + + ( + Future { thread.join(); code.get }, + () => thread.interrupt() + ) + } + + /** Start and block until the exit value is available and then return it in Some. Return None if destroyed (use 'run')*/ + protected[this] def runAndExitValue(): Option[Int] + + protected[this] def runInterruptible[T](action: => T)(destroyImpl: => Unit): Option[T] = + { + try { Some(action) } + catch { case _: InterruptedException => destroyImpl; None } + } +} + +private abstract class SequentialProcessBuilder(a: ProcessBuilder, b: ProcessBuilder, operatorString: String) extends BasicBuilder { + checkNotThis(a) + checkNotThis(b) + override def toString = " ( " + a + " " + operatorString + " " + b + " ) " +} +private class PipedProcessBuilder(first: ProcessBuilder, second: ProcessBuilder, toError: Boolean, exitCode: (Int, Int) => Int) extends SequentialProcessBuilder(first, second, if (toError) "#|!" else "#|") { + override def createProcess(io: ProcessIO) = new PipedProcesses(first, second, io, toError, exitCode) +} +private class AndProcessBuilder(first: ProcessBuilder, second: ProcessBuilder) extends SequentialProcessBuilder(first, second, "#&&") { + override def createProcess(io: ProcessIO) = new AndProcess(first, second, io) +} +private class OrProcessBuilder(first: ProcessBuilder, second: ProcessBuilder) extends SequentialProcessBuilder(first, second, "#||") { + override def createProcess(io: ProcessIO) = new OrProcess(first, second, io) +} +private class SequenceProcessBuilder(first: ProcessBuilder, second: ProcessBuilder) extends SequentialProcessBuilder(first, second, "###") { + override def createProcess(io: ProcessIO) = new ProcessSequence(first, second, io) +} + +private class SequentialProcess(a: ProcessBuilder, b: ProcessBuilder, io: ProcessIO, evaluateSecondProcess: Int => Boolean) extends CompoundProcess { + protected[this] override def runAndExitValue() = + { + val first = a.run(io) + runInterruptible(first.exitValue)(first.destroy()) flatMap + { codeA => + if (evaluateSecondProcess(codeA)) { + val second = b.run(io) + runInterruptible(second.exitValue)(second.destroy()) + } else + Some(codeA) + } + } +} +private class AndProcess(a: ProcessBuilder, b: ProcessBuilder, io: ProcessIO) extends SequentialProcess(a, b, io, _ == 0) +private class OrProcess(a: ProcessBuilder, b: ProcessBuilder, io: ProcessIO) extends SequentialProcess(a, b, io, _ != 0) +private class ProcessSequence(a: ProcessBuilder, b: ProcessBuilder, io: ProcessIO) extends SequentialProcess(a, b, io, ignore => true) + +private class PipedProcesses(a: ProcessBuilder, b: ProcessBuilder, defaultIO: ProcessIO, toError: Boolean, exitCode: (Int, Int) => Int) extends CompoundProcess { + protected[this] override def runAndExitValue() = + { + val currentSource = new SyncVar[Option[InputStream]] + val pipeOut = new PipedOutputStream + val source = new PipeSource(currentSource, pipeOut, a.toString) + source.start() + + val pipeIn = new PipedInputStream(pipeOut) + val currentSink = new SyncVar[Option[OutputStream]] + val sink = new PipeSink(pipeIn, currentSink, b.toString) + sink.start() + + def handleOutOrError(fromOutput: InputStream) = currentSource.put(Some(fromOutput)) + + val firstIO = + if (toError) + defaultIO.withError(handleOutOrError) + else + defaultIO.withOutput(handleOutOrError) + val secondIO = defaultIO.withInput(toInput => currentSink.put(Some(toInput))) + + val second = b.run(secondIO) + val first = a.run(firstIO) + try { + runInterruptible { + val firstResult = first.exitValue + currentSource.put(None) + currentSink.put(None) + val secondResult = second.exitValue + exitCode(firstResult, secondResult) + } { + first.destroy() + second.destroy() + } + } finally { + BasicIO.close(pipeIn) + BasicIO.close(pipeOut) + } + } +} +private class PipeSource(currentSource: SyncVar[Option[InputStream]], pipe: PipedOutputStream, label: => String) extends Thread { + final override def run(): Unit = { + currentSource.get match { + case Some(source) => + try { BasicIO.transferFully(source, pipe) } + catch { case e: IOException => println("I/O error " + e.getMessage + " for process: " + label); e.printStackTrace() } + finally { + BasicIO.close(source) + currentSource.unset() + } + run() + case None => + currentSource.unset() + BasicIO.close(pipe) + } + } +} +private class PipeSink(pipe: PipedInputStream, currentSink: SyncVar[Option[OutputStream]], label: => String) extends Thread { + final override def run(): Unit = { + currentSink.get match { + case Some(sink) => + try { BasicIO.transferFully(pipe, sink) } + catch { case e: IOException => println("I/O error " + e.getMessage + " for process: " + label); e.printStackTrace() } + finally { + BasicIO.close(sink) + currentSink.unset() + } + run() + case None => + currentSink.unset() + } + } +} + +private[sbt] class DummyProcessBuilder(override val toString: String, exitValue: => Int) extends AbstractProcessBuilder { + override def run(io: ProcessIO): Process = new DummyProcess(exitValue) + override def canPipeTo = true +} +/** + * A thin wrapper around a java.lang.Process. `ioThreads` are the Threads created to do I/O. + * The implementation of `exitValue` waits until these threads die before returning. + */ +private class DummyProcess(action: => Int) extends Process { + private[this] val exitCode = Future(action) + override def exitValue() = exitCode() + override def destroy(): Unit = () +} +/** Represents a simple command without any redirection or combination. */ +private[sbt] class SimpleProcessBuilder(p: JProcessBuilder) extends AbstractProcessBuilder { + override def run(io: ProcessIO): Process = + { + import io._ + val inherited = inheritInput(p) + val process = p.start() + + // spawn threads that process the output and error streams, and also write input if not inherited. + if (!inherited) + Spawn(writeInput(process.getOutputStream)) + val outThread = Spawn(processOutput(process.getInputStream)) + val errorThread = + if (!p.redirectErrorStream) + Spawn(processError(process.getErrorStream)) :: Nil + else + Nil + new SimpleProcess(process, outThread :: errorThread) + } + override def toString = p.command.toString + override def canPipeTo = true +} + +/** + * A thin wrapper around a java.lang.Process. `outputThreads` are the Threads created to read from the + * output and error streams of the process. + * The implementation of `exitValue` wait for the process to finish and then waits until the threads reading output and error streams die before + * returning. Note that the thread that reads the input stream cannot be interrupted, see https://github.com/sbt/sbt/issues/327 and + * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4514257 + */ +private class SimpleProcess(p: JProcess, outputThreads: List[Thread]) extends Process { + override def exitValue() = + { + try { + p.waitFor() + } catch { + case _: InterruptedException => p.destroy() + } + outputThreads.foreach(_.join()) // this ensures that all output is complete before returning (waitFor does not ensure this) + p.exitValue() + } + override def destroy() = p.destroy() +} + +private[sbt] class FileOutput(file: File, append: Boolean) extends OutputStreamBuilder(new FileOutputStream(file, append), file.getAbsolutePath) +private[sbt] class URLInput(url: URL) extends InputStreamBuilder(url.openStream, url.toString) +private[sbt] class FileInput(file: File) extends InputStreamBuilder(new FileInputStream(file), file.getAbsolutePath) + +import Uncloseable.protect +private[sbt] class OutputStreamBuilder(stream: => OutputStream, label: String) extends ThreadProcessBuilder(label, _.writeInput(protect(stream))) { + def this(stream: => OutputStream) = this(stream, "") +} +private[sbt] class InputStreamBuilder(stream: => InputStream, label: String) extends ThreadProcessBuilder(label, _.processOutput(protect(stream))) { + def this(stream: => InputStream) = this(stream, "") +} + +private[sbt] abstract class ThreadProcessBuilder(override val toString: String, runImpl: ProcessIO => Unit) extends AbstractProcessBuilder { + override def run(io: ProcessIO): Process = + { + val success = new SyncVar[Boolean] + success.put(false) + new ThreadProcess(Spawn { runImpl(io); success.set(true) }, success) + } +} +private[sbt] final class ThreadProcess(thread: Thread, success: SyncVar[Boolean]) extends Process { + override def exitValue() = + { + thread.join() + if (success.get) 0 else 1 + } + override def destroy(): Unit = thread.interrupt() +} + +object Uncloseable { + def apply(in: InputStream): InputStream = new FilterInputStream(in) { override def close(): Unit = () } + def apply(out: OutputStream): OutputStream = new FilterOutputStream(out) { override def close(): Unit = () } + def protect(in: InputStream): InputStream = if (in eq System.in) Uncloseable(in) else in + def protect(out: OutputStream): OutputStream = if ((out eq System.out) || (out eq System.err)) Uncloseable(out) else out +} +private[sbt] object Streamed { + def apply[T](nonzeroException: Boolean): Streamed[T] = + { + val q = new java.util.concurrent.LinkedBlockingQueue[Either[Int, T]] + def next(): Stream[T] = + q.take match { + case Left(0) => Stream.empty + case Left(code) => if (nonzeroException) sys.error("Nonzero exit code: " + code) else Stream.empty + case Right(s) => Stream.cons(s, next) + } + new Streamed((s: T) => q.put(Right(s)), code => q.put(Left(code)), () => next()) + } +} + +private[sbt] final class Streamed[T](val process: T => Unit, val done: Int => Unit, val stream: () => Stream[T]) extends NotNull \ No newline at end of file diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala new file mode 100644 index 000000000..1d5a8a231 --- /dev/null +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -0,0 +1,24 @@ +package example.test + +import minitest._ +import scala.sys.process._ +import java.io.File + +object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { + lazy val sbtScript = new File("target/universal/stage/bin/sbt") + def sbtProcess(arg: String) = + sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest")) + + test("sbt runs") { + assert(sbtScript.exists) + val out = sbtProcess("compile -v").! + assert(out == 0) + () + } + + test("sbt -no-colors") { + val out = sbtProcess("compile -no-colors -v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.log.noformat=true")) + () + } +} diff --git a/integration-test/src/test/scala/SyncVar.scala b/integration-test/src/test/scala/SyncVar.scala new file mode 100644 index 000000000..5754e6da0 --- /dev/null +++ b/integration-test/src/test/scala/SyncVar.scala @@ -0,0 +1,38 @@ +package sbt.internal + +// minimal copy of scala.concurrent.SyncVar since that version deprecated put and unset +private[sbt] final class SyncVar[A] { + private[this] var isDefined: Boolean = false + private[this] var value: Option[A] = None + + /** Waits until a value is set and then gets it. Does not clear the value */ + def get: A = synchronized { + while (!isDefined) wait() + value.get + } + + /** Waits until a value is set, gets it, and finally clears the value. */ + def take(): A = synchronized { + try get finally unset() + } + + /** Sets the value, whether or not it is currently defined. */ + def set(x: A): Unit = synchronized { + isDefined = true + value = Some(x) + notifyAll() + } + + /** Sets the value, first waiting until it is undefined if it is currently defined. */ + def put(x: A): Unit = synchronized { + while (isDefined) wait() + set(x) + } + + /** Clears the value, whether or not it is current defined. */ + def unset(): Unit = synchronized { + isDefined = false + value = None + notifyAll() + } +} diff --git a/src/test/scala/RunnerTest.scala b/src/test/scala/RunnerTest.scala deleted file mode 100644 index 9db52d254..000000000 --- a/src/test/scala/RunnerTest.scala +++ /dev/null @@ -1,51 +0,0 @@ -package org.improving - -import scala.tools.nsc.io._ -import org.specs._ - -object SbtRunnerTest extends Specification { - val scripts = { - import Predef._ - List[String]( - """|sbt -sbt-create -sbt-snapshot -210 - |sbt update - |sbt about - """, - """|sbt -sbt-create -sbt-snapshot -29 - |sbt update - |sbt version - """, - """|sbt -sbt-create -sbt-version 0.7.7 -28 - |sbt help - |sbt -h - """ - ) map (_.trim.stripMargin.lines.toList) - } - - val singles = """ -sbt -v -d -no-colors update package -sbt -verbose -210 -debug -ivy /tmp update -""".trim.lines - - import scala.sys.process._ - - def sbtProjectLines(lines: List[String]) = { - println("Running: " + lines.mkString(", ")) - - val dir = Directory.makeTemp("sbt-runner-test").jfile - val result = lines map (x => Process(x, dir)) reduceLeft (_ #&& _) ! ; - - result == 0 - } - def sbtProjectLine(line: String) = - sbtProjectLines(List("sbt -sbt-create version", line)) - - "Sbt Runner" should { - "deal with lots of different command lines" in { - singles foreach (x => sbtProjectLine(x) mustEqual true) - } - "handle various command sequences" in { - scripts foreach (xs => sbtProjectLines(xs) mustEqual true) - } - } -} From b5cb8b4657772410f1ae82dbe70cf3ffb8eeb029 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 22 Feb 2019 22:31:58 -0500 Subject: [PATCH 347/483] Let -mem take higher precedence Fixes #256 JAVA_OPTS and SBT_OPTS are now read into an array first. If `-mem` is passed, it will evict all memory related options, and use the calculated memory options instead. --- .travis.yml | 2 +- .../src/test/scala/RunnerTest.scala | 20 ++++- src/universal/bin/sbt | 86 ++++++++++++------- 3 files changed, 74 insertions(+), 34 deletions(-) diff --git a/.travis.yml b/.travis.yml index aaaa5cf4f..588311e44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ matrix: include: ## build using JDK 8, test using JDK 8 - script: - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin integrationTest/test + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - cd citest && ./test.sh jdk: oraclejdk8 diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 1d5a8a231..ab238243c 100644 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -7,7 +7,13 @@ import java.io.File object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { lazy val sbtScript = new File("target/universal/stage/bin/sbt") def sbtProcess(arg: String) = - sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest")) + sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest"), + "JAVA_OPTS" -> "", + "SBT_OPTS" -> "") + def sbtProcessWithOpts(arg: String) = + sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest"), + "JAVA_OPTS" -> "-Xmx1024m", + "SBT_OPTS" -> "") test("sbt runs") { assert(sbtScript.exists) @@ -21,4 +27,16 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { assert(out.contains[String]("-Dsbt.log.noformat=true")) () } + + test("sbt -mem 503") { + val out = sbtProcess("compile -mem 503 -v").!!.linesIterator.toList + assert(out.contains[String]("-Xmx503m")) + () + } + + test("sbt -mem 503 with JAVA_OPTS") { + val out = sbtProcessWithOpts("compile -mem 503 -v").!!.linesIterator.toList + assert(out.contains[String]("-Xmx503m")) + () + } } diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 094134a1d..3c60188b0 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -5,6 +5,7 @@ declare -a residual_args declare -a java_args declare -a scalac_args declare -a sbt_commands +declare -a sbt_options declare java_cmd=java declare java_version declare init_sbt_version=_to_be_replaced @@ -117,34 +118,54 @@ addDebugger () { addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$1" } -get_mem_opts () { +addMemory () { + dlog "[addMemory] arg = '$1'" + # evict memory related options + local xs=("${java_args[@]}") + java_args=() + for i in "${xs[@]}"; do + if ! [[ "${i}" == *-Xmx* ]] && ! [[ "${i}" == *-Xms* ]] && ! [[ "${i}" == *-XX:MaxPermSize* ]] && ! [[ "${i}" == *-XX:MaxMetaspaceSize* ]] && ! [[ "${i}" == *-XX:ReservedCodeCacheSize* ]]; then + java_args+=("${i}") + fi + done + local ys=("${sbt_options[@]}") + sbt_options=() + for i in "${ys[@]}"; do + if ! [[ "${i}" == *-Xmx* ]] && ! [[ "${i}" == *-Xms* ]] && ! [[ "${i}" == *-XX:MaxPermSize* ]] && ! [[ "${i}" == *-XX:MaxMetaspaceSize* ]] && ! [[ "${i}" == *-XX:ReservedCodeCacheSize* ]]; then + sbt_options+=("${i}") + fi + done + # a ham-fisted attempt to move some memory settings in concert + local mem=$1 + local codecache=$(( $mem / 8 )) + (( $codecache > 128 )) || codecache=128 + (( $codecache < 512 )) || codecache=512 + local class_metadata_size=$(( $codecache * 2 )) + if [[ -z $java_version ]]; then + java_version=$(jdk_version) + fi + local class_metadata_opt=$((( $java_version < 8 )) && echo "MaxPermSize" || echo "MaxMetaspaceSize") + + addJava "-Xms${mem}m" + addJava "-Xmx${mem}m" + addJava "-Xss2M" + addJava "-XX:ReservedCodeCacheSize=${codecache}m" + if [[ (( $java_version > 7 )) ]]; then + addJava "-XX:${class_metadata_opt}=${class_metadata_size}m" + fi +} + +addDefaultMemory() { # if we detect any of these settings in ${JAVA_OPTS} or ${JAVA_TOOL_OPTIONS} we need to NOT output our settings. # The reason is the Xms/Xmx, if they don't line up, cause errors. - if [[ "${JAVA_OPTS}" == *-Xmx* ]] || [[ "${JAVA_OPTS}" == *-Xms* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxPermSize* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${JAVA_OPTS}" == *-XX:ReservedCodeCacheSize* ]]; then - echo "" - elif [[ "${JAVA_TOOL_OPTIONS}" == *-Xmx* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-Xms* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxPermSize* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-XX:ReservedCodeCacheSize* ]]; then - echo "" - elif [[ "${SBT_OPTS}" == *-Xmx* ]] || [[ "${SBT_OPTS}" == *-Xms* ]] || [[ "${SBT_OPTS}" == *-XX:MaxPermSize* ]] || [[ "${SBT_OPTS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${SBT_OPTS}" == *-XX:ReservedCodeCacheSize* ]]; then - echo "" + if [[ "${java_args[@]}" == *-Xmx* ]] || [[ "${java_args[@]}" == *-Xms* ]]; then + : + elif [[ "${JAVA_TOOL_OPTIONS}" == *-Xmx* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-Xms* ]]; then + : + elif [[ "${sbt_options[@]}" == *-Xmx* ]] || [[ "${sbt_options[@]}" == *-Xms* ]]; then + : else - # a ham-fisted attempt to move some memory settings in concert - # so they need not be messed around with individually. - local mem=${1:-$sbt_default_mem} - local codecache=$(( $mem / 8 )) - (( $codecache > 128 )) || codecache=128 - (( $codecache < 512 )) || codecache=512 - local class_metadata_size=$(( $codecache * 2 )) - if [[ -z $java_version ]]; then - java_version=$(jdk_version) - fi - local class_metadata_opt=$((( $java_version < 8 )) && echo "MaxPermSize" || echo "MaxMetaspaceSize") - - local arg_xms=$([[ "${java_args[@]}" == *-Xms* ]] && echo "" || echo "-Xms${mem}m") - local arg_xmx=$([[ "${java_args[@]}" == *-Xmx* ]] && echo "" || echo "-Xmx${mem}m") - local arg_rccs=$([[ "${java_args[@]}" == *-XX:ReservedCodeCacheSize* ]] && echo "" || echo "-XX:ReservedCodeCacheSize=${codecache}m") - local arg_meta=$([[ "${java_args[@]}" == *-XX:${class_metadata_opt}* && ! (( $java_version < 8 )) ]] && echo "" || echo "-XX:${class_metadata_opt}=${class_metadata_size}m") - - echo "${arg_xms} ${arg_xmx} ${arg_rccs} ${arg_meta}" + addMemory $sbt_default_mem fi } @@ -211,7 +232,7 @@ process_args () { -d|-debug) debug=1 && addSbt "-debug" && shift ;; -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; - -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; + -mem) require_arg integer "$1" "$2" && addMemory "$2" && shift 2 ;; -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; -batch) exec Date: Sat, 23 Feb 2019 00:02:48 -0500 Subject: [PATCH 348/483] Staging is required before the test --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 588311e44..7c92f1ad4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ matrix: - unset _JAVA_OPTIONS - curl -sL https://raw.githubusercontent.com/shyiko/jabba/0.10.1/install.sh | bash && . ~/.jabba/jabba.sh script: - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin integrationTest/test + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" && java -Xmx32m -version - cd citest && ./test.sh jdk: oraclejdk8 From f3e7aa008917ddb06484b82e4a8dc88fcf3c636e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 5 Apr 2019 09:11:01 -0400 Subject: [PATCH 349/483] Apache License 2.0 --- LICENSE | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++ LICENSE.txt | 11 --- NOTICE | 45 ++++++++++++ build.sbt | 5 ++ 4 files changed, 252 insertions(+), 11 deletions(-) create mode 100644 LICENSE delete mode 100644 LICENSE.txt create mode 100644 NOTICE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 563beedc6..000000000 --- a/LICENSE.txt +++ /dev/null @@ -1,11 +0,0 @@ -// Generated from http://www.opensource.org/licenses/bsd-license.php -Copyright (c) 2011 - 2018, Paul Phillips, Lightbend, and other contributors. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/NOTICE b/NOTICE new file mode 100644 index 000000000..6b28ce942 --- /dev/null +++ b/NOTICE @@ -0,0 +1,45 @@ +sbt +https://www.scala-sbt.org/ +Copyright 2011 - 2019, Lightbend, Inc. +Copyright 2008 - 2010, Mark Harrah +Licensed under Apache v2 license (see LICENSE) + +Portions based on code from the Scala compiler. Portions of the Scala +library are distributed with the launcher. +Copyright 2002-2008 EPFL, Lausanne + +JLine is distributed with the launcher. +It is licensed under a BSD-style license + +Portions based on code from sbt launcher script +Copyright 2011 - 2012, Paul Phillips, and other contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Apache Ivy, licensed under the Apache License, Version 2.0 + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + +Portions of Ivy were originally developed by +Jayasoft SARL (http://www.jayasoft.fr/) +and are licensed to the Apache Software Foundation under the +"Software Grant License Agreement" + +THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/build.sbt b/build.sbt index 96777b968..c8a72f9cd 100644 --- a/build.sbt +++ b/build.sbt @@ -175,6 +175,11 @@ val root = (project in file(".")). } else Def.task { Seq[(File, String)]() } }).value, + mappings in Universal ++= { + val base = baseDirectory.value + if (sbtVersionToRelease startsWith "0.13.") Nil + else Seq[(File, String)](base / "LICENSE" -> "LICENSE", base / "NOTICE" -> "NOTICE") + }, // Misccelaneous publishing stuff... projectID in Debian := { From fddd10e663cc774740f99350f32d7e14d6bcf4d0 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 5 Apr 2019 09:13:46 -0400 Subject: [PATCH 350/483] Readme --- README.md | 55 ++++++++++--------------------------------------------- 1 file changed, 10 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 7e19fa695..85df53a36 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,10 @@ -# Build Status +sbt: the launcher script +======================== -[![Build Status](https://travis-ci.org/sbt/sbt-launcher-package.svg?branch=master)](https://travis-ci.org/sbt/sbt-launcher-package) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/sbt/sbt-launcher-package?branch=master&svg=true&retina=true)](https://ci.appveyor.com/project/sbt/sbt-launcher-package) - -sbt: the launcher -================== - -An alternative script for running [sbt](https://github.com/sbt/sbt). -It works with sbt 0.7.x projects as well as 0.10+. If you're in an sbt -project directory, the runner will figure out the versions of sbt and -scala required by the project and download them if necessary. - -Sample usage: create a new project using a snapshot version of sbt as -well as a snapshot version of scala, then run the sbt "about" command. - - % sbt -v -sbt-snapshot -210 -sbt-create about - Detected sbt version 0.11.3-SNAPSHOT - sbt snapshot is 0.11.3-20111207-052114 - # Executing command line: - java - -XX:+CMSClassUnloadingEnabled - -Xms1536m - -Xmx1536m - -XX:MaxPermSize=384m - -XX:ReservedCodeCacheSize=192m - -Dfile.encoding=UTF8 - -jar - /r/sbt-extras/.lib/0.11.3-SNAPSHOT/sbt-launch.jar - "set resolvers in ThisBuild += ScalaToolsSnapshots" - "++ 2.10.0-SNAPSHOT" - about - - [info] Loading global plugins from /Users/paulp/.sbt/plugins - [info] Set current project to default-71999b (in build file:/Users/paulp/Desktop/new/) - [info] Reapplying settings... - [info] Set current project to default-71999b (in build file:/Users/paulp/Desktop/new/) - Setting version to 2.10.0-SNAPSHOT - [info] Set current project to default-71999b (in build file:/Users/paulp/Desktop/new/) - [info] This is sbt 0.11.3-20111207-052114 - [info] The current project is {file:/Users/paulp/Desktop/new/}default-71999b - [info] The current project is built against Scala 2.10.0-SNAPSHOT - [info] sbt, sbt plugins, and build definitions are using Scala 2.9.1 +This is a launcher script for running [sbt](https://github.com/sbt/sbt). Current -help output: + ```bash Usage: sbt [options] @@ -83,14 +45,17 @@ Usage: sbt [options] -S-X add -X to sbt's scalacOptions (-S is stripped) ``` -## Native Packages ## +### Native packages -This project also includes native packages to run SBT for +This project also includes native packages to run sbt for * Windows * RedHat (rpm) * Debian (deb) -* Homebrew (coming soon!) Locations for download to be available soon. +### Build status + +[![Build Status](https://travis-ci.org/sbt/sbt-launcher-package.svg?branch=master)](https://travis-ci.org/sbt/sbt-launcher-package) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/sbt/sbt-launcher-package?branch=master&svg=true&retina=true)](https://ci.appveyor.com/project/sbt/sbt-launcher-package) From 56f09ef1eca330b84f884788b182e7a32dafa12e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 5 Apr 2019 10:20:52 -0400 Subject: [PATCH 351/483] support GNU style double dash options --- .../src/test/scala/RunnerTest.scala | 6 ++ src/universal/bin/sbt | 84 +++++++++---------- src/universal/bin/sbt-launch-lib.bash | 36 ++++---- src/universal/bin/sbt.bat | 6 +- 4 files changed, 70 insertions(+), 62 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index ab238243c..0b9d63787 100644 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -28,6 +28,12 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } + test("sbt --no-colors") { + val out = sbtProcess("compile --no-colors -v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.log.noformat=true")) + () + } + test("sbt -mem 503") { val out = sbtProcess("compile -mem 503 -v").!!.linesIterator.toList assert(out.contains[String]("-Xmx503m")) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 3c60188b0..c426ff9ea 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -35,7 +35,7 @@ CYGWIN_FLAG=$(if is_cygwin; then echo true; else echo false; fi) # windows style paths. cygwinpath() { local file="$1" - if [[ "$CYGWIN_FLAG" == "true" ]]; then + if [[ "$CYGWIN_FLAG" == "true" ]]; then #" echo $(cygpath -w $file) else echo $file @@ -387,7 +387,7 @@ run() { copyRt #If we're in cygwin, we should use the windows config, and terminal hacks - if [[ "$CYGWIN_FLAG" == "true" ]]; then + if [[ "$CYGWIN_FLAG" == "true" ]]; then #" stty -icanon min 1 -echo > /dev/null 2>&1 addJava "-Djline.terminal=jline.UnixTerminal" addJava "-Dsbt.cygwin=true" @@ -405,7 +405,7 @@ run() { exit_code=$? # Clean up the terminal from cygwin hacks. - if [[ "$CYGWIN_FLAG" == "true" ]]; then + if [[ "$CYGWIN_FLAG" == "true" ]]; then #" stty icanon echo > /dev/null 2>&1 fi exit $exit_code @@ -421,41 +421,41 @@ usage() { cat < path to global settings/plugins directory (default: ~/.sbt) - -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) - -ivy path to local Ivy repository (default: ~/.ivy2) - -mem set memory options (default: $sbt_default_mem, which is $(get_mem_opts)) - -no-share use all local caches; no sharing - -no-global uses global caches, but does not use global ~/.sbt directory. - -jvm-debug Turn on JVM debugging, open at the given port. - -batch Disable interactive mode + -h | --help print this message + -v | --verbose this runner is chattier + -d | --debug set sbt log level to debug + --no-colors disable ANSI color codes + --sbt-create start sbt even if current directory contains no sbt project + --sbt-dir path to global settings/plugins directory (default: ~/.sbt) + --sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) + --ivy path to local Ivy repository (default: ~/.ivy2) + --mem set memory options (default: $sbt_default_mem, which is $(get_mem_opts)) + --no-share use all local caches; no sharing + --no-global uses global caches, but does not use global ~/.sbt directory. + --jvm-debug Turn on JVM debugging, open at the given port. + --batch Disable interactive mode # sbt version (default: from project/build.properties if present, else latest release) - -sbt-version use the specified version of sbt - -sbt-jar use the specified jar as the sbt launcher - -sbt-rc use an RC version of sbt - -sbt-snapshot use a snapshot version of sbt + --sbt-version use the specified version of sbt + --sbt-jar use the specified jar as the sbt launcher + --sbt-rc use an RC version of sbt + --sbt-snapshot use a snapshot version of sbt # java version (default: java from PATH, currently $(java -version 2>&1 | grep version)) - -java-home alternate JAVA_HOME + --java-home alternate JAVA_HOME # jvm options and output control - JAVA_OPTS environment variable, if unset uses "$default_java_opts" - .jvmopts if this file exists in the current directory, its contents - are appended to JAVA_OPTS - SBT_OPTS environment variable, if unset uses "$default_sbt_opts" - .sbtopts if this file exists in the current directory, its contents - are prepended to the runner args - /etc/sbt/sbtopts if this file exists, it is prepended to the runner args - -Dkey=val pass -Dkey=val directly to the java runtime - -J-X pass option -X directly to the java runtime - (-J is stripped) - -S-X add -X to sbt's scalacOptions (-S is stripped) + JAVA_OPTS environment variable, if unset uses "$default_java_opts" + .jvmopts if this file exists in the current directory, its contents + are appended to JAVA_OPTS + SBT_OPTS environment variable, if unset uses "$default_sbt_opts" + .sbtopts if this file exists in the current directory, its contents + are prepended to the runner args + /etc/sbt/sbtopts if this file exists, it is prepended to the runner args + -Dkey=val pass -Dkey=val directly to the java runtime + -J-X pass option -X directly to the java runtime + (-J is stripped) + -S-X add -X to sbt's scalacOptions (-S is stripped) In the case of duplicated or conflicting options, the order above shows precedence: JAVA_OPTS lowest, command line options highest. @@ -467,19 +467,19 @@ EOM process_my_args () { while [[ $# -gt 0 ]]; do case "$1" in - -no-colors) addJava "-Dsbt.log.noformat=true" && shift ;; - -no-share) addJava "$noshare_opts" && shift ;; - -no-global) addJava "-Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;; - -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; - -sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;; - -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; - -batch) exec - -sbt-create) sbt_create=true && shift ;; + -sbt-create|--sbt-create) sbt_create=true && shift ;; - new) sbt_new=true && addResidual "$1" && shift ;; + new) sbt_new=true && addResidual "$1" && shift ;; - *) addResidual "$1" && shift ;; + *) addResidual "$1" && shift ;; esac done diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index ce022f7db..29631a599 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -175,27 +175,27 @@ jdk_version() { process_args () { while [[ $# -gt 0 ]]; do case "$1" in - -h|-help) usage; exit 1 ;; - -v|-verbose) verbose=1 && shift ;; - -d|-debug) debug=1 && addSbt "-debug" && shift ;; + -h|-help|--help) usage; exit 1 ;; + -v|-verbose|--verbose) verbose=1 && shift ;; + -d|-debug|--debug) debug=1 && addSbt "-debug" && shift ;; - -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; - -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; - -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; - -batch) exec nul >nul ) else if "!JVM_DEBUG!" == "true" ( set /a JVM_DEBUG_PORT=%1 2>nul >nul From a47004e01e7409f73c45ebd18bcc09f52fddd63b Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 5 Apr 2019 11:30:59 -0400 Subject: [PATCH 352/483] add options for timings, traces, supershell, and color `--supershell=*` will pass on to `-Dsbt.supershell=*`. --- .../src/test/scala/RunnerTest.scala | 18 ++++++++++++++++++ src/universal/bin/sbt | 14 +++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 0b9d63787..074d75c04 100644 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -34,6 +34,24 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } + test("sbt --color=false") { + val out = sbtProcess("compile --color=false -v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.color=false")) + () + } + + test("sbt --supershell=never") { + val out = sbtProcess("compile --supershell=never -v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.supershell=never")) + () + } + + test("sbt --timings") { + val out = sbtProcess("compile --timings -v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.task.timings=true")) + () + } + test("sbt -mem 503") { val out = sbtProcess("compile -mem 503 -v").!!.linesIterator.toList assert(out.contains[String]("-Xmx503m")) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index c426ff9ea..688b6b6e4 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -425,6 +425,12 @@ Usage: `basename "$0"` [options] -v | --verbose this runner is chattier -d | --debug set sbt log level to debug --no-colors disable ANSI color codes + --color=auto|always|true|false|never + enable or disable ANSI color codes (sbt 1.3 and above) + --supershell=auto|always|true|false|never + enable or disable supershell (sbt 1.3 and above) + --traces generate Trace Event report on shutdown (sbt 1.3 and above) + --timings display task timings report on shutdown --sbt-create start sbt even if current directory contains no sbt project --sbt-dir path to global settings/plugins directory (default: ~/.sbt) --sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) @@ -433,7 +439,7 @@ Usage: `basename "$0"` [options] --no-share use all local caches; no sharing --no-global uses global caches, but does not use global ~/.sbt directory. --jvm-debug Turn on JVM debugging, open at the given port. - --batch Disable interactive mode + --batch disable interactive mode # sbt version (default: from project/build.properties if present, else latest release) --sbt-version use the specified version of sbt @@ -468,6 +474,12 @@ process_my_args () { while [[ $# -gt 0 ]]; do case "$1" in -no-colors|--no-colors) addJava "-Dsbt.log.noformat=true" && shift ;; + -timings|--timings) addJava "-Dsbt.task.timings=true" && addJava "-Dsbt.task.timings.on.shutdown=true" && shift ;; + -traces|--traces) addJava "-Dsbt.traces=true" && shift ;; + --supershell=*) addJava "-Dsbt.supershell=${1:13}" && shift ;; + -supershell=*) addJava "-Dsbt.supershell=${1:12}" && shift ;; + --color=*) addJava "-Dsbt.color=${1:8}" && shift ;; + -color=*) addJava "-Dsbt.color=${1:7}" && shift ;; -no-share|--no-share) addJava "$noshare_opts" && shift ;; -no-global|--no-global) addJava "-Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;; -sbt-boot|--sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; From ffd80f5144d92e94d44f3582ec3b4c76740a45c4 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 8 May 2019 18:33:38 -0400 Subject: [PATCH 353/483] Delete sbt-launch-lib.bash The bash files were already merged in #257 --- src/universal/bin/sbt-launch-lib.bash | 359 -------------------------- 1 file changed, 359 deletions(-) delete mode 100755 src/universal/bin/sbt-launch-lib.bash diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash deleted file mode 100755 index 29631a599..000000000 --- a/src/universal/bin/sbt-launch-lib.bash +++ /dev/null @@ -1,359 +0,0 @@ -#!/usr/bin/env bash -# - -# A library to simplify using the SBT launcher from other packages. -# Note: This should be used by tools like giter8/conscript etc. - -# TODO - Should we merge the main SBT script with this library? - -declare -a residual_args -declare -a java_args -declare -a scalac_args -declare -a sbt_commands -declare java_cmd=java -declare java_version -declare init_sbt_version=_to_be_replaced -declare sbt_default_mem=1024 - -declare SCRIPT=$0 -while [ -h "$SCRIPT" ] ; do - ls=$(ls -ld "$SCRIPT") - # Drop everything prior to -> - link=$(expr "$ls" : '.*-> \(.*\)$') - if expr "$link" : '/.*' > /dev/null; then - SCRIPT="$link" - else - SCRIPT=$(dirname "$SCRIPT")/"$link" - fi -done -declare -r sbt_bin_dir="$(dirname "$SCRIPT")" -declare -r sbt_home="$(dirname "$sbt_bin_dir")" - -echoerr () { - echo 1>&2 "$@" -} -vlog () { - [[ $verbose || $debug ]] && echoerr "$@" -} -dlog () { - [[ $debug ]] && echoerr "$@" -} - -jar_file () { - echo "$(cygwinpath "${sbt_home}/bin/sbt-launch.jar")" -} - -acquire_sbt_jar () { - sbt_jar="$(jar_file)" - - if [[ ! -f "$sbt_jar" ]]; then - echoerr "Could not find launcher jar: $sbt_jar" - exit 2 - fi -} - -rt_export_file () { - echo "${sbt_bin_dir}/java9-rt-export.jar" -} - -execRunner () { - # print the arguments one to a line, shell-quoted - [[ $verbose || $debug ]] && echo "# Executing command line:" && { - for arg in "$@"; do - printf "%q\n" "$arg" - done - echo "" - } - - # THis used to be exec, but we loose the ability to re-hook stty then - # for cygwin... Maybe we should flag the feature here... - "$@" -} - -addJava () { - dlog "[addJava] arg = '$1'" - java_args=( "${java_args[@]}" "$1" ) -} -addSbt () { - dlog "[addSbt] arg = '$1'" - sbt_commands=( "${sbt_commands[@]}" "$1" ) -} -addResidual () { - dlog "[residual] arg = '$1'" - residual_args=( "${residual_args[@]}" "$1" ) -} -addDebugger () { - addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$1" -} - -get_mem_opts () { - # if we detect any of these settings in ${JAVA_OPTS} or ${JAVA_TOOL_OPTIONS} we need to NOT output our settings. - # The reason is the Xms/Xmx, if they don't line up, cause errors. - if [[ "${JAVA_OPTS}" == *-Xmx* ]] || [[ "${JAVA_OPTS}" == *-Xms* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxPermSize* ]] || [[ "${JAVA_OPTS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${JAVA_OPTS}" == *-XX:ReservedCodeCacheSize* ]]; then - echo "" - elif [[ "${JAVA_TOOL_OPTIONS}" == *-Xmx* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-Xms* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxPermSize* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-XX:ReservedCodeCacheSize* ]]; then - echo "" - elif [[ "${SBT_OPTS}" == *-Xmx* ]] || [[ "${SBT_OPTS}" == *-Xms* ]] || [[ "${SBT_OPTS}" == *-XX:MaxPermSize* ]] || [[ "${SBT_OPTS}" == *-XX:MaxMetaspaceSize* ]] || [[ "${SBT_OPTS}" == *-XX:ReservedCodeCacheSize* ]]; then - echo "" - else - # a ham-fisted attempt to move some memory settings in concert - # so they need not be messed around with individually. - local mem=${1:-$sbt_default_mem} - local codecache=$(( $mem / 8 )) - (( $codecache > 128 )) || codecache=128 - (( $codecache < 512 )) || codecache=512 - local class_metadata_size=$(( $codecache * 2 )) - if [[ -z $java_version ]]; then - java_version=$(jdk_version) - fi - local class_metadata_opt=$((( $java_version < 8 )) && echo "MaxPermSize" || echo "MaxMetaspaceSize") - - local arg_xms=$([[ "${java_args[@]}" == *-Xms* ]] && echo "" || echo "-Xms${mem}m") - local arg_xmx=$([[ "${java_args[@]}" == *-Xmx* ]] && echo "" || echo "-Xmx${mem}m") - local arg_rccs=$([[ "${java_args[@]}" == *-XX:ReservedCodeCacheSize* ]] && echo "" || echo "-XX:ReservedCodeCacheSize=${codecache}m") - local arg_meta=$([[ "${java_args[@]}" == *-XX:${class_metadata_opt}* && ! (( $java_version < 8 )) ]] && echo "" || echo "-XX:${class_metadata_opt}=${class_metadata_size}m") - - echo "${arg_xms} ${arg_xmx} ${arg_rccs} ${arg_meta}" - fi -} - -get_gc_opts () { - local older_than_9=$(( $java_version < 9 )) - - if [[ "$older_than_9" == "1" ]]; then - # don't need to worry about gc - echo "" - elif [[ "${JAVA_OPTS}" =~ Use.*GC ]] || [[ "${JAVA_TOOL_OPTIONS}" =~ Use.*GC ]] || [[ "${SBT_OPTS}" =~ Use.*GC ]] ; then - # GC arg has been passed in - don't change - echo "" - else - # Java 9+ so revert to old - echo "-XX:+UseParallelGC" - fi -} - -require_arg () { - local type="$1" - local opt="$2" - local arg="$3" - if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then - echo "$opt requires <$type> argument" - exit 1 - fi -} - -is_function_defined() { - declare -f "$1" > /dev/null -} - -# parses JDK version from the -version output line. -# 8 for 1.8.0_nn, 9 for 9-ea etc, and "no_java" for undetected -jdk_version() { - local result - local lines=$("$java_cmd" -Xms32M -Xmx32M -version 2>&1 | tr '\r' '\n') - local IFS=$'\n' - for line in $lines; do - if [[ (-z $result) && ($line = *"version \""*) ]] - then - local ver=$(echo $line | sed -e 's/.*version "\(.*\)"\(.*\)/\1/; 1q') - # on macOS sed doesn't support '?' - if [[ $ver = "1."* ]] - then - result=$(echo $ver | sed -e 's/1\.\([0-9]*\)\(.*\)/\1/; 1q') - else - result=$(echo $ver | sed -e 's/\([0-9]*\)\(.*\)/\1/; 1q') - fi - fi - done - if [[ -z $result ]] - then - result=no_java - fi - echo "$result" -} - -process_args () { - while [[ $# -gt 0 ]]; do - case "$1" in - -h|-help|--help) usage; exit 1 ;; - -v|-verbose|--verbose) verbose=1 && shift ;; - -d|-debug|--debug) debug=1 && addSbt "-debug" && shift ;; - - -ivy|--ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; - -mem|--mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; - -jvm-debug|--jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; - -batch|--batch) exec /dev/null 2>&1 && { - mkdir -p "$target_preloaded" - rsync -a --ignore-existing "$source_preloaded" "$target_preloaded" - } - } - } -} - -# Detect that we have java installed. -checkJava() { - local required_version="$1" - # Now check to see if it's a good enough version - local good_enough="$(expr $java_version ">=" $required_version)" - if [[ "$java_version" == "" ]]; then - echo - echo "No Java Development Kit (JDK) installation was detected." - echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download. - echo - exit 1 - elif [[ "$good_enough" != "1" ]]; then - echo - echo "The Java Development Kit (JDK) installation you have is not up to date." - echo $script_name requires at least version $required_version+, you have - echo version $java_version - echo - echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download - echo a valid JDK and install before running $script_name. - echo - exit 1 - fi -} - -copyRt() { - local at_least_9="$(expr $java_version ">=" 9)" - if [[ "$at_least_9" == "1" ]]; then - rtexport=$(rt_export_file) - # The grep for java9-rt-ext- matches the filename prefix printed in Export.java - java9_ext=$("$java_cmd" ${JAVA_OPTS} ${SBT_OPTS:-$default_sbt_opts} ${java_args[@]} \ - -jar "$rtexport" --rt-ext-dir | grep java9-rt-ext-) - java9_rt=$(echo "$java9_ext/rt.jar") - vlog "[copyRt] java9_rt = '$java9_rt'" - if [[ ! -f "$java9_rt" ]]; then - echo Copying runtime jar. - mkdir -p "$java9_ext" - execRunner "$java_cmd" \ - ${JAVA_OPTS} \ - ${SBT_OPTS:-$default_sbt_opts} \ - ${java_args[@]} \ - -jar "$rtexport" \ - "${java9_rt}" - fi - addJava "-Dscala.ext.dirs=${java9_ext}" - fi -} - -run() { - # process the combined args, then reset "$@" to the residuals - process_args "$@" - set -- "${residual_args[@]}" - argumentCount=$# - - # Copy preloaded repo to user's preloaded directory - syncPreloaded - - # no jar? download it. - [[ -f "$sbt_jar" ]] || acquire_sbt_jar "$sbt_version" || { - # still no jar? uh-oh. - echo "Download failed. Obtain the sbt-launch.jar manually and place it at $sbt_jar" - exit 1 - } - - # TODO - java check should be configurable... - checkJava "6" - - # Java 9 support - copyRt - - #If we're in cygwin, we should use the windows config, and terminal hacks - if [[ "$CYGWIN_FLAG" == "true" ]]; then - stty -icanon min 1 -echo > /dev/null 2>&1 - addJava "-Djline.terminal=jline.UnixTerminal" - addJava "-Dsbt.cygwin=true" - fi - - # run sbt - execRunner "$java_cmd" \ - $(get_mem_opts $sbt_mem) \ - $(get_gc_opts) \ - ${JAVA_OPTS} \ - ${SBT_OPTS:-$default_sbt_opts} \ - "${java_args[@]}" \ - -jar "$sbt_jar" \ - "${sbt_commands[@]}" \ - "${residual_args[@]}" - - exit_code=$? - - # Clean up the terminal from cygwin hacks. - if [[ "$CYGWIN_FLAG" == "true" ]]; then - stty icanon echo > /dev/null 2>&1 - fi - exit $exit_code -} From 88dc416932f7bd6e48899e0f289e4a487ac7bec5 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 9 May 2019 00:28:14 -0400 Subject: [PATCH 354/483] expand -no-colors alias in SBT_OPTS Fixes #260 This expands the JVM flag aliaes in SBT_OPTS, so `-no-colors` etc would work. --- .../src/test/scala/RunnerTest.scala | 23 +++- src/universal/bin/sbt | 120 ++++++++++-------- 2 files changed, 84 insertions(+), 59 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 074d75c04..489edb899 100644 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -10,10 +10,10 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest"), "JAVA_OPTS" -> "", "SBT_OPTS" -> "") - def sbtProcessWithOpts(arg: String) = + def sbtProcessWithOpts(arg: String, javaOpts: String, sbtOpts: String) = sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest"), - "JAVA_OPTS" -> "-Xmx1024m", - "SBT_OPTS" -> "") + "JAVA_OPTS" -> javaOpts, + "SBT_OPTS" -> sbtOpts) test("sbt runs") { assert(sbtScript.exists) @@ -58,9 +58,22 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } - test("sbt -mem 503 with JAVA_OPTS") { - val out = sbtProcessWithOpts("compile -mem 503 -v").!!.linesIterator.toList + test("sbt with -mem 503 in JAVA_OPTS") { + val out = sbtProcessWithOpts("compile -mem 503 -v", "-Xmx1024m", "").!!.linesIterator.toList assert(out.contains[String]("-Xmx503m")) () } + + test("sbt with -Xms2048M -Xmx2048M -Xss6M in SBT_OPTS") { + val out = sbtProcessWithOpts("compile -v", "", "-Xms2048M -Xmx2048M -Xss6M").!!.linesIterator.toList + assert(out.contains[String]("-Xss6M")) + () + } + + test("sbt with --no-colors in SBT_OPTS") { + val out = sbtProcessWithOpts("compile -v", "", "--no-colors").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.log.noformat=true")) + () + } + } diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 688b6b6e4..9dd623ec8 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -224,43 +224,6 @@ jdk_version() { echo "$result" } -process_args () { - while [[ $# -gt 0 ]]; do - case "$1" in - -h|-help) usage; exit 1 ;; - -v|-verbose) verbose=1 && shift ;; - -d|-debug) debug=1 && addSbt "-debug" && shift ;; - - -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; - -mem) require_arg integer "$1" "$2" && addMemory "$2" && shift 2 ;; - -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; - -batch) exec -sbt-create|--sbt-create) sbt_create=true && shift ;; @@ -516,6 +468,66 @@ process_my_args () { } } +## map over argument array. this is used to process both command line arguments and SBT_OPTS +map_args () { + local retarr=() + while [[ $# -gt 0 ]]; do + case "$1" in + -no-colors|--no-colors) retarr=( "${retarr[@]}" "-Dsbt.log.noformat=true" ) && shift ;; + -timings|--timings) retarr=( "${retarr[@]}" "-Dsbt.task.timings=true" "-Dsbt.task.timings.on.shutdown=true" ) && shift ;; + -traces|--traces) retarr=( "${retarr[@]}" "-Dsbt.traces=true" ) && shift ;; + --supershell=*) retarr=( "${retarr[@]}" "-Dsbt.supershell=${1:13}" ) && shift ;; + -supershell=*) retarr=( "${retarr[@]}" "-Dsbt.supershell=${1:12}" ) && shift ;; + --color=*) retarr=( "${retarr[@]}" "-Dsbt.color=${1:8}" ) && shift ;; + -color=*) retarr=( "${retarr[@]}" "-Dsbt.color=${1:7}" ) && shift ;; + -no-share|--no-share) retarr=( "${retarr[@]}" "$noshare_opts" ) && shift ;; + -no-global|--no-global) retarr=( "${retarr[@]}" "-Dsbt.global.base=$(pwd)/project/.sbtboot" ) && shift ;; + -sbt-boot|--sbt-boot) require_arg path "$1" "$2" && retarr=( "${retarr[@]}" "-Dsbt.boot.directory=$2" ) && shift 2 ;; + -sbt-dir|--sbt-dir) require_arg path "$1" "$2" && retarr=( "${retarr[@]}" "-Dsbt.global.base=$2" ) && shift 2 ;; + -debug-inc|--debug-inc) retarr=( "${retarr[@]}" "-Dxsbt.inc.debug=true" ) && shift ;; + *) retarr=( "${retarr[@]}" "$1" ) && shift ;; + esac + done + declare -p retarr +} + +process_args () { + while [[ $# -gt 0 ]]; do + case "$1" in + -h|-help) usage; exit 1 ;; + -v|-verbose) verbose=1 && shift ;; + -d|-debug) debug=1 && addSbt "-debug" && shift ;; + + -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; + -mem) require_arg integer "$1" "$2" && addMemory "$2" && shift 2 ;; + -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; + -batch) exec Date: Thu, 9 May 2019 23:17:22 -0400 Subject: [PATCH 355/483] Fix dangling ivy.xml without JAR files Fixes #250 Ref https://github.com/sbt/sbt/issues/4661 Ref https://github.com/sbt/sbt-export-repo/pull/1 --- .appveyor.yml | 4 ++-- .travis.yml | 2 +- build.sbt | 36 ++++++++++++++++++------------------ project/plugins.sbt | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index b18d73b07..680470c9d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -13,7 +13,7 @@ install: Add-Type -AssemblyName System.IO.Compression.FileSystem if (!(Test-Path -Path "C:\sbt" )) { (new-object System.Net.WebClient).DownloadFile( - 'https://piccolo.link/sbt-0.13.17.zip', + 'https://piccolo.link/sbt-0.13.18.zip', 'C:\sbt-bin.zip' ) [System.IO.Compression.ZipFile]::ExtractToDirectory("C:\sbt-bin.zip", "C:\sbt") @@ -22,7 +22,7 @@ install: - SET SBT_OPTS=-XX:MaxPermSize=2g -Xmx4g -Dfile.encoding=UTF8 test_script: - - sbt "-Dsbt.build.version=1.1.2" universal:packageBin + - sbt "-Dsbt.build.version=1.2.8" universal:packageBin - cd citest - test.bat - test1.bat diff --git a/.travis.yml b/.travis.yml index 7c92f1ad4..213d7d1ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ language: scala env: global: - - SBT_VER=1.2.4 + - SBT_VER=1.2.8 matrix: include: diff --git a/build.sbt b/build.sbt index c8a72f9cd..84ef58036 100644 --- a/build.sbt +++ b/build.sbt @@ -14,6 +14,24 @@ lazy val sbtOfflineInstall = lazy val sbtVersionToRelease = sys.props.getOrElse("sbt.build.version", sys.env.getOrElse("sbt.build.version", { sys.error("-Dsbt.build.version must be set") })) + +lazy val scala210 = "2.10.7" +lazy val scala212 = "2.12.8" +lazy val scala210Jline = "org.scala-lang" % "jline" % scala210 +lazy val jansi = { + if (sbtVersionToRelease startsWith "1.") "org.fusesource.jansi" % "jansi" % "1.4" + else "org.fusesource.jansi" % "jansi" % "1.4" +} +lazy val scala212Jline = "jline" % "jline" % "2.14.6" +lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6" +lazy val scala212Compiler = "org.scala-lang" % "scala-compiler" % scala212 +lazy val sbtActual = "org.scala-sbt" % "sbt" % sbtVersionToRelease + +lazy val sbt013ExtraDeps = { + if (sbtVersionToRelease startsWith "0.13.") Seq(scala210Jline) + else Seq() +} + lazy val isExperimental = (sbtVersionToRelease contains "RC") || (sbtVersionToRelease contains "M") val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url") val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") @@ -288,24 +306,6 @@ def publishToSettings = def bintrayRelease(repo: BintrayRepo, pkg: String, version: String, log: Logger): Unit = repo.release(pkg, version, log) - -lazy val scala210 = "2.10.7" -lazy val scala212 = "2.12.7" -lazy val scala210Jline = "org.scala-lang" % "jline" % scala210 -lazy val jansi = { - if (sbtVersionToRelease startsWith "1.") "org.fusesource.jansi" % "jansi" % "1.4" - else "org.fusesource.jansi" % "jansi" % "1.4" -} -lazy val scala212Jline = "jline" % "jline" % "2.14.6" -lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6" -lazy val scala212Compiler = "org.scala-lang" % "scala-compiler" % scala212 -lazy val sbtActual = "org.scala-sbt" % "sbt" % sbtVersionToRelease - -lazy val sbt013ExtraDeps = { - if (sbtVersionToRelease startsWith "0.13.") Seq(scala210Jline) - else Seq() -} - def downloadUrl(uri: URI, out: File): Unit = { import dispatch.classic._ diff --git a/project/plugins.sbt b/project/plugins.sbt index 8c0785c95..4f87d4adb 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0-M9") libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.10" addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1") -addSbtPlugin("com.eed3si9n" % "sbt-export-repo" % "0.1.0") +addSbtPlugin("com.eed3si9n" % "sbt-export-repo" % "0.1.1") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.1") From c94af60119f54436ed524cf376d235e4c289afc1 Mon Sep 17 00:00:00 2001 From: cia-rana Date: Fri, 10 May 2019 12:19:28 +0900 Subject: [PATCH 356/483] Fix typo in execRunner() --- src/universal/bin/sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 9dd623ec8..7447bb89b 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -97,7 +97,7 @@ execRunner () { echo "" } - # THis used to be exec, but we loose the ability to re-hook stty then + # This used to be exec, but we loose the ability to re-hook stty then # for cygwin... Maybe we should flag the feature here... "$@" } From a85b486b4c4545dd1beabd39cf51321545bc57e1 Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Wed, 15 May 2019 10:52:39 -0400 Subject: [PATCH 357/483] export repo using Coursier (#267) export repo using Coursier Ref https://github.com/sbt/sbt/issues/4661 --- .appveyor.yml | 2 +- .travis.yml | 2 +- bin/coursier | Bin 0 -> 18500 bytes bin/coursier.bat | 95 ++++++++++++++++++++++++++++++++ build.sbt | 46 ++++++++++++---- citest/build.sbt | 3 +- citest/project/build.properties | 2 +- citest/test.bat | 2 +- citest/test.sh | 8 +-- citest/test1.bat | 2 +- citest/test2.bat | 2 +- src/universal/bin/sbt | 2 +- src/universal/bin/sbt.bat | 4 +- 13 files changed, 145 insertions(+), 25 deletions(-) create mode 100755 bin/coursier create mode 100644 bin/coursier.bat diff --git a/.appveyor.yml b/.appveyor.yml index 680470c9d..f0c903f69 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -22,7 +22,7 @@ install: - SET SBT_OPTS=-XX:MaxPermSize=2g -Xmx4g -Dfile.encoding=UTF8 test_script: - - sbt "-Dsbt.build.version=1.2.8" universal:packageBin + - sbt "-Dsbt.build.version=1.3.0-M4" universal:packageBin - cd citest - test.bat - test1.bat diff --git a/.travis.yml b/.travis.yml index 213d7d1ce..7f51ec42d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ language: scala env: global: - - SBT_VER=1.2.8 + - SBT_VER=1.3.0-M4 matrix: include: diff --git a/bin/coursier b/bin/coursier new file mode 100755 index 0000000000000000000000000000000000000000..e808b0db087e04b23284c027ceb95bd143182bc8 GIT binary patch literal 18500 zcmch<1#lh7vL-CHn3g$zo<^vY45fnJs1utd;Mb-SN!s&fWjL zh`&y>;+*d4uQE%O(3x3HLd4+Wq_Wk4sC1TXy(L6N&*dS!NJGwuiNOP=%}d(olKkw>FD0!KN7$H@qF({LMP=-OvuCYXKxcH1EW8GS@4lkQd$tw z5He9w{rjx3ovjHp^zTS?mIjXRaE!$NKXLIpwZC}#-xz!6>%YX4xrM3oJ0t&^^LJ)U z+)a!KEe%`^2r1}n?OaV9ElfQq2uY;`)dWAuE2t>{YaXE$q(Q+@fgm9vfue$P|7k3EKJ`2>2`L`PR@=7_6*hrF1AMI@23ptjjRovoTAjU)lt+@e@07k_A;)4 zPz9EXRE&s*7Fe=r(d5=sW}_vDeZ~nUiiBrzU{*YOH9ULuncY~$$UM`EDtA@ge4479 z7nl;5YT|cmkZzfT_50|b8sdGwzj}DuKDl9by*i#%3A*HWK?*C)No64APuBg_Uaton zYEt?!ZWniubr5zi4cE@0ZTt#;uod^hp>6UCcrXN)z`<+m3Tm(jH_Jiipt}*hq5Nk!BomFs#@bbcA7zkY4DC9S1=rXxw6d#H4N%e;LZ59V&47 zT}ALoeVOjMYBb&u3beK_`TiJ8rCVg_N|(%XH16Oe(DXeDm!(_ug6fyp_{x_ph?`#u zw_qY^9;MQ+8aU5zWT+p}NnrJ3jS|lW$WP1JCJ=2b&IIx@)prXm3wHPlQ-^O?Pnyq9 zO^QF6;yB{G3kpG<4aY9GW$LM>bQl{dK112>BPxKk7VJauHn2AoTC`W%`+iW5PiC7CS;|_t{(p+Hhz7kjqx2T^g z{I^n9*N?IY5&UMwG)NSn%2cRq84LaO^K@dXRMB^}6rlr%6BK(`+^Q7wf&q0h9wIK7 z3+vPlckHg=*>MNM({zgj+R(BBNvg8Y#MwOc-U?alI$Gqg06@abIzC$((mcxPPN?sy3Hc|ThOv00~t}ubhmiP`(I5#b~H7x2_20ENO z(MT(+MoA)^1&`-)O7}2NgJQjDT~w=KF4NG8DTEcMS zfzX8G(y@Y`lx4C{TdUh!v>Rb+TClPioJe< z!zrg7+Y07Km5mbxC_VZg0?732g72DqzLg-!w0sF_g?ggSL{~RQ#uzT2(Majx2k5La zAhS<3wZrdVWZU6*n}ns3&d*3?@dU0^8hlqpAdILw_x}cE#p^VWps|_QJD@c-nbSKc z8OXD{yR-=z2fM%l1x%U0kg zir~@P&O8W#9k&-h#-BZ%k<)yk4Z%P0!W#UfhLcY#*vb{lRgPGvrHh-x0&wAQ=W!i5 z#9w_CmIRi#<=w_4_p!X3_{3EqBlF0)V+M$6z-LLzw>`Qsu(wkf<==+={U4kI%klO? z?;TfQ-ar+kKR}ki-@B880|CWD0|EWl)vocs)$UhyC>_*AtTzOnRy(W#Or~t%0ODL- zbo&Y|BXsGqK+*(VVbK~KOXnp#12osglx0*y>(8Xe-dUu4vjH2btMrJa?N(M7EPS)i z9TyAi%RZZ@^yfSN37gkh9-DU^4{se0rUyNF2$`VOvZa?hqIzvh5iELMOA#^d4hs>J z?hYFflb^4+s=%s9p?E17X)dY!|e%|uMZxKC5Ecf ztIwIMPX3U80E0@ppJUl-jr*7WP%7FvNlw(J(>OFv5UBZnF$2DR7>{K;Bw3J;6V5wUl6Vg9Dv2-9$%F-(csJtniGiKZeh{Zj^?d8VK{$)8uC-Q8 znv~8`!fuY*%Kqe^KTB0OXqW)Vl){2)0YDrJPz#F0=aq1V*hP@f7NT*Cb?Gx(Xg8J= znTI?3BSd{9Ffr*1caK%*Oy(2atS{~$wB#vGv$1gMi$i>T!(Ab@)=V7?jd#!%B48V` zxQR<=FBmf(VLWR#&^0Kjp*f18If_wG&7DJF$7)GmagPeLiJm111t(Xe!!dHe9unUv zcZI7N5MDBhlvX$*x7JAH7XdCcpGq4|SD~?}U#vF2F0L6Jals3su;}EEBX?pd*Y=EL zf~MF}TQm>PXuEn52E2@>=ZVhb>J_3hwCX}HM7LSdTIQd+GYiTe{Ag_vNwBhnDnsXV zl#UvtTg?WW+qr3U#-t7$L6An)aa%^u_f85uHl^)EtLPz4&ofD~IN9~;m=bjR5g}rb z`$Cn#Y1(JIP+_prhg?a`mt`K1gd0y*H`QDc(fVb>hF;P$;&biL@^M10hjiwH3F{9t z*t;nvl0{QyJ0wg0Y5$n?As5kbXCN8UzMdX<%pdAMR6vu?zk_@vnN9*ZtYnL;vCuxM+!e5+$nM;pW zG%EsM=&-E6r-&LELvsY1)-ca72hjnl1p?B{6vb!sUHVz?jV}W&IfPYxwhR=U0${ld zksNdD#|ViHpgDq$&%cP+jmyVZ7ui5GNhEiHt=~%BW|o8RqswLr`UbJsKeIvO!+&Ol ze%^x;VT+*&$UN)$=4$s~d5*o!ue1Br2up{c+40st+qY6MK*6Ae0>h2^(>vWd9t1u~RfObZ` zg(B$0IIAn*P`D^e2WmFZB9wL~7CaRkJ7bf3%Bo5JqmxeuEw_SddFHHyiprC9?t>En zZ<2PkA(jqd-oRS>9$056dTKJiuA@tVrSkH(m7i4B0%xdt+wuus%b=)2vDTl_;rf)+ zDShFdN%#)AbyoMWzx@P0y;>a7_O~79i(1EWhTyA6HG_~ZAI)t$0{&l|`9vjtqe3RNhEej&6n~{%5Mf<*LBC^J z8a(q+{f=r2DR1~nn>e{RWJXme?erjA(F86NPT6-j9gh@%d4* zN+?zppD!uvC5fQ%1H&<@!u_)kSqEAQNDb<)T2T{nKU|%Pht(-juK1;7c#O5}w^v;} zAOMLk)znzzSs9IrRe}5Ob_q#iECxX>1|Uodf55?SoF-3x?S|WK_T`twk9SYpi+^Q~B=iH}77UIC`5| z_}ACCH?Bj^45y9@o=vWY9Cf)2i0btFmP=WTbEj=>dau=>XI=NMpbxr_O)zf`+vP9} zt(V~uTf`v|2 z&*~BnuR#=#P>gCS<@E~b@&wx`GvuyRSM+x)N%m`kYSZ1y0J%VatPW3cuj`Tp$wK9< zFhu7kzjW|R1Lvo)59v||mxG2az1)@s;ecApHDo_W=BzY?=g%{wk1o;p(o}r88yc>p zDP009eFf}?0PQ8Ql`x|H7}#}2jlLa0P2abuN;_}})D~yHVu1g<=Sy{&&}9eaLvv~7X9oV0h%p}k)45oT zDG&J~w-tk3l3Rvsu{Tf!{<9P?pd5!GFl(NATNt4Qg=WqwY|e7!6y?>E93{?{8bDyl zim^Fuj^9x>?Zulv4dNwF(n(u^>N{ng1IvK8E((INLxHX9*J)la7(D)%CWdpBFP7G) zhbS;r3_fXIpVA~%0itc(Sn(Jnwwm9hYr5*^YgvyXFmI0GQ?8gc=0Mg_rO1OnYtG@5 zKaJ0O*iC}Zd(v$Lwn2vLbg$F4VVh`6-27@HCcg%$DYhh^d|Jg&b*&wy*SS$5Zs^tc za;N%JZq{&v)z^(QC9;qE6%SCXm`MAu$lOp}-nKjt1tzcQVc+SaP!*NjAWN$(p3D_ zJ121rPmZDZkvu46 zli4?0^Vny>Zb`nj33$o5}+I9EJotaVNDk3*_OJlKel`^Nv#T z2tynk_&;|jE5D|K4QfiLWpd2LhGb5*e|uRssyzhg&;XVMZ@wt58fxg8x(DFHh)3<^ zW?SG(^xt6O$UBJJtv$XaA5&2*&=HJ&4P3^riEMEyBGdL6P{~_)0YM?P@l-PsaTpd~ zWeH!>AMn)PbuGXt`bbARn!=AMsYSA2gaU~(0NLJ%95*=EQhQ_l;AP^l%?VNKw3?!+ z(paRoBB}aQ!fY(T_)45sNbpM){bH&DD{_R!cgP90lxWY_=!L|C;4*D3H@0g$CA(C$ z8L6Wy=cRZZ7@V={ZpWmw5JN>}gw@5uCMEzQ%1`@X@;XG*g0PU5rO`Z%zM{Ex++A%# zK={r0D8|LntOB#lQcoGbIs`^E^rmYBi>iE}6S2%?(*U<@%1QdCVD+twEzufr4JPMo z(U=QFyE^fFOTYw16#l^-=bigns6)v8Ri-d5s;eobCAnroMIrKVD4;m(JJbQ@^hx=Z zrD^|C=S?kf!*ebEo>N?SP)ndQzRwY_*DmjioSx58C^kBb<*}Sqd5!qaIcuflu_C+? zQLA1sUwRa>YOg6zUqRb+v^n*1zfcAQit4}^$`=+P2y$_HQ}8H_qJE|Llmz8BDCK0t zxp=h*tY~Ku(iX$qehKnBxkmo558BRQlJR_L+5=E5wxs17+W?bbnM}FknfSCQe7zuK zNp{yk(H^wnHhg!#XP1F*%Q7YMF3y-xB5|-w(tX{JPY)kf^eSQ_s0k{=YQ-2I`h-k z9ry#S`J4z46J-=yH0jME*ig`a@D^gUC*n}0mFh(VGQXl_b&OvGb)CX_#j#~+o&LQtR1uVG2t!x@3(kp4j%J_@`iY}cfS zu7s>J=v>mF9G6!XL9_g|HXq~$cX+6Qc2}nG-enbhd{bPiY&=1;M#;2$r7dS8~WkH^}VuK{B=NIEh9ItpEJs@4w4}G zvg2L#pxO6~BMImNa1say_bAsVXqLx38anv8Mmu!8YF7>~(Nr^gT)KcxE`q8GN(ok< zYdXDeK$BTQ!OwPBFZNKDdLcdyPH_6sOxiD2gW_oxNF?*9qf5{B*8}Td+b5!KMmF#t z9>?vxKh`XT@)-5e{A8d)XW;1{otT{&f7BX_K;XFUN%!0N5)X1h=yk?_2xSe&`GINn zoW1db3PIY^)-I+1jyLWMs>*yZ>dH6`IX$+! zxL52gVp_Dh-;WqaB|SgPBFtvY6yC&0ZDIB3adIu9jwx*^E7-c30yFGVgX;|zB!<3Ael);v?# zx@T@|>SxnJ*q%Uij%upH3{$y7W){*|s!QSY^_1jRrI1{`j*})kp?BazQ9%XsteT0| zusD68cFgd=^4g6%Z(d6xoD|@}vk3O1-R3RO8vfzB#{7o{Lm-si>|nlKCTj z^>1gK=gw}C9|8gb1wzpk0@xKo&=rEn6~cfXf*eAQ9>Np?o*n`n0v;bi4}u;a!UqCh z48jy{oKXydDat&nysuW|HNCIR`E@HUcdX6XDmIXc9V%<@WhQrLY>xOf|K%laCoZ=S zB-_hE&k;g_61+TSoScQBt}hzk*Uu$D_7&jA1ONzvXR#Ad1^@)nvuZ^^uBjqnK_DNV zC`<~-lYsC5X~`*r*+W3aOkaRdV!>fS2!}uHL4jC^5ssHOWcYcLXaG|LK!S3pXh9dJ zLrL76nd(QcO>`aP6|@KVq2)#c|Lgf>qQ#?i=Y3x6|69*5M*p6&C}k^o6hTzJ*-Goy z@@qseG=-X-#)9&T52COgapc8e*zr#`Ej)>2t0|^DG*4Bm05!6!5080~ZsDqsn9B%< z6T53p1fGY3lXjcHYhACnl`GAryMjb)T#$!NzZw|Wr=L*XgOUZXN(RpTEQ=Dkyo5rim*Q7> zrmn&=ZCepc`Cx$>LQE7Vy4ZK!#+Qy!lF)_}aiTY<>vElZ3vX&dN_!E-BuoQ{yrn)P zC{%#N3A*Ka%J9%#^Eb?@2Ag0(G`deEK6$p3g zlep&tz%7VsR`|QuiyjzN&?)2CTjwX(eiF9`B8L72!p|Kfw!zRXxMNUc&P-7G_KQH=-SyLpjjCag?8kWHy@33Z z&E=K-H6#!qpeoRRl1-NXAe+kO2974i!oRZ0GIj>WCXRosxY$m)UPiv>CC?iuwlJ*fenA*2b;87!oQHu)IJBL7z*wjgPu^F3w+C1)hA~I(&h2 zj4*d7`}7GwULo;6GZCNmbBfT~b4z80V|>mlCsH+GF|$Y3 zHm5Eaju-bE7FfoMSh@e1uh!6t1XryM-9ZUX+0ZCOuc`fw8;OK;F|n<8eNoE=RA$l+s z8FRK;{4GFrlbNTYBtf~w&~%g$nE+j~;0`EMYb;klO|oM&w!m&O`AkNJSc)j`wp#?E zNv51|pbIuwfi;n*UmbSayu5mX5ovu5<3e=gN{OpUE1qYjslWBMgkj-YHBeg$(CZ+5 ztRc?TYfWLZO*|NToc$6qtR{kJ{W;hCIZ3B0FX&E3&Sj>yIL)FqRVzuVZlnjnI%R}? zvR=uVfv1v$WzKzpW(77rX%y?pHNSepHteKwsVuhn`~LaOVgzg|HVg_Z(rDQaKcnXo zzR7sMThXtj<=@m&DA6tpm0(6-d&#srszH&p@3p4V(M7Yy?O#8xSamSKH(FhLrJ~Lo z48W4$h4e8_9W*`M+erTuXB!+~bjr~^nWls8T(acJ#!|IzA}u*(G@(_(5Nz0)a%rF8 zsY+Nv=peBfn?83e7SHR?X9E+C>!4lPWXzBrgglJVw}r3VY3)Fh4<0HuB1Ds9d+x{PVx6Nz3-WYxiYE&j!9^-l`+WW;#kne_K`55z#E(>E#MpTS z^ZDq*ZSSM{tu3zbmW zp>7oGQ!ZKp0Eq=(EnNlm87?&irRo9%F%NRc*L<#s4I69=n=eOXDD`4UaRIf3RF(_S zXbm5Xl{t!JV={4xLB*>bvVxwuI0K?S@vDQwz#!BmoRVQT1kd$~*SYSn2NE9_y_xtA3ilkQ%)5p=-bUyW6 z0_zsF8xg-5YOx8#ZmWQM^`AbBcPr}#h(1;hfc7hep)<9AlD(fStyqea!XfpyQ$_$Ngb zbh$#~JsGiSC02=8>9|IW3aXM5&2WXZIVUmp3QRy?Wm-KymoSo}mSb$O-}Bh4?v@-? zsi6{~-$v}2blr3Jy1Zc{fYN{6;E59gRY`%A7S{ou7w+@E!8KjphFr>U*T_c}3%UZ_ z)#*vWmL`5&^bMXh01FFOyjtl{uQS#7+TbjuHUj)lu6y!f4z@b8si~M1ki}*7SVJ+x z+LbDtUa4@>&Cj$Y#$)xB0RA`67>DA_XZSSx%g;)ins~M3XGcQc4osZFtOc`_l#Aw~`djU+?XAlzz6G|+HdyU^Prq`hbj0n9 zWVQ>NWD7rl*~%cX=bkVU9a0tuXY(e?n%z~bGP>F$RK|?_n9uY*!`YtXM_GkH^^I_Tka4D@H@Q5zFEw$C^j80?5vAEZO=eiO*~`#$n*|_*ck%mXjmG zB<07vdq~P=m2waaqLP{$TKM3Z;=nRIK#PKY86t1fd*0@#fE!8zanZKn-WbDu%tT$Q z>qO1^!Q3E8wfz33J|hktj2d%XRR{9aCTG|($%cmdN+w<}mQ(XHI3Dd?rVC!0U{u$5 zUu&=mgDM66bas^FNFp>tcf1EM!-MUcOAIL#(;GQYes&hMpKc6`9Og^!j9hq5gO(~0B3mD!+>2QQ~v@v+mI9Fg2v`C)XKrW!d zrP>CV&E}-7Z)?kPNbY&pv&Jh$69p*GrE=OdWU%sEMNMkjU_!i7)Lx;LHI#XP^az+| zGj{MY!Izn`@$$TSIQRC?`Z7n+en#TNhq+3LeqnLZuM|wo~WuA`1Lg3{ffPfTX|H%>kPv*(|5A&pAp**XA z%7-8oUq~elgoMZercEh=&hfDxHMW3O2|Z$h(_;8zHfsiJ|8~*ihuboLWlZ}N0K(W~ z1THStg_Q|f(AZwvgPhz%>%+mi*XHIENH!jWsB`EM>NMR>SSS%v9kCuHCORTABM~93 zzEW4h7Ykq(`q1Ltt^F;h?x4?MTZv#$99(mb=37%kIVl0u-BCEmyj;!W+tGnSk6f(7 z?t$#^Zd|;v(=j2qAh@4Rc>BGvK#u@Sq1lm0^+TAVWsyv4@k|rjSSu#HhlqkS!ZnK+ zT61cw^NjO8B$aN=33v()bWByjHlq?_C>a-bvStp6ISZcG1)X;~+82BQ0;4U*LOq%F zNLjOVGf7zmMQ~;lTMRvqLQE_+1+eQ%d4(25*3!~(gc+f9h$d6faVuVgIUsm+bID@Z zE(M|{h^>YWBnC_CuoIO6@jY8hb0Y55b~~z!h`2{a_F&^&8TH-5O;(4tdhSm!RD(*G z5%eca&!`?6n(|8vhSDTjj!F>&7M}_g?X{RoC=Se#3V6hRegI}Qt1~G6@ks>cke359 z{J@0=Q8wkOzTzfUo_RM_7T?xzfR3d^`<}XAgodw1s2*^_MmsW8ADS3LAs2Gzyh2f| zGXsnE#>q+1Uq+?<$&`{WmmGuk#-&nbV!wc^S8Cd=b{te&om&)5i!tfgV?zo?tGHtQ z)@Z1xu>d}Q8PSdpyUhJzI$8W|L!LW$5Ga1@BXA9m73Fe&5gR37+iv-X_5kW2`N)D| z`JUa*XVQ9@B&BLeaU&chW4L|-#TGwl60d#rK)3{PF_z}FZS%FD!7Raj98MZMA}#P{ zW1P$(h)PO1$DwR7128NdvXCJOH63p)K$5ck2M#PY69u;34D90!Sn37End%#O!(xM? zE1IB}Or`i5KRPKhn5;SyVFClZz)zPj_As#z+aW+5FHTG@vPQOJizF_B zi$)YC5kVQwNwuSg^bp2Lw&R0@5bCbb*Gr6#aupa#A<9d)gM~C1?k?ANL#&5*)e(xI z>pmZ}sN=pK)TGR0 zi3YRTwnb%F#uzDKJ%T+kp<%gucV*q7lwm1SFPWoRczZsEt7FQsq#L+{E|aI59LvhE zZ_}~!58C6Wkb41X0)Z`o*aF)CH%%r1m}jr;)o!jX$UkL^l#SG!CiEvAOG+k54XECR zrUD$xX=b$)r|Vb}-2!YOgI!@XuwbKbljNjo((`5dceqLvmc(Lox}(2qsimx#@;WMf z^knpDa4k+AmmR^zs(@Cb9Gn^4kL-vdC>tg~-$KyCD>c0}*A4cKml*Eg1|Z9a-Og`) zmpN0=jahI^RE*FfqOq!}FFgU*jlVWlP%$Smuc7tmxD)WK1RV7FI;$0V-uXIxQioO< z`Po8@UzuXV=xzpA#Kx(`lmomXej~PM!@AG0KWtLtahT#lxhL zk;bN391yFuke!k1hq(En!%lLnsd^QKapR#nE4kT{A5+%~qF9z#?49Z*vtUeSbcxe~ zEX?P<-YYzvd2a0MY{k2bg15HDhAHbz7RR^VuKg6R+Y6GuS|_EpDcEWyK|RzlTrQSU zrlm&zNJ*BJd(z>LrI&fDNDmU&4CJYkksmV?Y<#G&n7Gk#ZZ7X=&e+0+B`@|I(%PEW zF6s6B3t!A`d&)WQ%i#~OobpF8Bv+yd-9%TUmF**5CtCGqj)uWLW_RQ><2@c#;ypoV_ ze8I6;kuURWfy?>0xiH%n>_NzsifYF^<)P^83-iosizf>MR_P1h$ki%&d&8|Xw zV|biiJf|hZ=!tHE`;|jPNKZT`$l&$~u0Z||Z`f3+mQU3gK|}o3?L8odhf@m%&f`fA zMk7vVybztQAOQK}l#IF4xtTekIY%`CBc0MOo+W2Tmyq}1&Sxq8rh8Kgfnmt=ZY zMm5q}BJZf=zwWG%Z)2M}@eW#;Yn9Tf+ZhsS6 z^e$h4%inn+i1(&v&0F9Y^hb-$R2vp_7tZf=lq+=A77E26PUqYZI8B4lS=0(lSp4ol z^1gaWr)+8ubA0u<=Z&a(ulY=}yrdp`SOYFY3XY4qZHV8Oz&csl>=6#_g{aEf)ke z=lby_wDk%jw6j+_uTnJq%WSp>)GkLP!wv`n`ZgP?s;`mwl zFOZN|!#&S>g+0Aei;F>fR-H(%kb5LKBE$S?w@gX7UC(+43?^pc&p&9_kODa1UJCsL z4D&VFFOy(F3Iz!b_w?8y6JY%d1sM(76qX4!m?2Xjazd{XO#)&K^gEkXT1YgGpU~)h zKicQ42f0L;2aF@G`ptLtXwK9xa%uEg?#_zDpwLad7vXPGAIL8x@Y|wS`aZiv^I& zy(9skC|&=GUtGYw(Zswvh*t3b9s6eaZ~OLV`heaQ0^apk&VU>O9Up=nLQM=p5$=Ca z5&X&>u&0f+jUn@hL7*SLB&di%EdL)e2AMN$d$8FG=p+H$Jqc57J2U?NFS&7ZsBivr zxqWeCFT9K4dvhR&0o}2FNalQyj37i)a3ACFhEPDl{ri^d>zh~@?ZC?Pf3f%hQczok zC-*&y*z$h-*G;nwD}lM(d}hMWC{(Wu@u`)==>ns;VNz78XUvuU%nR5i{v?S4U93+t8~x5M<5@$Yu+x6ogBE}IbLf-h4L`Ehy4By$Suf2QgDr!X^prxMoD`~ z8H~VXuoO>|98j#WIC^7ikUdSxdni$K2P|P3JwA$&JeiaWCWZ|d2M%M#TJG^H>{t4Cy+AP^Ca2UnF3p6J1ikE+4&kJ+2$H+iuFQ6kTr1ue?A9KL% z${aH(<$;g=&O0622szJyIlmV|rHsUz)aOOqn36m7vprEbn z!>e`6dtJwEh1NKhi7@O|sQo-iUj3O3^8&H*LOW;9Sw!Y?~@Zp*E^WLj_(JjYDZuCY|O})Mi(wcpTx2g&C&`_ z!-*evx-}h~GL1nQC8dm7F8Iu2MZn#cCh`>?G_KZw4m4X9=V>J>7Ja^d;87#mt;bb# z#keguj5=BlRMHn-4%6jwnUkXg^XN39G6Fq-8ke9n?Y`3Vcot;eoH-Vv=H4Ny#fxZX z24m&>Y%p{%LJ$65)D;5=B7q{Q(`FX=_yB$gt`bR0!D5somlkn{6r zo#UNr)87P*r(kNaV349>X3@WI)&2m>*Vrff^U<-DR`xsd2bE`$Dt4cWWHLx5t;?+1A}7VaOYYB57yT4!`?&U32;C0LC1+7Ieo&;}>E zt&kcLwxO0VX}+J`(Xj;XM@V_6jvOVoa;rH4MLbv`pt6$Wxi~_ex1HNQyxnqZl{VQu zHYZXUYVIPbILpUWYj(FWW#4FX5zzz!_hyo&#f8yb)8ZhOi1Y?<+4e%GRDMA zZB$|!3)lKoMg@p}T6@@(sOXZ3DH|}r(Ns;h(-NIk>XpdK`}rOYviR6-ZY)fXO`z+i za@ef$=@B`w%frQzcl|}zhTr){hPa#agJJ|`ei0Ji!3gVSjw$t6?RnVkm)xJ^#d{H{ zlUAojx(+=XryR$_LaV)V6~Q+50>X&QT(jhq^H`q@d4}ic%Ui}kXo8pvw~Jd0U^L>H zU=k~=)K;r4xaWH3dABJsQ(P}Z2Mc{baet0Ik3=d~9H%6%%8X z9z}1(?6=FoIA8Uk&fCXZX9Z(TIF6NOLr+ajbx7839XeCRGMXhevLi}z5-!#xGn?yd zABNI!9q$dMKETdg%%*%sZ)$r;y*`Mr5JYJCUf)vCa~?5+%z<$-C$3Dsc?@5*oQum* zTl)1*#QH5gEIBztOqbhp z6HZ$!xG6G33X!ISvuQYbiqEe#knyL{dJ8H%rU*F4N?hZ@(Z_?LsZ&wqT!N2*EK48l zUf^z9^ZhrDj^~q2X?~C;4=@V7oWlZt%AV(rLo_cB>kK~ODwmneejS17L%hVD1`6ch zi=yC*S~WM0YI!V+-JM-x5BuU?bG_p)hlpmEt7ZR{f19ddmWepZO4|%ceu_hK^O07I zLh)<1$F)-1SBvBBH{uV*KHd-3yrMFV2K^*EtmhjuBfWguI21JoXBD@6 zW*X|nlr%zrBUZUmf6+J3sC)Zty3*-4(Eol0&$Pb zb)BetqRdc~+*M?+hK&Kp^L^FE2F0L^1`zVhVcV@8MI(iU)S>mvy=;Oe)$l(uFXYpZ zu)SI^DJ^HgR|kbM2IztrB7}*ZgkwILP1lARfw!uYGmTBfz87^KzJQAQmKJX>w5sC9cu(3`SQf(n&jEaKWDS!u5u!mZ^PUe23To-=6q5&&_ zZn&Lw1Bc&XjGl7;@Wi+ig$|t2CG4KOKvKQ#GOY-D&08|9)DzyMAlgfZtTsMtw+=L( zG^-=TSMY=Pl@`6G%RmfnpUB(2f5p!OTBU$u$MIf5;XrZRsox~jmX3FS{X{@FpesME zrcOffpeULwS!H5Ju4S)X2kVe1Oc{~Nw4$KwW3Dq=WO%$n+?51)2{|WtuHOx$Xh3{y z{2kQ@o1u)MOKpQlu5%W&V0siUOc#)lu&wgt3Hbg;M5w% zJx1M8y6xK4{j@uXj|E=QkGOpS(n4Dvo7yL@3uF@!Do4{IYj^&*Nho*1l^DcLfPUyt zU0EM5sZkMp8zNpzxtBu55lt$qiG@<$gtv%P+UV8C(R3UDt3!q%Wr2v!uO2I9;g~;2 zW(Qb&P0(%@@{wWlo5V z8q=WO5W<~ruFC2RJc?s3RC_m4mzg42F26v*1>`)3iXArxU6waPd!8&rC_!~#~(HYyivRqR)tncAAwh%QmFdK^>+rk^bY8&rmPw*cZez}&M&RIOr z@7o!BQU1xbM16NWWkpp4=_KXE7-R+IB*jFPRp@2KzQ&Bh2M{6#Uhso6RBOy;Hs2fP zCjDGTQsfXMtnTnV2A)0Q zo+lyrnbEPva>l^QD}WTXejX~if8HtxwA8w$9mYRrH;-JwRuUlcWNgbV>nyui4yb6{4B$Ssua!A0_@Ie#INk;jxbLi_yNpH}|4< zHe&vgiN^~0>y~-?_a6VWW&VHdqW|^I0Xi2)YbTRoMd&Ytus~BNHdYJjZbz_0>?4d6 zv)sOjV1m8~8w*+`Bmhapf!NUd6?~AVs}ns@tBxh8Lxm|eYfir z(k3J1Q^DQr{uRYb$sFrbekaD`{rJ=6|2w(=sUG96$ixZsUr!b9$UyIL z!hf~@`w)!p*Z-epgx=oK&fdh)*}}w0dSsG;ik?b}c4}01Y|Lpwl9s+vc7lP9dP0V7 zMtWj+&MDaOUnHca21${<4?y*PC`bc?paT8*CWGHM+x`mo|F!)SNq@Z8;O~IH@2>eP zpxb+>^q&C#*s=R}z~6V3{1tE!?wn9e4EWb7yT9Z9UM=)jLN9Ut8TXGGw7&!XUMKTwQUBSL@c$X`|59@F_W^#ddiX2F zB?SLGz#qjoe+T?MPxV(oUgCcS{G)W@?|{F@?f(k6O8L)#eE8xZZBKRkX{3Dj}cfjA3{4bmJXOrUpKU=Wh z5q@dc-}UY "bin/sbt-launch.jar", rtExportJar -> "bin/java9-rt-export.jar") }, mappings in Universal ++= (Def.taskDyn { - if (sbtOfflineInstall) + if (sbtOfflineInstall && sbtVersionToRelease.startsWith("1.")) + Def.task { + val _ = (exportRepoUsingCoursier in dist).value + directory((target in dist).value / "lib") + } + else if (sbtOfflineInstall) Def.task { val _ = (exportRepo in dist).value directory((target in dist).value / "lib") @@ -330,15 +339,7 @@ lazy val dist = (project in file("dist")) val old = exportRepo.value sbtVersionToRelease match { case v if v.startsWith("1.") => - val zincBase = exportRepoDirectory.value / "org.scala-sbt" / "zinc_2.12" - val zincVersion = (zincBase * DirectoryFilter).get.head.getName - val utilBase = exportRepoDirectory.value / "org.scala-sbt" / "util-logging_2.12" - val utilVersion = (utilBase * DirectoryFilter).get.head.getName - val outbase = exportRepoDirectory.value / "org" / "scala-sbt" / "compiler-interface" / zincVersion - val uribase = s"https://oss.sonatype.org/content/repositories/public/org/scala-sbt/compiler-interface/$zincVersion/" - downloadUrl(uri(uribase + s"compiler-interface-${zincVersion}.jar"), outbase / s"compiler-interface-${zincVersion}.jar") - downloadUrl(uri(uribase + s"compiler-interface-${zincVersion}-sources.jar"), outbase / s"compiler-interface-${zincVersion}-sources.jar") - downloadUrl(uri(uribase + s"compiler-interface-${zincVersion}.pom"), outbase / s"compiler-interface-${zincVersion}.pom") + sys.error("sbt 1.x should use coursier") case v if v.startsWith("0.13.") => val outbase = exportRepoDirectory.value / "org.scala-sbt" / "compiler-interface" / v val uribase = s"https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compiler-interface/$v/" @@ -350,6 +351,31 @@ lazy val dist = (project in file("dist")) old }, exportRepoDirectory := target.value / "lib" / "local-preloaded", + exportRepoCsrDirectory := exportRepoDirectory.value, + exportRepoUsingCoursier := { + val outDirectory = exportRepoCsrDirectory.value + val csr = + if (isWindows) (baseDirectory in LocalRootProject).value / "bin" / "coursier.bat" + else (baseDirectory in LocalRootProject).value / "bin" / "coursier" + val cache = target.value / "coursier" + IO.delete(cache) + val v = sbtVersionToRelease + s"$csr fetch --cache $cache org.scala-sbt:sbt:$v".! + val mavenCache = cache / "https" / "repo1.maven.org" / "maven2" + val compilerBridgeVer = IO.listFiles(mavenCache / "org" / "scala-sbt" / "compiler-bridge_2.12", DirectoryFilter).toList.headOption + compilerBridgeVer match { + case Some(bridgeDir) => + val bridgeVer = bridgeDir.getName + s"$csr fetch --cache $cache --sources org.scala-sbt:compiler-bridge_2.10:$bridgeVer".! + s"$csr fetch --cache $cache --sources org.scala-sbt:compiler-bridge_2.11:$bridgeVer".! + s"$csr fetch --cache $cache --sources org.scala-sbt:compiler-bridge_2.12:$bridgeVer".! + s"$csr fetch --cache $cache --sources org.scala-sbt:compiler-bridge_2.13:$bridgeVer".! + case _ => + sys.error("bridge not found") + } + IO.copyDirectory(mavenCache, outDirectory, true, true) + outDirectory + }, conflictWarning := ConflictWarning.disable, publish := (), publishLocal := (), diff --git a/citest/build.sbt b/citest/build.sbt index 3ff4eae20..77123e433 100644 --- a/citest/build.sbt +++ b/citest/build.sbt @@ -10,11 +10,10 @@ lazy val root = (project in file(".")) println(xs) assert(xs(0) startsWith "[info] Loading project definition") - assert(xs(1) startsWith "[info] Loading settings from build.sbt") + assert(xs(1) startsWith "[info] Loading settings") assert(xs(2) startsWith "[info] Set current project to Hello") assert(xs(3) startsWith "[info] This is sbt") assert(xs(4) startsWith "[info] The current project") - assert(xs(5) startsWith "[info] The current project is built against Scala 2.12.4") val ys = IO.readLines(file("err.txt")).toVector.distinct diff --git a/citest/project/build.properties b/citest/project/build.properties index 31334bbd3..c491602bb 100644 --- a/citest/project/build.properties +++ b/citest/project/build.properties @@ -1 +1 @@ -sbt.version=1.1.1 +sbt.version=1.3.0-M4 diff --git a/citest/test.bat b/citest/test.bat index 9234e6201..6dc88bae4 100644 --- a/citest/test.bat +++ b/citest/test.bat @@ -13,6 +13,6 @@ SET JAVA_HOME=C:\jdk11 SET PATH=C:\jdk11\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 -"freshly-baked\sbt\bin\sbt" about +"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" about ENDLOCAL diff --git a/citest/test.sh b/citest/test.sh index 53c9c6db6..c25555881 100755 --- a/citest/test.sh +++ b/citest/test.sh @@ -23,14 +23,14 @@ fail() { } env HOME=./target/home1 ./freshly-baked/sbt/bin/sbt about -test -d ./target/home1/.sbt/preloaded/org.scala-sbt || fail "expected to find preloaded in ./target/home1/.sbt" +test -d ./target/home1/.sbt/preloaded/org/scala-sbt || fail "expected to find preloaded in ./target/home1/.sbt" env HOME=./target/home2 ./freshly-baked/sbt/bin/sbt -sbt-dir ./target/home2/alternate-sbt about -test -d ./target/home2/alternate-sbt/preloaded/org.scala-sbt || fail "expected to find preloaded in ./target/home2/alternate-sbt" +test -d ./target/home2/alternate-sbt/preloaded/org/scala-sbt || fail "expected to find preloaded in ./target/home2/alternate-sbt" env HOME=./target/home3 ./freshly-baked/sbt/bin/sbt -J-Dsbt.preloaded=./target/home3/alternate-preloaded about -test -d ./target/home3/alternate-preloaded/org.scala-sbt || fail "expected to find preloaded in ./target/home3/alternate-preloaded" +test -d ./target/home3/alternate-preloaded/org/scala-sbt || fail "expected to find preloaded in ./target/home3/alternate-preloaded" env HOME=./target/home4 ./freshly-baked/sbt/bin/sbt -J-Dsbt.global.base=./target/home4/global-base about -test -d ./target/home4/global-base/preloaded/org.scala-sbt || fail "expected to find preloaded in ./target/home4/global-base" +test -d ./target/home4/global-base/preloaded/org/scala-sbt || fail "expected to find preloaded in ./target/home4/global-base" diff --git a/citest/test1.bat b/citest/test1.bat index 4036c2593..9ac5f2b1c 100644 --- a/citest/test1.bat +++ b/citest/test1.bat @@ -6,6 +6,6 @@ SET JAVA_HOME=C:\jdk11 SET PATH=C:\jdk11\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 -"freshly-baked\sbt\bin\sbt" about 1> output.txt 2> err.txt +"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" about 1> output.txt 2> err.txt ENDLOCAL diff --git a/citest/test2.bat b/citest/test2.bat index 2c42c7288..ebd74afe8 100644 --- a/citest/test2.bat +++ b/citest/test2.bat @@ -6,6 +6,6 @@ SET JAVA_HOME=C:\jdk11 SET PATH=C:\jdk11\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 -"freshly-baked\sbt\bin\sbt" check +"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" check ENDLOCAL diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 7447bb89b..1a4e02524 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -264,7 +264,7 @@ syncPreloaded() { local target_preloaded="$(getPreloaded)" if [[ "$init_sbt_version" == "" ]]; then # FIXME: better $init_sbt_version detection - init_sbt_version="$(ls -1 "$source_preloaded/org.scala-sbt/sbt/")" + init_sbt_version="$(ls -1 "$source_preloaded/org/scala-sbt/sbt/")" fi [[ -f "$target_preloaded/org.scala-sbt/sbt/$init_sbt_version/jars/sbt.jar" ]] || { # lib/local-preloaded exists (This is optional) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index f909ec0fb..b67083271 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -190,11 +190,11 @@ exit /B 0 :sync_preloaded if "%INIT_SBT_VERSION%"=="" ( rem FIXME: better %INIT_SBT_VERSION% detection - FOR /F "tokens=* USEBACKQ" %%F IN (`dir /b "%SBT_HOME%\..\lib\local-preloaded\org.scala-sbt\sbt" /B`) DO ( + FOR /F "tokens=* USEBACKQ" %%F IN (`dir /b "%SBT_HOME%\..\lib\local-preloaded\org\scala-sbt\sbt" /B`) DO ( SET INIT_SBT_VERSION=%%F ) ) -set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org.scala-sbt\sbt\%INIT_SBT_VERSION%\jars\sbt.jar" +set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org\scala-sbt\sbt\%INIT_SBT_VERSION%\" if /I %JAVA_VERSION% GEQ 8 ( where robocopy >nul 2>nul if %ERRORLEVEL% equ 0 ( From 05ea7eedc55dcf306895ace924e1c8e2b621187d Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 22 May 2019 17:22:03 -0400 Subject: [PATCH 358/483] whitespace fix --- src/universal/conf/sbtopts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/universal/conf/sbtopts b/src/universal/conf/sbtopts index f018465af..c6f4e7bec 100644 --- a/src/universal/conf/sbtopts +++ b/src/universal/conf/sbtopts @@ -17,7 +17,7 @@ # Path to shared boot directory (default: ~/.sbt/boot in 0.11 series) # -#-sbt-boot ~/.sbt/boot +#-sbt-boot ~/.sbt/boot # Path to local Ivy repository (default: ~/.ivy2) # @@ -25,7 +25,7 @@ # set memory options # -#-mem +#-mem # Use local caches for projects, no sharing. # @@ -40,7 +40,7 @@ # Scala version (default: latest release) # -#-scala-home +#-scala-home #-scala-version # java version (default: java from PATH, currently $(java -version |& grep version)) From e39a13904251e6535e3dc8905dd2b1cc11044506 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 22 May 2019 17:32:13 -0400 Subject: [PATCH 359/483] Remove -XX:MaxPermSize out of Windows default Fixes #223 --- .appveyor.yml | 2 +- citest/test.sh | 2 +- src/universal/conf/sbtconfig.txt | 16 +++++++--------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index f0c903f69..b7a0e4f2b 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -19,7 +19,7 @@ install: [System.IO.Compression.ZipFile]::ExtractToDirectory("C:\sbt-bin.zip", "C:\sbt") } - SET PATH=C:\sbt\sbt\bin;%PATH% - - SET SBT_OPTS=-XX:MaxPermSize=2g -Xmx4g -Dfile.encoding=UTF8 + - SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 test_script: - sbt "-Dsbt.build.version=1.3.0-M4" universal:packageBin diff --git a/citest/test.sh b/citest/test.sh index c25555881..1eda5675b 100755 --- a/citest/test.sh +++ b/citest/test.sh @@ -13,7 +13,7 @@ export SBT_OPTS=-Dfile.encoding=UTF-8 ./freshly-baked/sbt/bin/sbt about run -v -export SBT_OPTS="-Dfile.encoding=UTF-8 -Xms2048M -Xmx2048M -Xss2M -XX:MaxPermSize=512M" +export SBT_OPTS="-Dfile.encoding=UTF-8 -Xms2048M -Xmx2048M -Xss2M" ./freshly-baked/sbt/bin/sbt about run diff --git a/src/universal/conf/sbtconfig.txt b/src/universal/conf/sbtconfig.txt index a4da43eaf..437b5a21d 100644 --- a/src/universal/conf/sbtconfig.txt +++ b/src/universal/conf/sbtconfig.txt @@ -1,14 +1,12 @@ -# Set the java args to high +# sbt configuration file for Windows --Xmx512M - --XX:MaxPermSize=256m +# Set the java args +-Xms1024m +-Xmx1024m +-Xss2M -XX:ReservedCodeCacheSize=128m +# Set the extra sbt options - -# Set the extra SBT options - --Dsbt.log.format=true - +# -Dsbt.log.format=true From 8a3a7c2b7d6e757f4b459bedbf451db45890cc0d Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 22 May 2019 23:36:52 -0400 Subject: [PATCH 360/483] Remove MaxMetaspaceSize Ref https://github.com/sbt/sbt/issues/4686 --- README.md | 2 +- src/universal/bin/sbt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 85df53a36..e1593c771 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Usage: sbt [options] -sbt-dir path to global settings/plugins directory (default: ~/.sbt) -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) -ivy path to local Ivy repository (default: ~/.ivy2) - -mem set memory options (default: 1024, which is -Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m -XX:MaxMetaspaceSize=256m) + -mem set memory options (default: 1024, which is -Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m) -no-share use all local caches; no sharing -no-global uses global caches, but does not use global ~/.sbt directory. -jvm-debug Turn on JVM debugging, open at the given port. diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 1a4e02524..d9c2efc79 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -144,13 +144,13 @@ addMemory () { if [[ -z $java_version ]]; then java_version=$(jdk_version) fi - local class_metadata_opt=$((( $java_version < 8 )) && echo "MaxPermSize" || echo "MaxMetaspaceSize") + local class_metadata_opt="MaxPermSize" addJava "-Xms${mem}m" addJava "-Xmx${mem}m" addJava "-Xss2M" addJava "-XX:ReservedCodeCacheSize=${codecache}m" - if [[ (( $java_version > 7 )) ]]; then + if [[ (( $java_version < 8 )) ]]; then addJava "-XX:${class_metadata_opt}=${class_metadata_size}m" fi } From bd32204c21be787c70a0b2c0f5e1a1d313a856a1 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 22 May 2019 23:38:50 -0400 Subject: [PATCH 361/483] Bump stack size Ref https://github.com/scala/bug/issues/10870 --- citest/test.sh | 2 +- src/universal/bin/sbt | 2 +- src/universal/conf/sbtconfig.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/citest/test.sh b/citest/test.sh index 1eda5675b..499669739 100755 --- a/citest/test.sh +++ b/citest/test.sh @@ -13,7 +13,7 @@ export SBT_OPTS=-Dfile.encoding=UTF-8 ./freshly-baked/sbt/bin/sbt about run -v -export SBT_OPTS="-Dfile.encoding=UTF-8 -Xms2048M -Xmx2048M -Xss2M" +export SBT_OPTS="-Dfile.encoding=UTF-8 -Xms2048M -Xmx2048M -Xss4M" ./freshly-baked/sbt/bin/sbt about run diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index d9c2efc79..0dab765dc 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -148,7 +148,7 @@ addMemory () { addJava "-Xms${mem}m" addJava "-Xmx${mem}m" - addJava "-Xss2M" + addJava "-Xss4M" addJava "-XX:ReservedCodeCacheSize=${codecache}m" if [[ (( $java_version < 8 )) ]]; then addJava "-XX:${class_metadata_opt}=${class_metadata_size}m" diff --git a/src/universal/conf/sbtconfig.txt b/src/universal/conf/sbtconfig.txt index 437b5a21d..50395e227 100644 --- a/src/universal/conf/sbtconfig.txt +++ b/src/universal/conf/sbtconfig.txt @@ -4,7 +4,7 @@ -Xms1024m -Xmx1024m --Xss2M +-Xss4M -XX:ReservedCodeCacheSize=128m # Set the extra sbt options From 8015e9f1a9d1a09bca3bb05fc5a3ec6e842565ea Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 22 May 2019 23:40:10 -0400 Subject: [PATCH 362/483] Remove reference to get_mem_opts --- src/universal/bin/sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 0dab765dc..79d92cc95 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -401,7 +401,7 @@ Usage: `basename "$0"` [options] --sbt-dir path to global settings/plugins directory (default: ~/.sbt) --sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11 series) --ivy path to local Ivy repository (default: ~/.ivy2) - --mem set memory options (default: $sbt_default_mem, which is $(get_mem_opts)) + --mem set memory options (default: $sbt_default_mem) --no-share use all local caches; no sharing --no-global uses global caches, but does not use global ~/.sbt directory. --jvm-debug Turn on JVM debugging, open at the given port. From f94dc1a9ed07315107686d5eed1eb6dfbc746423 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 23 May 2019 12:42:19 -0400 Subject: [PATCH 363/483] no more warnings --- citest/build.sbt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/citest/build.sbt b/citest/build.sbt index 77123e433..d860bffb1 100644 --- a/citest/build.sbt +++ b/citest/build.sbt @@ -17,7 +17,6 @@ lazy val root = (project in file(".")) val ys = IO.readLines(file("err.txt")).toVector.distinct - assert(ys.size == 1, s"ys has more than one item: $ys") - assert(ys(0) startsWith "Java HotSpot(TM) 64-Bit Server VM warning") + assert(ys.isEmpty, s"there's an stderr: $ys") } ) From 79e13bb39c7bbcbfe92e0a3f9c61dd6251a7b760 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 29 May 2019 17:02:02 -0400 Subject: [PATCH 364/483] Reinstate realpath Fixes #269 Ref #149 There were two implementations of `realpath`-like things the scripts. One in `sbt` called `realpath` contributed in #27, and another using ls in sbt-launch-lib.bash that I added in #155 because at some point I got confused by the fact macOS doesn't have [realpath(1)](https://linux.die.net/man/1/realpath). In #257 `sbt` and `sbt-launcher-lib.bash` were merged and the emulated `realpath` was removed. dcsobral noticed this and raised #269. This commit reinstates the emulated `realpath` as `realpathish` to avoid the future confusion, and removes the inferior version that uses `ls`. Co-authored-by: Bart Schuller Co-authored-by: Eugene Yokota --- src/universal/bin/sbt | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 79d92cc95..3c9414d63 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -17,6 +17,33 @@ declare -r default_java_opts="-Dfile.encoding=UTF-8" ### Helper methods for BASH scripts ### ### ------------------------------- ### +# Bash reimplementation of realpath to return the absolute path +realpathish () { +( + TARGET_FILE="$1" + FIX_CYGPATH="$2" + + cd "$(dirname "$TARGET_FILE")" + TARGET_FILE=$(basename "$TARGET_FILE") + + COUNT=0 + while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ] + do + TARGET_FILE=$(readlink "$TARGET_FILE") + cd "$(dirname "$TARGET_FILE")" + TARGET_FILE=$(basename "$TARGET_FILE") + COUNT=$(($COUNT + 1)) + done + + # make sure we grab the actual windows path, instead of cygwin's path. + if [[ "x$FIX_CYGPATH" != "x" ]]; then + echo "$(cygwinpath "$(pwd -P)/$TARGET_FILE")" + else + echo "$(pwd -P)/$TARGET_FILE" + fi +) +} + # Uses uname to detect if we're in the odd cygwin environment. is_cygwin() { local os=$(uname -s) @@ -43,18 +70,7 @@ cygwinpath() { } -declare SCRIPT=$0 -while [ -h "$SCRIPT" ] ; do - ls=$(ls -ld "$SCRIPT") - # Drop everything prior to -> - link=$(expr "$ls" : '.*-> \(.*\)$') - if expr "$link" : '/.*' > /dev/null; then - SCRIPT="$link" - else - SCRIPT=$(dirname "$SCRIPT")/"$link" - fi -done -declare -r sbt_bin_dir="$(dirname "$SCRIPT")" +declare -r sbt_bin_dir="$(dirname "$(realpathish "$0")")" declare -r sbt_home="$(dirname "$sbt_bin_dir")" echoerr () { From 53f847d7039c086ef34c829fd843cb76ad4abf70 Mon Sep 17 00:00:00 2001 From: Christian Lachner Date: Sun, 30 Jun 2019 11:19:18 +0200 Subject: [PATCH 365/483] Fix JVM_DEBUG in sbt.bat JVM_DEBUG was broken due to a copy-pasta error in sbt.bat. This commit corrects the value assignment to the variable and therefore fixes the problem. --- src/universal/bin/sbt.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index b67083271..78cbe17a2 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -64,8 +64,8 @@ set INIT_SBT_VERSION=_TO_BE_REPLACED :args_loop if "%~1" == "" goto args_end -if "%~1" == "-jvm-debug" set set JVM_DEBUG=true -if "%~1" == "--jvm-debug" set set JVM_DEBUG=true +if "%~1" == "-jvm-debug" set JVM_DEBUG=true +if "%~1" == "--jvm-debug" set JVM_DEBUG=true if "%JVM_DEBUG%" == "true" ( set /a JVM_DEBUG_PORT=5005 2>nul >nul From 4a61c27538affbac3828c2eac7bd24bdc2b3a10b Mon Sep 17 00:00:00 2001 From: Christian Lachner Date: Sun, 30 Jun 2019 14:14:57 +0200 Subject: [PATCH 366/483] Add --java-home to sbt.bat In contrast to the unix version of the sbt launcher, the windows version lacks the functionality of specifying JAVA_HOME via launch parameters. This commit adds the missing --java-home parameter to sbt.bat. --- src/universal/bin/sbt.bat | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 78cbe17a2..ac5d33212 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -67,6 +67,9 @@ if "%~1" == "" goto args_end if "%~1" == "-jvm-debug" set JVM_DEBUG=true if "%~1" == "--jvm-debug" set JVM_DEBUG=true +if "%~1" == "-java-home" set SET_JAVA_HOME=true +if "%~1" == "--java-home" set SET_JAVA_HOME=true + if "%JVM_DEBUG%" == "true" ( set /a JVM_DEBUG_PORT=5005 2>nul >nul ) else if "!JVM_DEBUG!" == "true" ( @@ -81,6 +84,24 @@ if "%JVM_DEBUG%" == "true" ( set SBT_ARGS=!SBT_ARGS! %1 ) +if "%SET_JAVA_HOME%" == "true" ( + set SET_JAVA_HOME= + if NOT "%~2" == "" ( + if exist "%~2\bin\java.exe" ( + set _JAVACMD="%~2\bin\java.exe" + set JAVA_HOME="%~2" + set JDK_HOME="%~2" + shift + ) else ( + echo Directory "%~2" for JAVA_HOME is not valid + goto error + ) + ) else ( + echo Second argument for --java-home missing + goto error + ) +) + shift goto args_loop :args_end From 3cd702af9f20d55de755382f6481e9214a267ee7 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 15 Jul 2019 19:23:58 -0400 Subject: [PATCH 367/483] Windows --- .travis.yml | 76 +++++++++++-------- citest/test.bat | 4 + citest/test1.bat | 11 --- citest/test2.bat | 11 --- .../src/test/scala/RunnerTest.scala | 5 +- 5 files changed, 53 insertions(+), 54 deletions(-) delete mode 100644 citest/test1.bat delete mode 100644 citest/test2.bat diff --git a/.travis.yml b/.travis.yml index 7f51ec42d..a2d12b760 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,42 +1,61 @@ sudo: false -dist: trusty +dist: xenial group: stable language: scala +scala: 2.10.7 env: global: - - SBT_VER=1.3.0-M4 + - SBT_VER=1.3.0-M4 + - TRAVIS_JDK=adopt@1.8.212-04 + - JABBA_HOME=$HOME/.jabba + - TRAVIS_JDK11=openjdk@1.11.0 matrix: include: + - os: windows + language: bash + before_install: + - "PowerShell -ExecutionPolicy Bypass -Command '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-Expression (Invoke-WebRequest https://raw.githubusercontent.com/shyiko/jabba/0.11.2/install.ps1 -UseBasicParsing).Content'" + install: + - $JABBA_HOME/bin/jabba.exe install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" + - java -Xmx32m -version + - curl https://piccolo.link/sbt-1.2.8.zip -L --output /tmp/sbt.zip + - unzip /tmp/sbt.zip -d $HOME/sbt + - export PATH="$HOME/sbt/sbt/bin:$PATH" + script: + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin + - cd citest + - "./test.bat" + - "test3/test3.bat" + + ## build using JDK 8, test using JDK 8, on macOS + - os: osx + osx_image: xcode9.2 + language: java + before_install: + - curl -sL https://raw.githubusercontent.com/shyiko/jabba/0.11.2/install.sh | bash && . ~/.jabba/jabba.sh + - brew update + - brew install sbt + install: + - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK/Contents/Home" && export PATH="$JAVA_HOME/bin:$PATH" + - java -Xmx32m -version + script: + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin + - cd citest && ./test.sh + ## build using JDK 8, test using JDK 8 - script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - cd citest && ./test.sh - jdk: oraclejdk8 - - ## build using JDK 8, test using JDK 8, on macOS - - script: - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin - - cd citest && ./test.sh - ## https://github.com/travis-ci/travis-ci/issues/2316 - language: java - os: osx - osx_image: xcode9.2 ## build using JDK 8, test using OpenJDK 11 - - env: - - TRAVIS_JDK=openjdk@1.11.0 - - JABBA_HOME=/home/travis/.jabba - before_install: - - unset _JAVA_OPTIONS - - curl -sL https://raw.githubusercontent.com/shyiko/jabba/0.10.1/install.sh | bash && . ~/.jabba/jabba.sh - script: + - script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" && java -Xmx32m -version + - $JABBA_HOME/bin/jabba install $TRAVIS_JDK11 && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK11" && export PATH="$JAVA_HOME/bin:$PATH" + - java -Xmx32m -version - cd citest && ./test.sh - jdk: oraclejdk8 - script: - sbt -Dsbt.build.version=$SBT_VER rpm:packageBin debian:packageBin @@ -45,18 +64,13 @@ matrix: packages: - fakeroot - rpm - jdk: oraclejdk8 - -scala: - - 2.10.7 before_install: - # https://github.com/travis-ci/travis-ci/issues/8408 - - unset _JAVA_OPTIONS - - if [[ "$TRAVIS_OS_NAME" = "osx" ]]; then - brew update; - brew install sbt; - fi + - curl -sL https://raw.githubusercontent.com/shyiko/jabba/0.10.1/install.sh | bash && . ~/.jabba/jabba.sh + +install: + - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" + - java -Xmx32m -version cache: directories: diff --git a/citest/test.bat b/citest/test.bat index 6dc88bae4..e0f2cab41 100644 --- a/citest/test.bat +++ b/citest/test.bat @@ -15,4 +15,8 @@ SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 "freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" about +"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" about 1> output.txt 2> err.txt + +"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" check + ENDLOCAL diff --git a/citest/test1.bat b/citest/test1.bat deleted file mode 100644 index 9ac5f2b1c..000000000 --- a/citest/test1.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo on - -SETLOCAL - -SET JAVA_HOME=C:\jdk11 -SET PATH=C:\jdk11\bin;%PATH% -SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 - -"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" about 1> output.txt 2> err.txt - -ENDLOCAL diff --git a/citest/test2.bat b/citest/test2.bat deleted file mode 100644 index ebd74afe8..000000000 --- a/citest/test2.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo on - -SETLOCAL - -SET JAVA_HOME=C:\jdk11 -SET PATH=C:\jdk11\bin;%PATH% -SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 - -"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" check - -ENDLOCAL diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 489edb899..708ab13e1 100644 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -5,7 +5,10 @@ import scala.sys.process._ import java.io.File object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { - lazy val sbtScript = new File("target/universal/stage/bin/sbt") + lazy val isWindows: Boolean = sys.props("os.name").toLowerCase(java.util.Locale.ENGLISH).contains("windows") + lazy val sbtScript = + if (isWindows) new File("target/universal/stage/bin/sbt.bat") + else new File("target/universal/stage/bin/sbt") def sbtProcess(arg: String) = sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest"), "JAVA_OPTS" -> "", From 16f5b638df1fd7f8620ea8422a85e4587703229d Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 18 Jul 2019 16:23:14 +0900 Subject: [PATCH 368/483] Add -V|-version to print sbtVersion. --- README.md | 1 + src/linux/usr/share/man/man1/sbt.1 | 2 ++ src/universal/bin/sbt | 2 ++ 3 files changed, 5 insertions(+) diff --git a/README.md b/README.md index e1593c771..2bb597383 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Usage: sbt [options] -h | -help print this message -v | -verbose this runner is chattier + -V | -version print the version of mothership sbt -d | -debug set sbt log level to debug -no-colors disable ANSI color codes -sbt-create start sbt even if current directory contains no sbt project diff --git a/src/linux/usr/share/man/man1/sbt.1 b/src/linux/usr/share/man/man1/sbt.1 index 6dc5d7211..04e9dfa29 100644 --- a/src/linux/usr/share/man/man1/sbt.1 +++ b/src/linux/usr/share/man/man1/sbt.1 @@ -20,6 +20,8 @@ The current directory is assumed to be the project. Show help options. .IP "-v, -verbose" turn up the noise +.IP "-V, -version" +print the version of mothership sbt .IP "-d, -debug" set sbt log level to debug .IP -no-colors diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 3c9414d63..4670a899f 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -405,6 +405,7 @@ Usage: `basename "$0"` [options] -h | --help print this message -v | --verbose this runner is chattier + -V | --version print the version of mothership sbt -d | --debug set sbt log level to debug --no-colors disable ANSI color codes --color=auto|always|true|false|never @@ -512,6 +513,7 @@ process_args () { case "$1" in -h|-help) usage; exit 1 ;; -v|-verbose) verbose=1 && shift ;; + -V|-version) addSbt "sbtVersion" && shift ;; -d|-debug) debug=1 && addSbt "-debug" && shift ;; -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; From 88976ad23f33a3807541280d842267fe5a42bcec Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 18 Jul 2019 16:47:22 +0900 Subject: [PATCH 369/483] Print only the last line containig sbt version --- src/universal/bin/sbt | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 4670a899f..954c25c9f 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -6,6 +6,7 @@ declare -a java_args declare -a scalac_args declare -a sbt_commands declare -a sbt_options +declare -a print_sbt_version declare java_cmd=java declare java_version declare init_sbt_version=_to_be_replaced @@ -375,14 +376,19 @@ run() { addJava "-Dsbt.cygwin=true" fi - # run sbt - execRunner "$java_cmd" \ - $(get_gc_opts) \ - ${java_args[@]} \ - ${sbt_options[@]} \ - -jar "$sbt_jar" \ - "${sbt_commands[@]}" \ - "${residual_args[@]}" + if [[ $print_sbt_version ]]; then + # print sbtVersion + execRunner "$java_cmd" -jar "$sbt_jar" "sbtVersion" | tail -1 + else + # run sbt + execRunner "$java_cmd" \ + $(get_gc_opts) \ + ${java_args[@]} \ + ${sbt_options[@]} \ + -jar "$sbt_jar" \ + "${sbt_commands[@]}" \ + "${residual_args[@]}" + fi exit_code=$? @@ -442,7 +448,7 @@ Usage: `basename "$0"` [options] are prepended to the runner args /etc/sbt/sbtopts if this file exists, it is prepended to the runner args -Dkey=val pass -Dkey=val directly to the java runtime - -J-X pass option -X directly to the java runtime + -J-X pass option -X directly to the java runtime (-J is stripped) -S-X add -X to sbt's scalacOptions (-S is stripped) @@ -465,7 +471,7 @@ process_my_args () { done # Now, ensure sbt version is used. - [[ "${sbt_version}XXX" != "XXX" ]] && addJava "-Dsbt.version=$sbt_version" + [[ "${sbt_version}XXX" != "XXX" ]] && addJava "-Dsbt.version=$sbt_version" # Confirm a user's intent if the current directory does not look like an sbt # top-level directory and neither the -sbt-create option nor the "new" @@ -513,7 +519,7 @@ process_args () { case "$1" in -h|-help) usage; exit 1 ;; -v|-verbose) verbose=1 && shift ;; - -V|-version) addSbt "sbtVersion" && shift ;; + -V|-version) print_sbt_version=1 && shift ;; -d|-debug) debug=1 && addSbt "-debug" && shift ;; -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; From c57c950e92a9ccf74cb16717a41aeced20920b41 Mon Sep 17 00:00:00 2001 From: exoego Date: Fri, 19 Jul 2019 08:32:41 +0900 Subject: [PATCH 370/483] Improve message since sbtVersion may vary for different projects --- integration-test/src/test/scala/RunnerTest.scala | 10 ++++++++++ src/universal/bin/sbt | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 708ab13e1..30cca6b5e 100644 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -79,4 +79,14 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } + test("sbt -V|-version should print sbtVersion") { + val out = sbtProcessWithOpts("-version", "", "").!!.trim + val expectedVersion = "^sbt version in this project: \\d\\.\\d+\\.\\d+\\S*$" + assert(out.matches(expectedVersion)) + + val out2 = sbtProcessWithOpts("-V", "", "").!!.trim + assert(out2.matches(expectedVersion)) + () + } + } diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 954c25c9f..a630386ee 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -378,7 +378,7 @@ run() { if [[ $print_sbt_version ]]; then # print sbtVersion - execRunner "$java_cmd" -jar "$sbt_jar" "sbtVersion" | tail -1 + execRunner "$java_cmd" -jar "$sbt_jar" "sbtVersion" | tail -1 | sed -e 's/\[info\]/sbt version in this project:/g' else # run sbt execRunner "$java_cmd" \ From 796e5d6ef859f10c88bd17868f4730efaf5f71c9 Mon Sep 17 00:00:00 2001 From: Dale Wijnand <344610+dwijnand@users.noreply.github.com> Date: Sat, 3 Aug 2019 08:31:38 +0100 Subject: [PATCH 371/483] Update issue templates --- .github/ISSUE_TEMPLATE/no-new-issues.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/no-new-issues.md diff --git a/.github/ISSUE_TEMPLATE/no-new-issues.md b/.github/ISSUE_TEMPLATE/no-new-issues.md new file mode 100644 index 000000000..7d656f8a4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/no-new-issues.md @@ -0,0 +1,12 @@ +--- +name: No new issues +about: No new issues +title: '' +labels: '' +assignees: '' + +--- + +No new issues should be opened against this repo. + +Please use https://github.com/sbt/sbt/issues/new/choose to file an issue against sbt. From 458ddd0e94862af6d8cca67d7f934062a78d034c Mon Sep 17 00:00:00 2001 From: Dale Wijnand <344610+dwijnand@users.noreply.github.com> Date: Sat, 3 Aug 2019 08:32:45 +0100 Subject: [PATCH 372/483] Update no-new-issues.md --- .github/ISSUE_TEMPLATE/no-new-issues.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/no-new-issues.md b/.github/ISSUE_TEMPLATE/no-new-issues.md index 7d656f8a4..77583949a 100644 --- a/.github/ISSUE_TEMPLATE/no-new-issues.md +++ b/.github/ISSUE_TEMPLATE/no-new-issues.md @@ -1,9 +1,6 @@ --- name: No new issues -about: No new issues -title: '' -labels: '' -assignees: '' +about: Use use https://github.com/sbt/sbt/issues/new/choose instead --- From 030b6e828367934b540594424b86ff8146546bd3 Mon Sep 17 00:00:00 2001 From: Dale Wijnand <344610+dwijnand@users.noreply.github.com> Date: Sat, 3 Aug 2019 08:33:10 +0100 Subject: [PATCH 373/483] Fix typo in no-new-issues.md --- .github/ISSUE_TEMPLATE/no-new-issues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/no-new-issues.md b/.github/ISSUE_TEMPLATE/no-new-issues.md index 77583949a..a3fc484f9 100644 --- a/.github/ISSUE_TEMPLATE/no-new-issues.md +++ b/.github/ISSUE_TEMPLATE/no-new-issues.md @@ -1,6 +1,6 @@ --- name: No new issues -about: Use use https://github.com/sbt/sbt/issues/new/choose instead +about: Use https://github.com/sbt/sbt/issues/new/choose instead --- From 06cece173392be9aae321433ba5a032d63d3749c Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 5 Sep 2019 16:03:14 -0400 Subject: [PATCH 374/483] Add names to the Travis CI jobs --- .travis.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index a2d12b760..56fe99a41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,19 +45,20 @@ matrix: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin - cd citest && ./test.sh - ## build using JDK 8, test using JDK 8 - - script: + - name: "build using JDK 8 test using JDK 8" + script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - cd citest && ./test.sh - ## build using JDK 8, test using OpenJDK 11 - - script: + - name: "build using JDK 8, test using OpenJDK 11" + script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - $JABBA_HOME/bin/jabba install $TRAVIS_JDK11 && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK11" && export PATH="$JAVA_HOME/bin:$PATH" - java -Xmx32m -version - cd citest && ./test.sh - - script: + - name: "Linux package testing" + script: - sbt -Dsbt.build.version=$SBT_VER rpm:packageBin debian:packageBin addons: apt: From 91b71b39d34967bb87fa17d409f481c4109bbb64 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 5 Sep 2019 17:51:59 -0400 Subject: [PATCH 375/483] Reproduce JDK 11 warning Ref https://github.com/sbt/sbt/issues/5031 --- citest/build.sbt | 9 ++++++++- citest/test.sh | 11 +++++++---- src/universal/bin/sbt | 12 +++++++----- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/citest/build.sbt b/citest/build.sbt index d860bffb1..19f66a715 100644 --- a/citest/build.sbt +++ b/citest/build.sbt @@ -1,4 +1,5 @@ lazy val check = taskKey[Unit]("") +lazy val check2 = taskKey[Unit]("") lazy val root = (project in file(".")) .settings( @@ -8,7 +9,6 @@ lazy val root = (project in file(".")) val xs = IO.readLines(file("output.txt")).toVector println(xs) - assert(xs(0) startsWith "[info] Loading project definition") assert(xs(1) startsWith "[info] Loading settings") assert(xs(2) startsWith "[info] Set current project to Hello") @@ -18,5 +18,12 @@ lazy val root = (project in file(".")) val ys = IO.readLines(file("err.txt")).toVector.distinct assert(ys.isEmpty, s"there's an stderr: $ys") + }, + + check2 := { + val xs = IO.readLines(file("output.txt")).toVector + println(xs) + val ys = IO.readLines(file("err.txt")).toVector.distinct + assert(!ys.exists(_.contains("Ignoring option MaxPermSize; support was removed in 8.0")), s"there's an stderr: $ys") } ) diff --git a/citest/test.sh b/citest/test.sh index 499669739..2dc2870b9 100755 --- a/citest/test.sh +++ b/citest/test.sh @@ -1,7 +1,11 @@ #!/bin/bash +# exit when something fails +set -e + ## https://github.com/travis-ci/travis-ci/issues/8408 unset _JAVA_OPTIONS +unset SBT_OPTS java -version ## end of Java switching @@ -9,12 +13,12 @@ java -version mkdir -p freshly-baked unzip -qo ../target/universal/sbt.zip -d ./freshly-baked -export SBT_OPTS=-Dfile.encoding=UTF-8 +./freshly-baked/sbt/bin/sbt -Dsbt.no.format=true about +./freshly-baked/sbt/bin/sbt -Dsbt.no.format=true about 1> output.txt 2> err.txt +./freshly-baked/sbt/bin/sbt check2 ./freshly-baked/sbt/bin/sbt about run -v -export SBT_OPTS="-Dfile.encoding=UTF-8 -Xms2048M -Xmx2048M -Xss4M" - ./freshly-baked/sbt/bin/sbt about run fail() { @@ -33,4 +37,3 @@ test -d ./target/home3/alternate-preloaded/org/scala-sbt || fail "expected to fi env HOME=./target/home4 ./freshly-baked/sbt/bin/sbt -J-Dsbt.global.base=./target/home4/global-base about test -d ./target/home4/global-base/preloaded/org/scala-sbt || fail "expected to find preloaded in ./target/home4/global-base" - diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index a630386ee..81811da46 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -13,6 +13,8 @@ declare init_sbt_version=_to_be_replaced declare sbt_default_mem=1024 declare -r default_sbt_opts="" declare -r default_java_opts="-Dfile.encoding=UTF-8" +declare sbt_verbose=0 +declare sbt_debug=0 ### ------------------------------- ### ### Helper methods for BASH scripts ### @@ -78,10 +80,10 @@ echoerr () { echo 1>&2 "$@" } vlog () { - [[ $verbose || $debug ]] && echoerr "$@" + [[ $sbt_verbose || $sbt_debug ]] && echoerr "$@" } dlog () { - [[ $debug ]] && echoerr "$@" + [[ $sbt_debug ]] && echoerr "$@" } jar_file () { @@ -103,7 +105,7 @@ rt_export_file () { execRunner () { # print the arguments one to a line, quoting any containing spaces - [[ $verbose || $debug ]] && echo "# Executing command line:" && { + [[ $sbt_verbose || $sbt_debug ]] && echo "# Executing command line:" && { for arg; do if printf "%s\n" "$arg" | grep -q ' '; then printf "\"%s\"\n" "$arg" @@ -518,9 +520,9 @@ process_args () { while [[ $# -gt 0 ]]; do case "$1" in -h|-help) usage; exit 1 ;; - -v|-verbose) verbose=1 && shift ;; + -v|-verbose) sbt_verbose=1 && shift ;; -V|-version) print_sbt_version=1 && shift ;; - -d|-debug) debug=1 && addSbt "-debug" && shift ;; + -d|-debug) sbt_debug=1 && addSbt "-debug" && shift ;; -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; -mem) require_arg integer "$1" "$2" && addMemory "$2" && shift 2 ;; From b629c92391de4f67c3bd089dcec8ec5dc81c4c6e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 5 Sep 2019 23:09:59 -0400 Subject: [PATCH 376/483] Fix -XX:MaxPermSize getting emitted for JDK 11 Fixes sbt/sbt#5031 --- src/universal/bin/sbt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 81811da46..4bbd3a5d4 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -163,15 +163,12 @@ addMemory () { if [[ -z $java_version ]]; then java_version=$(jdk_version) fi - local class_metadata_opt="MaxPermSize" addJava "-Xms${mem}m" addJava "-Xmx${mem}m" addJava "-Xss4M" addJava "-XX:ReservedCodeCacheSize=${codecache}m" - if [[ (( $java_version < 8 )) ]]; then - addJava "-XX:${class_metadata_opt}=${class_metadata_size}m" - fi + (( $java_version >= 8 )) || addJava "-XX:MaxPermSize=${class_metadata_size}m" } addDefaultMemory() { From 5165b9fd514c84cc2a86b35a75fd3b2840dac695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tuomas=20Lappetel=C3=A4inen?= Date: Fri, 13 Sep 2019 12:19:39 +0300 Subject: [PATCH 377/483] universal/bin/sbt: enclose arrays in quotes Fixes https://github.com/sbt/sbt/issues/5076. Arrays should be enclosed in quotes, or otherwise elements with spaces will be broken, e.g. `-Dfoobar="foo bar"` will become `-Dfoobar=foo` and `bar`. --- src/universal/bin/sbt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 4bbd3a5d4..9b160f3d4 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -330,8 +330,8 @@ copyRt() { echo Copying runtime jar. mkdir -p "$java9_ext" execRunner "$java_cmd" \ - ${sbt_options[@]} \ - ${java_args[@]} \ + "${sbt_options[@]}" \ + "${java_args[@]}" \ -jar "$rtexport" \ "${java9_rt}" fi @@ -382,8 +382,8 @@ run() { # run sbt execRunner "$java_cmd" \ $(get_gc_opts) \ - ${java_args[@]} \ - ${sbt_options[@]} \ + "${java_args[@]}" \ + "${sbt_options[@]}" \ -jar "$sbt_jar" \ "${sbt_commands[@]}" \ "${residual_args[@]}" From 2946025d750c378d7f742603142843c16754eded Mon Sep 17 00:00:00 2001 From: Anil Kumar Myla Date: Fri, 13 Sep 2019 19:56:39 -0700 Subject: [PATCH 378/483] Capture double dashes in process args --- src/universal/bin/sbt | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 9b160f3d4..dbfcaec53 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -516,28 +516,28 @@ map_args () { process_args () { while [[ $# -gt 0 ]]; do case "$1" in - -h|-help) usage; exit 1 ;; - -v|-verbose) sbt_verbose=1 && shift ;; - -V|-version) print_sbt_version=1 && shift ;; - -d|-debug) sbt_debug=1 && addSbt "-debug" && shift ;; + -h|-help|--help) usage; exit 1 ;; + -v|-verbose|--verbose) sbt_verbose=1 && shift ;; + -V|-version|--version) print_sbt_version=1 && shift ;; + -d|-debug|--debug) sbt_debug=1 && addSbt "-debug" && shift ;; - -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; - -mem) require_arg integer "$1" "$2" && addMemory "$2" && shift 2 ;; - -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; - -batch) exec Date: Fri, 13 Sep 2019 22:36:30 -0700 Subject: [PATCH 379/483] Add integration tests --- integration-test/src/test/scala/RunnerTest.scala | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 30cca6b5e..c5c1d4c80 100644 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -9,10 +9,7 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { lazy val sbtScript = if (isWindows) new File("target/universal/stage/bin/sbt.bat") else new File("target/universal/stage/bin/sbt") - def sbtProcess(arg: String) = - sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest"), - "JAVA_OPTS" -> "", - "SBT_OPTS" -> "") + def sbtProcess(arg: String) = sbtProcessWithOpts(arg, "", "") def sbtProcessWithOpts(arg: String, javaOpts: String, sbtOpts: String) = sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest"), "JAVA_OPTS" -> javaOpts, @@ -55,6 +52,12 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } + test("sbt --sbt-version") { + val out = sbtProcess("--sbt-version 1.3.0 compile -v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.version=1.3.0")) + () + } + test("sbt -mem 503") { val out = sbtProcess("compile -mem 503 -v").!!.linesIterator.toList assert(out.contains[String]("-Xmx503m")) From 91a639ff77c7b54ea4904fba956a8b739b28467c Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 17 Sep 2019 23:32:06 -0400 Subject: [PATCH 380/483] Drop -XX:+UseParallelGC Fixes https://github.com/sbt/sbt/issues/5045 Currently we set `-XX:+UseParallelGC` for JDK greater than 9. This isn't a great default because while the peak throughput is somewhat better than the default g1 collector, the worst case performance is really bad with UseParallelGC, especially when the heap size is large. Given the sudden diversification of JDK implementations, we should stay clear from `-XX` flags, and let the build users add them if they must. --- src/universal/bin/sbt | 16 ---------------- src/universal/bin/sbt.bat | 7 ------- 2 files changed, 23 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index dbfcaec53..0fbabf171 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -185,21 +185,6 @@ addDefaultMemory() { fi } -get_gc_opts () { - local older_than_9=$(( $java_version < 9 )) - - if [[ "$older_than_9" == "1" ]]; then - # don't need to worry about gc - echo "" - elif [[ "${JAVA_OPTS}" =~ Use.*GC ]] || [[ "${JAVA_TOOL_OPTIONS}" =~ Use.*GC ]] || [[ "${SBT_OPTS}" =~ Use.*GC ]] ; then - # GC arg has been passed in - don't change - echo "" - else - # Java 9+ so revert to old - echo "-XX:+UseParallelGC" - fi -} - require_arg () { local type="$1" local opt="$2" @@ -381,7 +366,6 @@ run() { else # run sbt execRunner "$java_cmd" \ - $(get_gc_opts) \ "${java_args[@]}" \ "${sbt_options[@]}" \ -jar "$sbt_jar" \ diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index ac5d33212..d8902fac5 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -198,13 +198,6 @@ if /I %JAVA_VERSION% GEQ 9 ( "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "!rtexport!" "!java9_rt!" ) set _JAVA_OPTS=!_JAVA_OPTS! -Dscala.ext.dirs="!java9_ext!" - - rem check to see if a GC has been set in the opts - echo !_JAVA_OPTS! | findstr /r "Use.*GC" >nul - if ERRORLEVEL 1 ( - rem don't have a GC set - revert to old GC - set _JAVA_OPTS=!_JAVA_OPTS! -XX:+UseParallelGC - ) ) exit /B 0 From 989136debfe08038283667bee76c032806e9ea6a Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 20 Sep 2019 10:36:16 -0400 Subject: [PATCH 381/483] Fix -v getting on all the time Fixes https://github.com/sbt/sbt/issues/5108 I messed up in https://github.com/sbt/sbt-launcher-package/pull/279/commits/91b71b39d34967bb87fa17d409f481c4109bbb64 by initializing the variable to 0. --- src/universal/bin/sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 0fbabf171..d72201d0a 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -13,8 +13,8 @@ declare init_sbt_version=_to_be_replaced declare sbt_default_mem=1024 declare -r default_sbt_opts="" declare -r default_java_opts="-Dfile.encoding=UTF-8" -declare sbt_verbose=0 -declare sbt_debug=0 +declare sbt_verbose= +declare sbt_debug= ### ------------------------------- ### ### Helper methods for BASH scripts ### From 261ddc3c3849cc85292897e55125e0939b2d6385 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 22 Sep 2019 15:50:18 -0400 Subject: [PATCH 382/483] Remove appveyor setting --- .appveyor.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index b7a0e4f2b..000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,30 +0,0 @@ -build: off - -init: - - git config --global core.autocrlf input - -install: - - cinst jdk8 -params 'installdir=C:\\jdk8' - - cinst jdk11 -params 'installdir=C:\\jdk11' - - SET JAVA_HOME=C:\jdk8 - - SET PATH=C:\jdk8\bin;%PATH% - - - ps: | - Add-Type -AssemblyName System.IO.Compression.FileSystem - if (!(Test-Path -Path "C:\sbt" )) { - (new-object System.Net.WebClient).DownloadFile( - 'https://piccolo.link/sbt-0.13.18.zip', - 'C:\sbt-bin.zip' - ) - [System.IO.Compression.ZipFile]::ExtractToDirectory("C:\sbt-bin.zip", "C:\sbt") - } - - SET PATH=C:\sbt\sbt\bin;%PATH% - - SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 - -test_script: - - sbt "-Dsbt.build.version=1.3.0-M4" universal:packageBin - - cd citest - - test.bat - - test1.bat - - test2.bat - - test3/test3.bat From 7636a47c9444e3cb0d71324f030990f44604520e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 22 Sep 2019 15:50:31 -0400 Subject: [PATCH 383/483] Ignore upload cookies --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 87178428e..f495d67cb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ src_managed /template-project/project/boot *~ /citest/freshly-baked/ +/upload/cookies From 0a09fa62edf6216007ed7fd1bcc74ea97ccabd2f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 22 Sep 2019 18:07:28 -0400 Subject: [PATCH 384/483] SBT_ETC_FILE Travis CI adds `/etc/sbt/sbtopts` that prevents us from testing the out-of-box behavior. This allows us to override the location. --- .travis.yml | 4 ++++ src/universal/bin/sbt | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 56fe99a41..a655dd166 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,8 @@ env: - TRAVIS_JDK=adopt@1.8.212-04 - JABBA_HOME=$HOME/.jabba - TRAVIS_JDK11=openjdk@1.11.0 + ## ignore Travis CI's default /etc/sbt/sbtopts + - SBT_ETC_FILE=$HOME/etc/sbt/sbtopts matrix: include: @@ -41,6 +43,7 @@ matrix: install: - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK/Contents/Home" && export PATH="$JAVA_HOME/bin:$PATH" - java -Xmx32m -version + - unset SBT_OPTS script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin - cd citest && ./test.sh @@ -72,6 +75,7 @@ before_install: install: - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" - java -Xmx32m -version + - unset SBT_OPTS cache: directories: diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index d72201d0a..4907c64c7 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -385,6 +385,8 @@ run() { declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" declare -r sbt_opts_file=".sbtopts" declare -r etc_sbt_opts_file="/etc/sbt/sbtopts" +# this allows /etc/sbt/sbtopts location to be changed +declare -r etc_file="${SBT_ETC_FILE:-$etc_sbt_opts_file}" declare -r dist_sbt_opts_file="${sbt_home}/conf/sbtopts" declare -r win_sbt_opts_file="${sbt_home}/conf/sbtconfig.txt" @@ -546,7 +548,7 @@ loadConfigFile() { [[ -f "$dist_sbt_opts_file" ]] && set -- $(loadConfigFile "$dist_sbt_opts_file") "$@" # Here we pull in the global settings configuration. -[[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@" +[[ -f "$etc_file" ]] && set -- $(loadConfigFile "$etc_file") "$@" # Pull in the project-level config file, if it exists. [[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@" From 4dc6bb788e9b33c94f3d248f225092399a1267be Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 22 Sep 2019 19:04:03 -0400 Subject: [PATCH 385/483] check that Linux output doesn't contain any junk --- .travis.yml | 2 +- citest/build.sbt | 7 ------- citest/test.sh | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index a655dd166..b26654512 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ scala: 2.10.7 env: global: - - SBT_VER=1.3.0-M4 + - SBT_VER=1.3.0 - TRAVIS_JDK=adopt@1.8.212-04 - JABBA_HOME=$HOME/.jabba - TRAVIS_JDK11=openjdk@1.11.0 diff --git a/citest/build.sbt b/citest/build.sbt index 19f66a715..567f42ae1 100644 --- a/citest/build.sbt +++ b/citest/build.sbt @@ -18,12 +18,5 @@ lazy val root = (project in file(".")) val ys = IO.readLines(file("err.txt")).toVector.distinct assert(ys.isEmpty, s"there's an stderr: $ys") - }, - - check2 := { - val xs = IO.readLines(file("output.txt")).toVector - println(xs) - val ys = IO.readLines(file("err.txt")).toVector.distinct - assert(!ys.exists(_.contains("Ignoring option MaxPermSize; support was removed in 8.0")), s"there's an stderr: $ys") } ) diff --git a/citest/test.sh b/citest/test.sh index 2dc2870b9..3cac58991 100755 --- a/citest/test.sh +++ b/citest/test.sh @@ -15,7 +15,7 @@ unzip -qo ../target/universal/sbt.zip -d ./freshly-baked ./freshly-baked/sbt/bin/sbt -Dsbt.no.format=true about ./freshly-baked/sbt/bin/sbt -Dsbt.no.format=true about 1> output.txt 2> err.txt -./freshly-baked/sbt/bin/sbt check2 +./freshly-baked/sbt/bin/sbt check ./freshly-baked/sbt/bin/sbt about run -v From 7e17407cba7862b684448bb6dfc04e82d4768985 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Mon, 23 Sep 2019 05:51:30 -0700 Subject: [PATCH 386/483] Update sbt.1 man page options --- src/linux/usr/share/man/man1/sbt.1 | 78 +++++++++++++++--------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/src/linux/usr/share/man/man1/sbt.1 b/src/linux/usr/share/man/man1/sbt.1 index 04e9dfa29..62c10bf29 100644 --- a/src/linux/usr/share/man/man1/sbt.1 +++ b/src/linux/usr/share/man/man1/sbt.1 @@ -3,65 +3,62 @@ .\" .TH SBT 1 "NOVEMBER 2011" Linux "User Manuals" .SH NAME -sbt \- Simple Build Tool +sbt \- An interactive build tool for Scala, Java, and more. .SH SYNOPSIS -.B sbt [-h] [-sbt-version -.I sbt-version -.B ] +.B sbt [-h] .I .B ... .SH DESCRIPTION -.B sbt -Runs the Simple Build Tool using the currently installed -.BR java (1) +SBT is a build tool for Scala, Java, and more. It requires Java 1.8 or later. The current directory is assumed to be the project. .SH OPTIONS -.IP "-h, -help" +.IP "-h, --help" Show help options. -.IP "-v, -verbose" +.IP "-v, --verbose" turn up the noise -.IP "-V, -version" +.IP "-V, --version" print the version of mothership sbt -.IP "-d, -debug" +.IP "-d, --debug" set sbt log level to debug -.IP -no-colors +.IP --no-colors disable ANSI color codes -.IP -sbt-create +.IP "--color=auto|always|true|false|never" +enable or disable ANSI color codes (sbt 1.3 and above) +.IP "--supershell=auto|always|true|false|never" +enable or disable supershell (sbt 1.3 and above) +.IP --traces +generate Trace Event report on shutdown (sbt 1.3 and above) +.IP --timings +display task timings report on shutdown +.IP --sbt-create start sbt even if current directory contains no sbt project -.IP "-sbt-dir " +.IP "--sbt-dir " path to global settings/plugins directory (default: ~/.sbt) -.IP "-sbt-boot " +.IP "--sbt-boot " path to shared boot directory (default: ~/.sbt/boot in 0.11 series) -.IP "-ivy " +.IP "--ivy " path to local Ivy repository (default: ~/.ivy2) -.IP "-mem " -set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem)) -.IP "-no-share" +.IP "--mem " +set memory options (default: 1024) +.IP "--no-share" use all local caches; no sharing -.IP "-no-global" +.IP "--no-global" uses global caches, but does not use global ~/.sbt directory. -.IP "-jvm-debug " +.IP "--jvm-debug " Turn on JVM debugging, open at the given port. -.IP -batch +.IP --batch Disable interactive mode -.IP -offline -put sbt in offline mode .SH SBT Version Options -.IP "-sbt-version " +.IP "--sbt-version " Use the alternate system wide -.I sbt-version -The Simple Build Tool version to use. This script will -download necessary versions using the -.BR curl (1) -tool. -.IP "-sbt-jar " +.IP "--sbt-jar " use the specified jar as the sbt launcher -.IP "-sbt-rc" +.IP "--sbt-rc" use an RC version of sbt -.IP -sbt-snapshot +.IP --sbt-snapshot use a snapshot version of sbt .SH Java Options -.IP "-java-home " +.IP "--java-home " alternate JAVA_HOME .IP "-Dkey=val" pass -Dkey=val directly to the java runtime @@ -72,7 +69,7 @@ add -X to sbt's scalacOptions (-S is stripped) .SH FILES .I ~/.sbt .RS -The user configuration file. +The user configuration directory. .RE .I ".jvmopts" .RS @@ -91,10 +88,11 @@ if this file exists, it is prepended to the runner args .IP JAVA_OPTS If non-null a set of arguments passed to java. .IP SBT_OPTS -environment variable, if unset uses "$default_sbt_opts". +environment variable, if unset uses "-Dfile.encoding=UTF-8". +.SH NOTES +In the case of duplicated or conflicting options, the order above +shows precedence: JAVA_OPTS lowest, command line options highest. .SH EXAMPLES Most users of this script will only have to call "sbt" on the command line. -.SH AUTHOR -Paul Phillips - - +.SH BUGS +https://github.com/sbt/sbt/issues From 07814bc576533cf725bcf81b0e7aa7a6b21eee4f Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 23 Sep 2019 18:08:29 -0400 Subject: [PATCH 387/483] Fix _to_be_replaced --- build.sbt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 267ebf00a..9a112b86f 100644 --- a/build.sbt +++ b/build.sbt @@ -172,8 +172,15 @@ val root = (project in file(".")). mappings in Universal := { val t = (target in Universal).value val prev = (mappings in Universal).value - val BinBat = "bin" + java.io.File.separator + "sbt.bat" + val BinSbt = "bin" + java.io.File.separator + "sbt" + val BinBat = BinSbt + ".bat" prev.toList map { + case (k, BinSbt) => + val x = IO.read(k) + IO.write(t / "sbt", x.replaceAllLiterally( + "declare init_sbt_version=_to_be_replaced", + s"""declare init_sbt_version=$sbtVersionToRelease""")) + (t / "sbt", BinSbt) case (k, BinBat) => val x = IO.read(k) IO.write(t / "sbt.bat", x.replaceAllLiterally( From f06e7e638e41a5a8e69735fdeb7dcd9d58c56a21 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Tue, 24 Sep 2019 12:31:18 -0400 Subject: [PATCH 388/483] Set posix +x Co-Authored-By: Eric Peters --- build.sbt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build.sbt b/build.sbt index 9a112b86f..a7d801219 100644 --- a/build.sbt +++ b/build.sbt @@ -176,10 +176,18 @@ val root = (project in file(".")). val BinBat = BinSbt + ".bat" prev.toList map { case (k, BinSbt) => + import java.nio.file.{Files, FileSystems} + val x = IO.read(k) IO.write(t / "sbt", x.replaceAllLiterally( "declare init_sbt_version=_to_be_replaced", s"""declare init_sbt_version=$sbtVersionToRelease""")) + + if (FileSystems.getDefault.supportedFileAttributeViews.contains("posix")) { + val perms = Files.getPosixFilePermissions(k.toPath) + Files.setPosixFilePermissions(t / "sbt" toPath, perms) + } + (t / "sbt", BinSbt) case (k, BinBat) => val x = IO.read(k) From 56cdfcaa9038669674d5d88e9fea2745b2f73641 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Mon, 23 Sep 2019 10:23:48 -0700 Subject: [PATCH 389/483] Add --numeric-version, --script-version, and update --version to print both versions --- .../src/test/scala/RunnerTest.scala | 28 +++++++++++++++++-- src/linux/usr/share/man/man1/sbt.1 | 6 +++- src/universal/bin/sbt | 16 +++++++++-- 3 files changed, 43 insertions(+), 7 deletions(-) mode change 100644 => 100755 integration-test/src/test/scala/RunnerTest.scala diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala old mode 100644 new mode 100755 index c5c1d4c80..6b94a7e3e --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -82,14 +82,36 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } - test("sbt -V|-version should print sbtVersion") { + // 1.3.0, 1.3.0-M4 + private val versionRegEx = "\\d(\\.\\d+){2}(-\\w+)?" + + test("sbt -V|-version|--version should print sbtVersion") { val out = sbtProcessWithOpts("-version", "", "").!!.trim - val expectedVersion = "^sbt version in this project: \\d\\.\\d+\\.\\d+\\S*$" + val expectedVersion = + s"""|(?m)^sbt version in this project: $versionRegEx + |sbt script version: $versionRegEx$$ + |""".stripMargin.trim.replace("\n", "\\n") assert(out.matches(expectedVersion)) - val out2 = sbtProcessWithOpts("-V", "", "").!!.trim + val out2 = sbtProcessWithOpts("--version", "", "").!!.trim assert(out2.matches(expectedVersion)) + + val out3 = sbtProcessWithOpts("-V", "", "").!!.trim + assert(out3.matches(expectedVersion)) () } + test("sbt --numeric-version should print sbt script version") { + val out = sbtProcessWithOpts("--numeric-version", "", "").!!.trim + val expectedVersion = "^"+versionRegEx+"$" + assert(out.matches(expectedVersion)) + () + } + + test("sbt --script-version should print sbtVersion") { + val out = sbtProcessWithOpts("--numeric-version", "", "").!!.trim + val expectedVersion = "^"+versionRegEx+"$" + assert(out.matches(expectedVersion)) + () + } } diff --git a/src/linux/usr/share/man/man1/sbt.1 b/src/linux/usr/share/man/man1/sbt.1 index 62c10bf29..523b3fe56 100644 --- a/src/linux/usr/share/man/man1/sbt.1 +++ b/src/linux/usr/share/man/man1/sbt.1 @@ -17,7 +17,11 @@ Show help options. .IP "-v, --verbose" turn up the noise .IP "-V, --version" -print the version of mothership sbt +print sbt version information +.IP "--numeric-version" +print the numeric sbt version (sbt sbtVersion) +.IP "--script-version" +print the version of sbt script .IP "-d, --debug" set sbt log level to debug .IP --no-colors diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 4907c64c7..dd50aeea6 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -6,7 +6,9 @@ declare -a java_args declare -a scalac_args declare -a sbt_commands declare -a sbt_options +declare -a print_version declare -a print_sbt_version +declare -a print_sbt_script_version declare java_cmd=java declare java_version declare init_sbt_version=_to_be_replaced @@ -361,8 +363,12 @@ run() { fi if [[ $print_sbt_version ]]; then - # print sbtVersion + execRunner "$java_cmd" -jar "$sbt_jar" "sbtVersion" | tail -1 | sed -e 's/\[info\]//g' + elif [[ $print_sbt_script_version ]]; then + echo "$init_sbt_version" + elif [[ $print_version ]]; then execRunner "$java_cmd" -jar "$sbt_jar" "sbtVersion" | tail -1 | sed -e 's/\[info\]/sbt version in this project:/g' + echo "sbt script version: $init_sbt_version" else # run sbt execRunner "$java_cmd" \ @@ -396,7 +402,9 @@ Usage: `basename "$0"` [options] -h | --help print this message -v | --verbose this runner is chattier - -V | --version print the version of mothership sbt + -V | --version print sbt version information + --numeric-version print the numeric sbt version (sbt sbtVersion) + --script-version print the version of sbt script -d | --debug set sbt log level to debug --no-colors disable ANSI color codes --color=auto|always|true|false|never @@ -504,7 +512,9 @@ process_args () { case "$1" in -h|-help|--help) usage; exit 1 ;; -v|-verbose|--verbose) sbt_verbose=1 && shift ;; - -V|-version|--version) print_sbt_version=1 && shift ;; + -V|-version|--version) print_version=1 && shift ;; + --numeric-version) print_sbt_version=1 && shift ;; + --script-version) print_sbt_script_version=1 && shift ;; -d|-debug|--debug) sbt_debug=1 && addSbt "-debug" && shift ;; -ivy|--ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; From 98efb989db1cdda4c6ad680cc449b89f980ef10e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 25 Sep 2019 06:57:07 +0100 Subject: [PATCH 390/483] Fix equal sign handling for -D Fixes sbt/sbt#2695 By the time the arguments are passed to a batch script, it seems like is parsed away. for /F did not work since it would not handle double quoted paths that include whitespaces. This adds special handling for -D parameters only. --- citest/test.bat | 6 +++--- src/universal/bin/sbt.bat | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/citest/test.bat b/citest/test.bat index e0f2cab41..b878746e4 100644 --- a/citest/test.bat +++ b/citest/test.bat @@ -13,10 +13,10 @@ SET JAVA_HOME=C:\jdk11 SET PATH=C:\jdk11\bin;%PATH% SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 -"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" about +"freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true about -"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" about 1> output.txt 2> err.txt +"freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true about 1> output.txt 2> err.txt -"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" check +"freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true check ENDLOCAL diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index d8902fac5..369d890e6 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -64,6 +64,7 @@ set INIT_SBT_VERSION=_TO_BE_REPLACED :args_loop if "%~1" == "" goto args_end +set g=%1 if "%~1" == "-jvm-debug" set JVM_DEBUG=true if "%~1" == "--jvm-debug" set JVM_DEBUG=true @@ -80,6 +81,19 @@ if "%JVM_DEBUG%" == "true" ( ) else if /I "%~1" == "new" ( set sbt_new=true set SBT_ARGS=!SBT_ARGS! %1 +) else if /I "%g:~0,2%" == "-D" ( + rem special handling for -D since '=' gets parsed away + if x%g:^==% == x%g% ( + if not "%~2" == "" ( + set SBT_ARGS=!SBT_ARGS! "%~1=%~2" + shift + ) else ( + echo "%~1" is missing a value + goto error + ) + ) else ( + set SBT_ARGS=!SBT_ARGS! %1 + ) ) else ( set SBT_ARGS=!SBT_ARGS! %1 ) From 8caa28b57bec80688cdeb9357cd39af7831014a3 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 25 Sep 2019 07:45:16 +0100 Subject: [PATCH 391/483] --verbose mode for Windows --- src/universal/bin/sbt.bat | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 369d890e6..e0e642d6f 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -12,6 +12,7 @@ @echo off set SBT_HOME=%~dp0 set SBT_ARGS= +set SBT_VERBOSE= set DEFAULT_JAVA_OPTS=-Dfile.encoding=UTF-8 @@ -71,6 +72,19 @@ if "%~1" == "--jvm-debug" set JVM_DEBUG=true if "%~1" == "-java-home" set SET_JAVA_HOME=true if "%~1" == "--java-home" set SET_JAVA_HOME=true +if "%~1" == "-v" ( + set SBT_VERBOSE=true + goto args_next +) +if "%~1" == "-verbose" ( + set SBT_VERBOSE=true + goto args_next +) +if "%~1" == "--verbose" ( + set SBT_VERBOSE=true + goto args_next +) + if "%JVM_DEBUG%" == "true" ( set /a JVM_DEBUG_PORT=5005 2>nul >nul ) else if "!JVM_DEBUG!" == "true" ( @@ -116,6 +130,7 @@ if "%SET_JAVA_HOME%" == "true" ( ) ) +:args_next shift goto args_loop :args_end @@ -163,10 +178,27 @@ if ERRORLEVEL 1 goto error goto end :run +if "%SBT_VERBOSE%" == "true" ( + echo # Executing command line: + echo "%_JAVACMD%" + if not "%_JAVA_OPTS%" == "" ( call :echolist %_JAVA_OPTS% ) + if not "%SBT_OPTS%" == "" ( call :echolist %SBT_OPTS% ) + echo -cp "%SBT_HOME%sbt-launch.jar" + echo xsbt.boot.Boot + if not "%*" == "" ( call :echolist %* ) + echo. +) "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%sbt-launch.jar" xsbt.boot.Boot %* goto :eof +:echolist +for /F "tokens=1*" %%g in ("%*") do ( + echo %%g + if not x%%h == x call :echolist %%h +) +exit /B 0 + :process rem Parses x out of 1.x; for example 8 out of java version 1.8.0_xx rem Otherwise, parses the major version; 9 out of java version 9-ea From a114398c71bfe48d1a3115e4a336c541905b05fa Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Sat, 28 Sep 2019 06:59:34 -0700 Subject: [PATCH 392/483] Fix No compatible version found for adopt@1.8.212-04 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b26654512..0358945df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ scala: 2.10.7 env: global: - SBT_VER=1.3.0 - - TRAVIS_JDK=adopt@1.8.212-04 + - TRAVIS_JDK=adopt@1.8.0-222 - JABBA_HOME=$HOME/.jabba - TRAVIS_JDK11=openjdk@1.11.0 ## ignore Travis CI's default /etc/sbt/sbtopts From 1ac4c7400a2397d626cab2fb0d905dcbbdf18306 Mon Sep 17 00:00:00 2001 From: Alex Zolotko Date: Mon, 30 Sep 2019 13:27:20 +0200 Subject: [PATCH 393/483] Detect more memory settings Fixes sbt/sbt#5135 --- src/universal/bin/sbt | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index dd50aeea6..1a42143ab 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -176,11 +176,29 @@ addMemory () { addDefaultMemory() { # if we detect any of these settings in ${JAVA_OPTS} or ${JAVA_TOOL_OPTIONS} we need to NOT output our settings. # The reason is the Xms/Xmx, if they don't line up, cause errors. - if [[ "${java_args[@]}" == *-Xmx* ]] || [[ "${java_args[@]}" == *-Xms* ]]; then + if [[ "${java_args[@]}" == *-Xmx* ]] || \ + [[ "${java_args[@]}" == *-Xms* ]] || \ + [[ "${java_args[@]}" == *-XX:+UseCGroupMemoryLimitForHeap* ]] || \ + [[ "${java_args[@]}" == *-XX:MaxRAM* ]] || \ + [[ "${java_args[@]}" == *-XX:InitialRAMPercentage* ]] || \ + [[ "${java_args[@]}" == *-XX:MaxRAMPercentage* ]] || \ + [[ "${java_args[@]}" == *-XX:MinRAMPercentage* ]]; then : - elif [[ "${JAVA_TOOL_OPTIONS}" == *-Xmx* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-Xms* ]]; then + elif [[ "${JAVA_TOOL_OPTIONS}" == *-Xmx* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-Xms* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:+UseCGroupMemoryLimitForHeap* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxRAM* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:InitialRAMPercentage* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxRAMPercentage* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MinRAMPercentage* ]] ; then : - elif [[ "${sbt_options[@]}" == *-Xmx* ]] || [[ "${sbt_options[@]}" == *-Xms* ]]; then + elif [[ "${sbt_options[@]}" == *-Xmx* ]] || \ + [[ "${sbt_options[@]}" == *-Xms* ]] || \ + [[ "${sbt_options[@]}" == *-XX:+UseCGroupMemoryLimitForHeap* ]] || \ + [[ "${sbt_options[@]}" == *-XX:MaxRAM* ]] || \ + [[ "${sbt_options[@]}" == *-XX:InitialRAMPercentage* ]] || \ + [[ "${sbt_options[@]}" == *-XX:MaxRAMPercentage* ]] || \ + [[ "${sbt_options[@]}" == *-XX:MinRAMPercentage* ]] ; then : else addMemory $sbt_default_mem From d272ab1a1f85ab3540c7f7472ceac2ab94889915 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Sat, 28 Sep 2019 06:59:34 -0700 Subject: [PATCH 394/483] Fix No compatible version found for adopt@1.8.212-04 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b26654512..0358945df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ scala: 2.10.7 env: global: - SBT_VER=1.3.0 - - TRAVIS_JDK=adopt@1.8.212-04 + - TRAVIS_JDK=adopt@1.8.0-222 - JABBA_HOME=$HOME/.jabba - TRAVIS_JDK11=openjdk@1.11.0 ## ignore Travis CI's default /etc/sbt/sbtopts From a9d85c6df66f5028aa71bc2b76a48c3aea746e5f Mon Sep 17 00:00:00 2001 From: Alex Zolotko Date: Mon, 30 Sep 2019 13:27:20 +0200 Subject: [PATCH 395/483] Detect more memory settings Fixes sbt/sbt#5135 --- src/universal/bin/sbt | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index dd50aeea6..1a42143ab 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -176,11 +176,29 @@ addMemory () { addDefaultMemory() { # if we detect any of these settings in ${JAVA_OPTS} or ${JAVA_TOOL_OPTIONS} we need to NOT output our settings. # The reason is the Xms/Xmx, if they don't line up, cause errors. - if [[ "${java_args[@]}" == *-Xmx* ]] || [[ "${java_args[@]}" == *-Xms* ]]; then + if [[ "${java_args[@]}" == *-Xmx* ]] || \ + [[ "${java_args[@]}" == *-Xms* ]] || \ + [[ "${java_args[@]}" == *-XX:+UseCGroupMemoryLimitForHeap* ]] || \ + [[ "${java_args[@]}" == *-XX:MaxRAM* ]] || \ + [[ "${java_args[@]}" == *-XX:InitialRAMPercentage* ]] || \ + [[ "${java_args[@]}" == *-XX:MaxRAMPercentage* ]] || \ + [[ "${java_args[@]}" == *-XX:MinRAMPercentage* ]]; then : - elif [[ "${JAVA_TOOL_OPTIONS}" == *-Xmx* ]] || [[ "${JAVA_TOOL_OPTIONS}" == *-Xms* ]]; then + elif [[ "${JAVA_TOOL_OPTIONS}" == *-Xmx* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-Xms* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:+UseCGroupMemoryLimitForHeap* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxRAM* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:InitialRAMPercentage* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxRAMPercentage* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MinRAMPercentage* ]] ; then : - elif [[ "${sbt_options[@]}" == *-Xmx* ]] || [[ "${sbt_options[@]}" == *-Xms* ]]; then + elif [[ "${sbt_options[@]}" == *-Xmx* ]] || \ + [[ "${sbt_options[@]}" == *-Xms* ]] || \ + [[ "${sbt_options[@]}" == *-XX:+UseCGroupMemoryLimitForHeap* ]] || \ + [[ "${sbt_options[@]}" == *-XX:MaxRAM* ]] || \ + [[ "${sbt_options[@]}" == *-XX:InitialRAMPercentage* ]] || \ + [[ "${sbt_options[@]}" == *-XX:MaxRAMPercentage* ]] || \ + [[ "${sbt_options[@]}" == *-XX:MinRAMPercentage* ]] ; then : else addMemory $sbt_default_mem From b5fd78f74bf1dc38bbc4203067dabb0f54dd5ea7 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Sun, 22 Sep 2019 22:25:35 -0700 Subject: [PATCH 396/483] Intial sbt.bat refactor to match the universal bash script - implement --help, --verbose, --version, --script-verion, --numeric-version, .sbtopts, .jvmopts, -D --- .travis.yml | 2 +- build.sbt | 8 +- citest/test.bat | 9 + citest/test3/build.sbt | 28 + .../src/test/scala/RunnerTest.scala | 23 +- src/universal/bin/sbt.bat | 742 +++++++++++++++--- src/universal/conf/sbtconfig.txt | 10 +- 7 files changed, 689 insertions(+), 133 deletions(-) mode change 100644 => 100755 .travis.yml mode change 100644 => 100755 build.sbt mode change 100644 => 100755 citest/test.bat mode change 100644 => 100755 citest/test3/build.sbt mode change 100644 => 100755 src/universal/conf/sbtconfig.txt diff --git a/.travis.yml b/.travis.yml old mode 100644 new mode 100755 index 0358945df..34e3c8e3f --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ matrix: - unzip /tmp/sbt.zip -d $HOME/sbt - export PATH="$HOME/sbt/sbt/bin:$PATH" script: - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - cd citest - "./test.bat" - "test3/test3.bat" diff --git a/build.sbt b/build.sbt old mode 100644 new mode 100755 index a7d801219..f08475da8 --- a/build.sbt +++ b/build.sbt @@ -181,7 +181,7 @@ val root = (project in file(".")). val x = IO.read(k) IO.write(t / "sbt", x.replaceAllLiterally( "declare init_sbt_version=_to_be_replaced", - s"""declare init_sbt_version=$sbtVersionToRelease""")) + s"declare init_sbt_version=$sbtVersionToRelease")) if (FileSystems.getDefault.supportedFileAttributeViews.contains("posix")) { val perms = Files.getPosixFilePermissions(k.toPath) @@ -192,8 +192,8 @@ val root = (project in file(".")). case (k, BinBat) => val x = IO.read(k) IO.write(t / "sbt.bat", x.replaceAllLiterally( - "set INIT_SBT_VERSION=_TO_BE_REPLACED", - s"""set INIT_SBT_VERSION=$sbtVersionToRelease""")) + "set init_sbt_version=_to_be_replaced", + s"set init_sbt_version=$sbtVersionToRelease")) (t / "sbt.bat", BinBat) case (k, v) => (k, v) } @@ -249,7 +249,7 @@ lazy val integrationTest = (project in file("integration-test")) libraryDependencies ++= Seq( "io.monix" %% "minitest" % "2.3.2" % Test, "com.eed3si9n.expecty" %% "expecty" % "0.11.0" % Test, - "org.scala-sbt" %% "io" % "1.2.2" % Test + "org.scala-sbt" %% "io" % "1.3.1" % Test ), testFrameworks += new TestFramework("minitest.runner.Framework") ) diff --git a/citest/test.bat b/citest/test.bat old mode 100644 new mode 100755 index b878746e4..c35ddae49 --- a/citest/test.bat +++ b/citest/test.bat @@ -19,4 +19,13 @@ SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8 "freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true check +"freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true --numeric-version > numericVersion.txt +"freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true checkNumericVersion + +"freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true --script-version > scriptVersion.txt +"freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true checkScriptVersion + +"freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true --version > version.txt +"freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true checkVersion + ENDLOCAL diff --git a/citest/test3/build.sbt b/citest/test3/build.sbt old mode 100644 new mode 100755 index 3ff4eae20..6cba9926c --- a/citest/test3/build.sbt +++ b/citest/test3/build.sbt @@ -1,4 +1,10 @@ lazy val check = taskKey[Unit]("") +lazy val checkNumericVersion = taskKey[Unit]("") +lazy val checkScriptVersion = taskKey[Unit]("") +lazy val checkVersion = taskKey[Unit]("") + +// 1.3.0, 1.3.0-M4 +lazy val versionRegEx = "\\d(\\.\\d+){2}(-\\w+)?" lazy val root = (project in file(".")) .settings( @@ -20,5 +26,27 @@ lazy val root = (project in file(".")) assert(ys.size == 1, s"ys has more than one item: $ys") assert(ys(0) startsWith "Java HotSpot(TM) 64-Bit Server VM warning") + }, + checkNumericVersion = { + val xs = IO.readLines(file("numericVersion.txt")).toVector + val expectedVersion = "^"+versionRegEx+"$" + + assert(xs(0).matches(expectedVersion)) + }, + checkScriptVersion = { + val xs = IO.readLines(file("scriptVersion.txt")).toVector + val expectedVersion = "^"+versionRegEx+"$" + + assert(xs(0).matches(expectedVersion)) + }, + checkVersion = { + val out = IO.readLines(file("version.txt")).toVector.mkString("\n") + + val expectedVersion = + s"""|(?m)^sbt version in this project: $versionRegEx + |sbt script version: $versionRegEx$$ + |""".stripMargin.trim.replace("\n", "\\n") + + assert(out.matches(expectedVersion)) } ) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 6b94a7e3e..314514f1a 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -5,10 +5,14 @@ import scala.sys.process._ import java.io.File object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { + // 1.3.0, 1.3.0-M4 + private val versionRegEx = "\\d(\\.\\d+){2}(-\\w+)?" + lazy val isWindows: Boolean = sys.props("os.name").toLowerCase(java.util.Locale.ENGLISH).contains("windows") lazy val sbtScript = if (isWindows) new File("target/universal/stage/bin/sbt.bat") else new File("target/universal/stage/bin/sbt") + def sbtProcess(arg: String) = sbtProcessWithOpts(arg, "", "") def sbtProcessWithOpts(arg: String, javaOpts: String, sbtOpts: String) = sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest"), @@ -64,33 +68,40 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } - test("sbt with -mem 503 in JAVA_OPTS") { + test("sbt with -mem 503, -Xmx in JAVA_OPTS") { val out = sbtProcessWithOpts("compile -mem 503 -v", "-Xmx1024m", "").!!.linesIterator.toList assert(out.contains[String]("-Xmx503m")) + assert(!out.contains[String]("-Xmx1024m")) + () + } + + test("sbt with -mem 503, -Xmx in SBT_OPTS") { + val out = sbtProcessWithOpts("compile -mem 503 -v", "", "-Xmx1024m").!!.linesIterator.toList + assert(out.contains[String]("-Xmx503m")) + assert(!out.contains[String]("-Xmx1024m")) () } test("sbt with -Xms2048M -Xmx2048M -Xss6M in SBT_OPTS") { + if (isWindows) cancel("Test not supported on windows") val out = sbtProcessWithOpts("compile -v", "", "-Xms2048M -Xmx2048M -Xss6M").!!.linesIterator.toList assert(out.contains[String]("-Xss6M")) () } test("sbt with --no-colors in SBT_OPTS") { + if (isWindows) cancel("Test not supported on windows") val out = sbtProcessWithOpts("compile -v", "", "--no-colors").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.log.noformat=true")) () } - // 1.3.0, 1.3.0-M4 - private val versionRegEx = "\\d(\\.\\d+){2}(-\\w+)?" - test("sbt -V|-version|--version should print sbtVersion") { val out = sbtProcessWithOpts("-version", "", "").!!.trim val expectedVersion = s"""|(?m)^sbt version in this project: $versionRegEx - |sbt script version: $versionRegEx$$ - |""".stripMargin.trim.replace("\n", "\\n") + |sbt script version: $versionRegEx$$ + |""".stripMargin.trim.replace("\n", "\\n") assert(out.matches(expectedVersion)) val out2 = sbtProcessWithOpts("--version", "", "").!!.trim diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index e0e642d6f..043ac450e 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -10,118 +10,352 @@ @setlocal enabledelayedexpansion @echo off -set SBT_HOME=%~dp0 -set SBT_ARGS= -set SBT_VERBOSE= +set SBT_BIN_DIR=%~dp0 +if not defined SBT_HOME for %%I in ("!SBT_BIN_DIR!\..") do set "SBT_HOME=%%~fI" -set DEFAULT_JAVA_OPTS=-Dfile.encoding=UTF-8 +set SBT_ARGS= +set _JAVACMD= +set _SBT_OPTS= +set _JAVA_OPTS= + +set init_sbt_version=_to_be_replaced +set sbt_default_mem=1024 +set default_sbt_opts= +set default_java_opts=-Dfile.encoding=UTF-8 + +set sbt_args_print_version= +set sbt_args_print_sbt_version= +set sbt_args_print_sbt_script_version= +set sbt_args_verbose= +set sbt_args_debug= +set sbt_args_batch= +set sbt_args_color= +set sbt_args_no_colors= +set sbt_args_no_global= +set sbt_args_no_share= +set sbt_args_ivy= +set sbt_args_supershell= +set sbt_args_timings= +set sbt_args_traces= +set sbt_args_sbt_create= +set sbt_args_sbt_dir= +set sbt_args_sbt_version= +set sbt_args_mem= + +rem users can set SBT_OPTS via .sbtopts +if exist .sbtopts for /F %%A in (.sbtopts) do ( + set _sbtopts_line=%%A + if not "!_sbtopts_line:~0,1!" == "#" ( + set _SBT_OPTS=%%A %SBT_OPTS% + ) +) + +rem TODO: remove/deprecate sbtconfig.txt and parse the sbtopts files rem FIRST we load the config file of extra options. -set FN=%SBT_HOME%\..\conf\sbtconfig.txt -set CFG_OPTS= -FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%FN%") DO ( +set SBT_CONFIG=!SBT_HOME!\conf\sbtconfig.txt +set SBT_CFG_OPTS= +for /F "tokens=* eol=# usebackq delims=" %%i in ("!SBT_CONFIG!") do ( set DO_NOT_REUSE_ME=%%i rem ZOMG (Part #2) WE use !! here to delay the expansion of - rem CFG_OPTS, otherwise it remains "" for this loop. - set CFG_OPTS=!CFG_OPTS! !DO_NOT_REUSE_ME! + rem SBT_CFG_OPTS, otherwise it remains "" for this loop. + set SBT_CFG_OPTS=!SBT_CFG_OPTS! !DO_NOT_REUSE_ME! ) rem poor man's jenv (which is not available on Windows) -IF DEFINED JAVA_HOMES ( - IF EXIST .java-version FOR /F %%A IN (.java-version) DO ( - SET JAVA_HOME=%JAVA_HOMES%\%%A - SET JDK_HOME=%JAVA_HOMES%\%%A +if defined JAVA_HOMES ( + if exist .java-version for /F %%A in (.java-version) do ( + set JAVA_HOME=%JAVA_HOMES%\%%A + set JDK_HOME=%JAVA_HOMES%\%%A ) ) + rem must set PATH or wrong javac is used for java projects -IF DEFINED JAVA_HOME SET "PATH=%JAVA_HOME%\bin;%PATH%" +if defined JAVA_HOME set "PATH=%JAVA_HOME%\bin;%PATH%" -rem users can set JAVA_OPTS via .jvmopts (sbt-extras style) -IF EXIST .jvmopts FOR /F %%A IN (.jvmopts) DO ( - SET _jvmopts_line=%%A - IF NOT "!_jvmopts_line:~0,1!"=="#" ( - SET JAVA_OPTS=%%A !JAVA_OPTS! - ) -) rem We use the value of the JAVACMD environment variable if defined -set _JAVACMD=%JAVACMD% +if defined JAVACMD set "_JAVACMD=%JAVACMD%" -if "%_JAVACMD%"=="" ( - if not "%JAVA_HOME%"=="" ( +rem remove quotes +if defined _JAVACMD set _JAVACMD=!_JAVACMD:"=! + +if not defined _JAVACMD ( + if not "%JAVA_HOME%" == "" ( if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe" ) ) -if "%_JAVACMD%"=="" set _JAVACMD=java +if not defined _JAVACMD set _JAVACMD=java + +rem users can set JAVA_OPTS via .jvmopts (sbt-extras style) +if exist .jvmopts for /F %%A in (.jvmopts) do ( + set _jvmopts_line=%%A + if not "!_jvmopts_line:~0,1!" == "#" ( + if defined _JAVA_OPTS ( + set _JAVA_OPTS=!_JAVA_OPTS! %%A + ) else ( + set _JAVA_OPTS=%%A + ) + ) +) rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config. -set _JAVA_OPTS=%JAVA_OPTS% -if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% +if not defined _JAVA_OPTS if defined JAVA_OPTS set _JAVA_OPTS=%JAVA_OPTS% +if not defined _JAVA_OPTS if defined default_java_opts set _JAVA_OPTS=!default_java_opts! -if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%DEFAULT_JAVA_OPTS% - -set INIT_SBT_VERSION=_TO_BE_REPLACED +rem We use the value of the SBT_OPTS environment variable if defined, rather than the config. +if not defined _SBT_OPTS if defined SBT_OPTS set _SBT_OPTS=%SBT_OPTS% +if not defined _SBT_OPTS if defined SBT_CFG_OPTS set _SBT_OPTS=!SBT_CFG_OPTS! +if not defined _SBT_OPTS if defined default_sbt_opts set _SBT_OPTS=!default_sbt_opts! :args_loop -if "%~1" == "" goto args_end +shift -set g=%1 -if "%~1" == "-jvm-debug" set JVM_DEBUG=true -if "%~1" == "--jvm-debug" set JVM_DEBUG=true +if [%0] EQU [] goto args_end +set g=%~0 -if "%~1" == "-java-home" set SET_JAVA_HOME=true -if "%~1" == "--java-home" set SET_JAVA_HOME=true +if "%~0" == "-h" goto usage +if "%~0" == "-help" goto usage +if "%~0" == "--help" goto usage -if "%~1" == "-v" ( - set SBT_VERBOSE=true - goto args_next -) -if "%~1" == "-verbose" ( - set SBT_VERBOSE=true - goto args_next -) -if "%~1" == "--verbose" ( - set SBT_VERBOSE=true - goto args_next +if "%~0" == "-v" set _verbose_arg=true +if "%~0" == "-verbose" set _verbose_arg=true +if "%~0" == "--verbose" set _verbose_arg=true + +if defined _verbose_arg ( + set _verbose_arg= + set sbt_args_verbose=1 + goto args_loop ) -if "%JVM_DEBUG%" == "true" ( - set /a JVM_DEBUG_PORT=5005 2>nul >nul -) else if "!JVM_DEBUG!" == "true" ( - set /a JVM_DEBUG_PORT=%1 2>nul >nul - if not "%~1" == "!JVM_DEBUG_PORT!" ( - set SBT_ARGS=!SBT_ARGS! %1 - ) -) else if /I "%~1" == "new" ( - set sbt_new=true - set SBT_ARGS=!SBT_ARGS! %1 -) else if /I "%g:~0,2%" == "-D" ( - rem special handling for -D since '=' gets parsed away - if x%g:^==% == x%g% ( - if not "%~2" == "" ( - set SBT_ARGS=!SBT_ARGS! "%~1=%~2" - shift - ) else ( - echo "%~1" is missing a value - goto error - ) +if "%~0" == "-V" set _version_arg=true +if "%~0" == "-version" set _version_arg=true +if "%~0" == "--version" set _version_arg=true + +if defined _version_arg ( + set _version_arg= + set sbt_args_print_version=1 + goto args_loop +) + +if "%~0" == "-batch" set _batch_arg=true +if "%~0" == "--batch" set _batch_arg=true + +if defined _batch_arg ( + set _batch_arg= + set sbt_args_batch=1 + goto args_loop +) + +if "%~0" == "-no-colors" set _no_colors_arg=true +if "%~0" == "--no-colors" set _no_colors_arg=true + +if defined _no_colors_arg ( + set _no_colors_arg= + set sbt_args_no_colors=1 + goto args_loop +) + +if "%~0" == "-no-global" set _no_global_arg=true +if "%~0" == "--no-global" set _no_global_arg=true + +if defined _no_global_arg ( + set _no_global_arg= + set sbt_args_no_global=1 + goto args_loop +) + +if "%~0" == "-traces" set _traces_arg=true +if "%~0" == "--traces" set _traces_arg=true + +if defined _traces_arg ( + set _traces_arg= + set sbt_args_traces=1 + goto args_loop +) + +if "%~0" == "-sbt-create" set _sbt_create_arg=true +if "%~0" == "--sbt-create" set _sbt_create_arg=true + +if defined _sbt_create_arg ( + set _sbt_create_arg= + set sbt_args_sbt_create=1 + goto args_loop +) + +if "%~0" == "-sbt-dir" set _sbt_dir_arg=true +if "%~0" == "--sbt-dir" set _sbt_dir_arg=true + +if defined _sbt_dir_arg ( + set _sbt_dir_arg= + if not "%~1" == "" ( + set sbt_args_sbt_dir=%1 + shift + goto args_loop + ) else ( + echo "%~0" is missing a value + goto error + ) +) + +if "%~0" == "-sbt-boot" set _sbt_boot_arg=true +if "%~0" == "--sbt-boot" set _sbt_boot_arg=true + +if defined _sbt_boot_arg ( + set _sbt_boot_arg= + if not "%~1" == "" ( + set sbt_args_sbt_boot=%1 + shift + goto args_loop + ) else ( + echo "%~0" is missing a value + goto error + ) +) + +if "%~0" == "-ivy" set _sbt_ivy_arg=true +if "%~0" == "--ivy" set _sbt_ivy_arg=true + +if defined _sbt_ivy_arg ( + set _sbt_ivy_arg= + if not "%~1" == "" ( + set sbt_args_ivy=%1 + shift + goto args_loop + ) else ( + echo "%~0" is missing a value + goto error + ) +) + +if "%~0" == "-d" set _debug_arg=true +if "%~0" == "--debug" set _debug_arg=true + +if defined _debug_arg ( + set _debug_arg= + set sbt_args_debug=1 + set SBT_ARGS=-debug !SBT_ARGS! + goto args_loop +) + +if "%~0" == "--sbt-version" set _sbt_version_arg=true +if "%~0" == "-sbt-version" set _sbt_version_arg=true + +if defined _sbt_version_arg ( + set _sbt_version_arg= + if not "%~1" == "" ( + set sbt_args_sbt_version=%~1 + shift + goto args_loop + ) else ( + echo "%~0" is missing a value + goto error + ) +) + +if "%~0" == "--mem" set _sbt_mem_arg=true +if "%~0" == "-mem" set _sbt_mem_arg=true + +if defined _sbt_mem_arg ( + set _sbt_mem_arg= + if not "%~1" == "" ( + set sbt_args_mem=%~1 + shift + goto args_loop + ) else ( + echo "%~0" is missing a value + goto error + ) +) + +if "%~0" == "--supershell" set _supershell_arg=true +if "%~0" == "-supershell" set _supershell_arg=true + +if defined _supershell_arg ( + set _supershell_arg= + if not "%~1" == "" ( + set sbt_args_supershell=%~1 + shift + goto args_loop + ) else ( + echo "%~0" is missing a value + goto error + ) +) + +if "%~0" == "--color" set _color_arg=true +if "%~0" == "-color" set _color_arg=true + +if defined _color_arg ( + set _color_arg= + if not "%~1" == "" ( + set sbt_args_color=%~1 + shift + goto args_loop ) else ( - set SBT_ARGS=!SBT_ARGS! %1 + echo "%~0" is missing a value + goto error ) -) else ( - set SBT_ARGS=!SBT_ARGS! %1 + goto args_loop ) -if "%SET_JAVA_HOME%" == "true" ( - set SET_JAVA_HOME= - if NOT "%~2" == "" ( - if exist "%~2\bin\java.exe" ( - set _JAVACMD="%~2\bin\java.exe" - set JAVA_HOME="%~2" - set JDK_HOME="%~2" +if "%~0" == "--no-share" set _no_share_arg=true +if "%~0" == "-no-share" set _no_share_arg=true + +if defined _no_share_arg ( + set _no_share_arg= + set sbt_args_no_share=1 + goto args_loop +) + +if "%~0" == "--timings" set _timings_arg=true +if "%~0" == "-timings" set _timings_arg=true + +if defined _timings_arg ( + set _timings_arg= + set sbt_args_timings=1 + goto args_loop +) + +if "%~0" == "--script-version" ( + set sbt_args_print_sbt_script_version=1 + goto args_loop +) + +if "%~0" == "--numeric-version" ( + set sbt_args_print_sbt_version=1 + goto args_loop +) + +if "%~0" == "-jvm-debug" set _jvm_debug_arg=true +if "%~0" == "--jvm-debug" set _jvm_debug_arg=true + +if defined _jvm_debug_arg ( + set _jvm_debug_arg= + if [%1] NEQ [] ( + set /a JVM_DEBUG_PORT=%~1 2>nul >nul + if !JVM_DEBUG_PORT! EQU 0 ( + rem next argument wasn't a port, set a default and process next arg + set /A JVM_DEBUG_PORT=5005 + goto args_loop + ) + ) +) + +if "%~0" == "-java-home" set _java_home_arg=true +if "%~0" == "--java-home" set _java_home_arg=true + +if defined _java_home_arg ( + set _java_home_arg= + if [%1] NEQ [] ( + if exist "%~1\bin\java.exe" ( + set "_JAVACMD=%~1\bin\java.exe" + set "JAVA_HOME=%~1" + set "JDK_HOME=%~1" shift + goto args_loop ) else ( - echo Directory "%~2" for JAVA_HOME is not valid + echo Directory "%~1" for JAVA_HOME is not valid goto error ) ) else ( @@ -130,14 +364,38 @@ if "%SET_JAVA_HOME%" == "true" ( ) ) -:args_next -shift +if /I "%~0" == "new" ( + if not defined SBT_ARGS ( + set sbt_new=true + ) +) + +if /I "%g:~0,2%" == "-D" ( + rem special handling for -D since '=' gets parsed away + if x%g:^==% == x%g% ( + if not "%~1" == "" ( + set SBT_ARGS=!SBT_ARGS! %0=%1 + shift + goto args_loop + ) else ( + echo %g is missing a value + goto error + ) + ) +) + +rem the %0 (instead of %~0) preserves original argument quoting +set SBT_ARGS=!SBT_ARGS! %0 + goto args_loop :args_end rem Confirm a user's intent if the current directory does not look like an sbt rem top-level directory and the "new" command was not given. -if not exist build.sbt ( + +rem TODO: if not -sbt-create + +if not defined sbt_args_sbt_create if not defined sbt_args_print_version if not defined sbt_args_print_sbt_version if not defined sbt_args_print_sbt_script_version if not exist build.sbt ( if not exist project\ ( if not defined sbt_new ( echo [warn] Neither build.sbt nor a 'project' directory in the current directory: %CD% @@ -146,7 +404,7 @@ if not exist build.sbt ( echo c^) continue echo q^) quit - set /P reply=?^ + set /P reply=?^ if /I "!reply!" == "c" ( goto confirm_end ) else if /I "!reply!" == "q" ( @@ -172,59 +430,241 @@ if defined JVM_DEBUG_PORT ( call :sync_preloaded -call :run %SBT_ARGS% +call :run !SBT_ARGS! if ERRORLEVEL 1 goto error goto end :run -if "%SBT_VERBOSE%" == "true" ( + +rem set arguments + +if defined sbt_args_no_colors ( + set _SBT_OPTS=-Dsbt.log.noformat=true !_SBT_OPTS! +) + +if defined sbt_args_no_global ( + set _SBT_OPTS=-Dsbt.global.base=project/.sbtboot !_SBT_OPTS! +) + +if defined sbt_args_no_share ( + set _SBT_OPTS=-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy !_SBT_OPTS! +) + +if defined sbt_args_supershell ( + set _SBT_OPTS=-Dsbt.supershell=!sbt_args_supershell! !_SBT_OPTS! +) + +if defined sbt_args_sbt_version ( + set _SBT_OPTS=-Dsbt.version=!sbt_args_sbt_version! !_SBT_OPTS! +) + +if defined sbt_args_sbt_dir ( + set _SBT_OPTS=-Dsbt.global.base=!sbt_args_sbt_dir! !_SBT_OPTS! +) + +if defined sbt_args_sbt_boot ( + set _SBT_OPTS=-Dsbt.boot.directory=!sbt_args_sbt_boot! !_SBT_OPTS! +) + +if defined sbt_args_ivy ( + set _SBT_OPTS=-Dsbt.ivy.home=!sbt_args_ivy! !_SBT_OPTS! +) + +if defined sbt_args_color ( + set _SBT_OPTS=-Dsbt.color=!sbt_args_color! !_SBT_OPTS! +) + +if defined sbt_args_mem ( + call :addMemory !sbt_args_mem! +) else ( + call :addDefaultMemory +) + +if defined sbt_args_timings ( + set _SBT_OPTS=-Dsbt.task.timings=true -Dsbt.task.timings.on.shutdown=true !_SBT_OPTS! +) + +if defined sbt_args_traces ( + set _SBT_OPTS=-Dsbt.traces=true !_SBT_OPTS! +) + +rem TODO: _SBT_OPTS needs to be processed as args and diffed against SBT_ARGS + +if !sbt_args_print_sbt_script_version! equ 1 ( + echo !init_sbt_version! + goto :eof +) + +if !sbt_args_print_sbt_version! equ 1 ( + call :set_sbt_version + echo !sbt_version! + goto :eof +) + +if !sbt_args_print_version! equ 1 ( + call :set_sbt_version + echo sbt version in this project: !sbt_version! + echo sbt script version: !init_sbt_version! + goto :eof +) + +if defined sbt_args_verbose ( echo # Executing command line: - echo "%_JAVACMD%" - if not "%_JAVA_OPTS%" == "" ( call :echolist %_JAVA_OPTS% ) - if not "%SBT_OPTS%" == "" ( call :echolist %SBT_OPTS% ) - echo -cp "%SBT_HOME%sbt-launch.jar" - echo xsbt.boot.Boot - if not "%*" == "" ( call :echolist %* ) + echo "!_JAVACMD!" + if defined _JAVA_OPTS ( call :echolist !_JAVA_OPTS! ) + if defined _SBT_OPTS ( call :echolist !_SBT_OPTS! ) + echo -cp "!SBT_HOME!\bin\sbt-launch.jar" xsbt.boot.Boot + if defined %* ( call :echolist %* ) echo. ) -"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%sbt-launch.jar" xsbt.boot.Boot %* +"!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -cp "!SBT_HOME!\bin\sbt-launch.jar" xsbt.boot.Boot %* + goto :eof +rem for expression tries to interpret files, so simply loop over %* instead +rem fixes dealing with quotes after = args: -Dscala.ext.dirs="C:\Users\First Last\.sbt\0.13\java9-rt-ext-adoptopenjdk_11_0_3" :echolist -for /F "tokens=1*" %%g in ("%*") do ( - echo %%g - if not x%%h == x call :echolist %%h +rem call method is in first call of %0 +shift + +if [%0] EQU [] goto echolist_end +set "p=%0" + +rem special handling for -D since '=' gets parsed away +if /I "%p:~0,2%" == "-D" ( + rem if "-Dscala.ext.dirs" (replace all = with nothing) == "-Dscala.ext.dirs" + rem (e.g. verify it doesn't have the = already) + if x%p:^==% == x%p% if not "%~1" == "" ( + echo %0=%1 + shift + goto echolist + ) ) + +echo %0 +goto echolist + +:echolist_end + +exit /B 0 + +:addJava + call :dlog [addJava] arg = '%*' + set "_JAVA_OPTS=!_JAVA_OPTS! %*" +exit /B 0 + +:addMemory + call :dlog [addMemory] arg = '%*' + + rem evict memory related options + set _new_java_opts= + + for /F %%g in ("!_JAVA_OPTS!") do ( + set "p=%%g" + if not "!p:~0,4!" == "-Xmx" if not "!p:~0,4!" == "-Xms" if not "!p:~0,15!" == "-XX:MaxPermSize" if not "!p:~0,20!" == "-XX:MaxMetaspaceSize" if not "!p:~0,25!" == "-XX:ReservedCodeCacheSize" ( + set _new_java_opts=!_new_java_opts! %%g + ) + ) + set _JAVA_OPTS=!_new_java_opts! + + set _new_sbt_opts= + + for /F %%g in ("!_SBT_OPTS!") do ( + set "p=%%g" + if not "!p:~0,4!" == "-Xmx" if not "!p:~0,4!" == "-Xms" if not "!p:~0,15!" == "-XX:MaxPermSize" if not "!p:~0,20!" == "-XX:MaxMetaspaceSize" if not "!p:~0,25!" == "-XX:ReservedCodeCacheSize" ( + set _new_sbt_opts=!_new_sbt_opts! %%g + ) + ) + + set _SBT_OPTS=!_new_sbt_opts! + + rem a ham-fisted attempt to move some memory settings in concert + set mem=%1 + set /a codecache=!mem! / 8 + if !codecache! GEQ 512 set /a codecache=512 + if !codecache! LEQ 128 set /a codecache=128 + + set /a class_metadata_size=!codecache! * 2 + + call :addJava -Xms!mem!m + call :addJava -Xmx!mem!m + call :addJava -Xss4M + call :addJava -XX:ReservedCodeCacheSize=!codecache!m + + if /I !JAVA_VERSION! LSS 8 ( + call :addJava -XX:MaxPermSize=!class_metadata_size!m + ) + +exit /B 0 + +:addDefaultMemory + rem if we detect any of these settings in ${JAVA_OPTS} or ${JAVA_TOOL_OPTIONS} we need to NOT output our settings. + rem The reason is the Xms/Xmx, if they don't line up, cause errors. + + set _has_memory_args= + + if defined _JAVA_OPTS for /F %%g in ("!_JAVA_OPTS!") do ( + set "p=%%g" + if "!p:~0,4!" == "-Xmx" set _has_memory_args=1 + if "!p:~0,4!" == "-Xms" set _has_memory_args=1 + ) + + if defined JAVA_TOOL_OPTIONS for /F %%g in ("%JAVA_TOOL_OPTIONS%") do ( + set "p=%%g" + if "!p:~0,4!" == "-Xmx" set _has_memory_args=1 + if "!p:~0,4!" == "-Xms" set _has_memory_args=1 + ) + + if defined _SBT_OPTS for /F %%g in ("!_SBT_OPTS!") do ( + set "p=%%g" + if "!p:~0,4!" == "-Xmx" set _has_memory_args=1 + if "!p:~0,4!" == "-Xms" set _has_memory_args=1 + ) + + if not defined _has_memory_args ( + call :addMemory !sbt_default_mem! + ) +exit /B 0 + +:dlog + if defined sbt_args_debug ( + echo %* 1>&2 + ) exit /B 0 :process rem Parses x out of 1.x; for example 8 out of java version 1.8.0_xx rem Otherwise, parses the major version; 9 out of java version 9-ea set JAVA_VERSION=0 -for /f "tokens=3" %%g in ('"%_JAVACMD%" -Xms32M -Xmx32M -version 2^>^&1 ^| findstr /i version') do ( + +for /f "tokens=3 usebackq" %%g in (`CALL "!_JAVACMD!" -Xms32M -Xmx32M -version 2^>^&1 ^| findstr /i version`) do ( set JAVA_VERSION=%%g ) -set JAVA_VERSION=%JAVA_VERSION:"=% -for /f "delims=.-_ tokens=1-2" %%v in ("%JAVA_VERSION%") do ( + +rem removes all quotes from JAVA_VERSION +set JAVA_VERSION=!JAVA_VERSION:"=! + +for /f "delims=.-_ tokens=1-2" %%v in ("!JAVA_VERSION!") do ( if /I "%%v" EQU "1" ( set JAVA_VERSION=%%w ) else ( set JAVA_VERSION=%%v ) ) + exit /B 0 :checkjava -set required_version=6 -if /I %JAVA_VERSION% GEQ %required_version% ( +set /a required_version=6 +if /I !JAVA_VERSION! GEQ !required_version! ( exit /B 0 ) echo. -echo The Java Development Kit (JDK) installation you have is not up to date. -echo sbt requires at least version %required_version%+, you have -echo version %JAVA_VERSION% +echo The Java Development Kit ^(JDK^) installation you have is not up to date. +echo sbt requires at least version !required_version!+, you have +echo version "!JAVA_VERSION!" echo. echo Please go to http://www.oracle.com/technetwork/java/javase/downloads/ and download echo a valid JDK and install before running sbt. @@ -232,43 +672,109 @@ echo. exit /B 1 :copyrt -if /I %JAVA_VERSION% GEQ 9 ( - set rtexport=!SBT_HOME!java9-rt-export.jar +if /I !JAVA_VERSION! GEQ 9 ( + set rtexport=!SBT_BIN_DIR!java9-rt-export.jar - "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "!rtexport!" --rt-ext-dir > "%TEMP%.\rtext.txt" + "!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -jar "!rtexport!" --rt-ext-dir > "%TEMP%.\rtext.txt" set /p java9_ext= < "%TEMP%.\rtext.txt" set java9_rt=!java9_ext!\rt.jar if not exist "!java9_rt!" ( mkdir "!java9_ext!" - "%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "!rtexport!" "!java9_rt!" + "!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -jar "!rtexport!" "!java9_rt!" ) set _JAVA_OPTS=!_JAVA_OPTS! -Dscala.ext.dirs="!java9_ext!" ) exit /B 0 :sync_preloaded -if "%INIT_SBT_VERSION%"=="" ( - rem FIXME: better %INIT_SBT_VERSION% detection - FOR /F "tokens=* USEBACKQ" %%F IN (`dir /b "%SBT_HOME%\..\lib\local-preloaded\org\scala-sbt\sbt" /B`) DO ( - SET INIT_SBT_VERSION=%%F +if [!init_sbt_version] == [] ( + rem FIXME: better !init_sbt_version! detection + FOR /F "tokens=* usebackq" %%F IN (`dir /b "!SBT_HOME!\lib\local-preloaded\org\scala-sbt\sbt" /B`) DO ( + SET init_sbt_version=%%F ) ) -set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org\scala-sbt\sbt\%INIT_SBT_VERSION%\" -if /I %JAVA_VERSION% GEQ 8 ( + +set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org\scala-sbt\sbt\!init_sbt_version!\" +if /I !JAVA_VERSION! GEQ 8 ( where robocopy >nul 2>nul - if %ERRORLEVEL% equ 0 ( - REM echo %PRELOAD_SBT_JAR% - if not exist %PRELOAD_SBT_JAR% ( - if exist "%SBT_HOME%\..\lib\local-preloaded\" ( - echo "about to robocopy" - robocopy "%SBT_HOME%\..\lib\local-preloaded" "%UserProfile%\.sbt\preloaded" /E + if %ERRORLEVEL% EQU 0 ( + if not exist !PRELOAD_SBT_JAR! ( + if exist "!SBT_HOME!\lib\local-preloaded\" ( + robocopy "!SBT_HOME!\lib\local-preloaded" "%UserProfile%\.sbt\preloaded" /E ) ) ) ) exit /B 0 +:usage + +for /f "tokens=3 usebackq" %%g in (`CALL "!_JAVACMD!" -Xms32M -Xmx32M -version 2^>^&1 ^| findstr /i version`) do ( + set FULL_JAVA_VERSION=%%g +) + +echo. +echo Usage: %~n0 [options] +echo. +echo -h ^| --help print this message +echo -v ^| --verbose this runner is chattier +echo -V ^| --version print sbt version information +echo --numeric-version print the numeric sbt version (sbt sbtVersion) +echo --script-version print the version of sbt script +echo -d ^| --debug set sbt log level to debug +echo --no-colors disable ANSI color codes +echo --color=auto^|always^|true^|false^|never +echo enable or disable ANSI color codes ^(sbt 1.3 and above^) +echo --supershell=auto^|always^|true^|false^|never +echo enable or disable supershell ^(sbt 1.3 and above^) +echo --traces generate Trace Event report on shutdown ^(sbt 1.3 and above^) +echo --timings display task timings report on shutdown +echo --sbt-create start sbt even if current directory contains no sbt project +echo --sbt-dir ^ path to global settings/plugins directory ^(default: ~/.sbt^) +echo --sbt-boot ^ path to shared boot directory ^(default: ~/.sbt/boot in 0.11 series^) +echo --ivy ^ path to local Ivy repository ^(default: ~/.ivy2^) +echo --mem ^ set memory options ^(default: %sbt_default_mem%^) +echo --no-share use all local caches; no sharing +echo --no-global uses global caches, but does not use global ~/.sbt directory. +echo --jvm-debug ^ enable on JVM debugging, open at the given port. +rem echo --batch disable interactive mode +echo. +echo # sbt version ^(default: from project/build.properties if present, else latest release^) +echo --sbt-version ^ use the specified version of sbt +rem echo --sbt-jar ^ use the specified jar as the sbt launcher +rem echo --sbt-rc use an RC version of sbt +rem echo --sbt-snapshot use a snapshot version of sbt +echo. +echo # java version ^(default: java from PATH, currently !FULL_JAVA_VERSION!^) +echo --java-home ^ alternate JAVA_HOME +echo. +echo # jvm options and output control +echo JAVA_OPTS environment variable, if unset uses "!default_java_opts!" +echo .jvmopts if this file exists in the current directory, its contents +echo are appended to JAVA_OPTS +echo SBT_OPTS environment variable, if unset uses "!default_sbt_opts!" +echo .sbtopts if this file exists in the current directory, its contents +echo are prepended to the runner args +echo !SBT_CONFIG! +echo if this file exists, it is prepended to the runner args +echo -Dkey=val pass -Dkey=val directly to the java runtime +rem echo -J-X pass option -X directly to the java runtime +rem echo ^(-J is stripped^) +rem echo -S-X add -X to sbt's scalacOptions ^(-S is stripped^) +echo. +echo In the case of duplicated or conflicting options, the order above +echo shows precedence: JAVA_OPTS lowest, command line options highest. +echo. + +@endlocal +exit /B 1 + +:set_sbt_version +rem print sbtVersion +for /F "usebackq tokens=2" %%G in (`CALL "!_JAVACMD!" -jar "!SBT_HOME!\bin\sbt-launch.jar" "sbtVersion" 2^>^&1`) do set "sbt_version=%%G" +exit /B 0 + :error @endlocal exit /B 1 diff --git a/src/universal/conf/sbtconfig.txt b/src/universal/conf/sbtconfig.txt old mode 100644 new mode 100755 index 50395e227..9226e252d --- a/src/universal/conf/sbtconfig.txt +++ b/src/universal/conf/sbtconfig.txt @@ -2,10 +2,12 @@ # Set the java args --Xms1024m --Xmx1024m --Xss4M --XX:ReservedCodeCacheSize=128m +#-mem 1024 was added in sbt.bat as default + +#-Xms1024m +#-Xmx1024m +#-Xss4M +#-XX:ReservedCodeCacheSize=128m # Set the extra sbt options From f3b9d7572e1c90a43d17117eb8fffeb1ac51189b Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Thu, 10 Oct 2019 10:42:17 -0700 Subject: [PATCH 397/483] Add usage for --debug-inc to bash sbt, add impl to sbt.bat --- integration-test/src/test/scala/RunnerTest.scala | 6 ++++++ src/universal/bin/sbt | 2 ++ src/universal/bin/sbt.bat | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) mode change 100644 => 100755 src/universal/bin/sbt.bat diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 314514f1a..eaec670f0 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -44,6 +44,12 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } + test("sbt --debug-inc") { + val out = sbtProcess("compile --debug-inc -v").!!.linesIterator.toList + assert(out.contains[String]("-Dxsbt.inc.debug=true")) + () + } + test("sbt --supershell=never") { val out = sbtProcess("compile --supershell=never -v").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.supershell=never")) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 1a42143ab..60fe5eeab 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -424,6 +424,8 @@ Usage: `basename "$0"` [options] --numeric-version print the numeric sbt version (sbt sbtVersion) --script-version print the version of sbt script -d | --debug set sbt log level to debug + -debug-inc | --debug-inc + enable extra debugging for the incremental debugger --no-colors disable ANSI color codes --color=auto|always|true|false|never enable or disable ANSI color codes (sbt 1.3 and above) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat old mode 100644 new mode 100755 index 043ac450e..8ed637529 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -28,6 +28,7 @@ set sbt_args_print_sbt_version= set sbt_args_print_sbt_script_version= set sbt_args_verbose= set sbt_args_debug= +set sbt_args_debug_inc= set sbt_args_batch= set sbt_args_color= set sbt_args_no_colors= @@ -238,6 +239,15 @@ if defined _debug_arg ( goto args_loop ) +if "%~0" == "-debug-inc" set _debug_inc_arg=true +if "%~0" == "--debug-inc" set _debug_inc_arg=true + +if defined _debug_inc_arg ( + set _debug_inc_arg= + set sbt_args_debug_inc=1 + goto args_loop +) + if "%~0" == "--sbt-version" set _sbt_version_arg=true if "%~0" == "-sbt-version" set _sbt_version_arg=true @@ -439,6 +449,10 @@ goto end rem set arguments +if defined sbt_args_debug_inc ( + set _SBT_OPTS=-Dxsbt.inc.debug=true !_SBT_OPTS! +) + if defined sbt_args_no_colors ( set _SBT_OPTS=-Dsbt.log.noformat=true !_SBT_OPTS! ) @@ -723,6 +737,8 @@ echo -V ^| --version print sbt version information echo --numeric-version print the numeric sbt version (sbt sbtVersion) echo --script-version print the version of sbt script echo -d ^| --debug set sbt log level to debug +echo -debug-inc ^| --debug-inc +echo enable extra debugging for the incremental debugger echo --no-colors disable ANSI color codes echo --color=auto^|always^|true^|false^|never echo enable or disable ANSI color codes ^(sbt 1.3 and above^) From c2bac898df4f8e61f8ef40eb2be68fcac874aa7c Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 14 Oct 2019 02:59:34 -0400 Subject: [PATCH 398/483] bump JAnsi --- build.sbt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index f08475da8..2b8f7d072 100755 --- a/build.sbt +++ b/build.sbt @@ -16,14 +16,14 @@ lazy val sbtVersionToRelease = sys.props.getOrElse("sbt.build.version", sys.env. })) lazy val scala210 = "2.10.7" -lazy val scala212 = "2.12.8" +lazy val scala212 = "2.12.10" lazy val scala210Jline = "org.scala-lang" % "jline" % scala210 lazy val jansi = { - if (sbtVersionToRelease startsWith "1.") "org.fusesource.jansi" % "jansi" % "1.4" + if (sbtVersionToRelease startsWith "1.") "org.fusesource.jansi" % "jansi" % "1.12" else "org.fusesource.jansi" % "jansi" % "1.4" } lazy val scala212Jline = "jline" % "jline" % "2.14.6" -lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6" +lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.2.0" lazy val scala212Compiler = "org.scala-lang" % "scala-compiler" % scala212 lazy val sbtActual = "org.scala-sbt" % "sbt" % sbtVersionToRelease @@ -245,7 +245,7 @@ val root = (project in file(".")). lazy val integrationTest = (project in file("integration-test")) .settings( name := "integration-test", - scalaVersion := "2.12.8", + scalaVersion := scala212, libraryDependencies ++= Seq( "io.monix" %% "minitest" % "2.3.2" % Test, "com.eed3si9n.expecty" %% "expecty" % "0.11.0" % Test, From ab001f55971c993f319a92a04cb85507c071b7c6 Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Tue, 15 Oct 2019 12:21:07 -0400 Subject: [PATCH 399/483] Fix typo around continue/quit Fixes https://github.com/sbt/sbt/issues/5188 --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 8ed637529..050cef76d 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -414,7 +414,7 @@ if not defined sbt_args_sbt_create if not defined sbt_args_print_version if not echo c^) continue echo q^) quit - set /P reply=?^ + set /P reply=^? if /I "!reply!" == "c" ( goto confirm_end ) else if /I "!reply!" == "q" ( From 546a8b8949b70f03181ce49695147650e06aa373 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 16 Oct 2019 10:45:33 -0400 Subject: [PATCH 400/483] Fix verbose output for SBT_ARGS --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 050cef76d..54f39259e 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -529,7 +529,7 @@ if defined sbt_args_verbose ( if defined _JAVA_OPTS ( call :echolist !_JAVA_OPTS! ) if defined _SBT_OPTS ( call :echolist !_SBT_OPTS! ) echo -cp "!SBT_HOME!\bin\sbt-launch.jar" xsbt.boot.Boot - if defined %* ( call :echolist %* ) + if not "%*" == "" ( call :echolist %* ) echo. ) From 71a216c03757260c0a5a4f7f1d5f3a4cf776e7ca Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 16 Oct 2019 10:48:11 -0400 Subject: [PATCH 401/483] Fix -D with quotes Fixe https://github.com/sbt/sbt/issues/5192 --- src/universal/bin/sbt.bat | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 54f39259e..33d3adbf1 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -381,17 +381,22 @@ if /I "%~0" == "new" ( ) if /I "%g:~0,2%" == "-D" ( - rem special handling for -D since '=' gets parsed away - if x%g:^==% == x%g% ( - if not "%~1" == "" ( - set SBT_ARGS=!SBT_ARGS! %0=%1 - shift - goto args_loop - ) else ( - echo %g is missing a value - goto error - ) - ) + rem special handling for -D since '=' gets parsed away + echo "%g%" | find "=" > null + if ERRORLEVEL 1 ( + if not "%~1" == "" ( + set SBT_ARGS=!SBT_ARGS! %0=%1 + shift + goto args_loop + ) else ( + echo %g% is missing a value + goto error + ) + ) else ( + set SBT_ARGS=!SBT_ARGS! %~0 + echo found !SBT_ARGS! + goto args_loop + ) ) rem the %0 (instead of %~0) preserves original argument quoting @@ -550,7 +555,8 @@ rem special handling for -D since '=' gets parsed away if /I "%p:~0,2%" == "-D" ( rem if "-Dscala.ext.dirs" (replace all = with nothing) == "-Dscala.ext.dirs" rem (e.g. verify it doesn't have the = already) - if x%p:^==% == x%p% if not "%~1" == "" ( + + if "x%p:^==%" == "x%p%" if not "%~1" == "" ( echo %0=%1 shift goto echolist From 6ebad1cffca279aae134202c8e977bb5f0641ed1 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Wed, 16 Oct 2019 06:23:30 -0700 Subject: [PATCH 402/483] Add a test for -D arguments (e.g. -Dsbt.supershell=false) --- integration-test/src/test/scala/RunnerTest.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index eaec670f0..655eeb661 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -62,6 +62,12 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } + test("sbt -D arguments") { + val out = sbtProcess("-Dsbt.supershell=false compile -v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.supershell=false")) + () + } + test("sbt --sbt-version") { val out = sbtProcess("--sbt-version 1.3.0 compile -v").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.version=1.3.0")) From 00e5224fdefdfb1ee9bcfbacb1a4ff86be6819d3 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 16 Oct 2019 10:53:49 -0400 Subject: [PATCH 403/483] Add debugging for -D parsing --- src/universal/bin/sbt.bat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 33d3adbf1..20b9fd54f 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -385,7 +385,8 @@ if /I "%g:~0,2%" == "-D" ( echo "%g%" | find "=" > null if ERRORLEVEL 1 ( if not "%~1" == "" ( - set SBT_ARGS=!SBT_ARGS! %0=%1 + call :dlog [args_loop] -D argument %~0=%~1 + set "SBT_ARGS=!SBT_ARGS! %~0=%~1" shift goto args_loop ) else ( @@ -393,7 +394,8 @@ if /I "%g:~0,2%" == "-D" ( goto error ) ) else ( - set SBT_ARGS=!SBT_ARGS! %~0 + call :dlog [args_loop] -D argument %~0 + set "SBT_ARGS=!SBT_ARGS! %~0" echo found !SBT_ARGS! goto args_loop ) From 7d7e01015f592e9e9acb028527524cf427be3664 Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Wed, 16 Oct 2019 11:54:22 -0400 Subject: [PATCH 404/483] Update src/universal/bin/sbt.bat Co-Authored-By: Eric Peters --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 20b9fd54f..4bae4f7ad 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -380,7 +380,7 @@ if /I "%~0" == "new" ( ) ) -if /I "%g:~0,2%" == "-D" ( +if "%g:~0,2%" == "-D" ( rem special handling for -D since '=' gets parsed away echo "%g%" | find "=" > null if ERRORLEVEL 1 ( From 3953c80c736e8db7b8e51586785ea07a3d52c03c Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Wed, 16 Oct 2019 11:56:43 -0400 Subject: [PATCH 405/483] Update src/universal/bin/sbt.bat Co-Authored-By: Eric Peters --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 4bae4f7ad..2fdeb2f43 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -536,7 +536,7 @@ if defined sbt_args_verbose ( if defined _JAVA_OPTS ( call :echolist !_JAVA_OPTS! ) if defined _SBT_OPTS ( call :echolist !_SBT_OPTS! ) echo -cp "!SBT_HOME!\bin\sbt-launch.jar" xsbt.boot.Boot - if not "%*" == "" ( call :echolist %* ) + if not [%~1] == [] ( call :echolist %* ) echo. ) From 689fdd682aa4708c843998eaed5462c25dc0820f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 16 Oct 2019 12:00:47 -0400 Subject: [PATCH 406/483] remove unnecessary /I --- src/universal/bin/sbt.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 2fdeb2f43..a9fc1617e 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -374,7 +374,7 @@ if defined _java_home_arg ( ) ) -if /I "%~0" == "new" ( +if "%~0" == "new" ( if not defined SBT_ARGS ( set sbt_new=true ) @@ -554,7 +554,7 @@ if [%0] EQU [] goto echolist_end set "p=%0" rem special handling for -D since '=' gets parsed away -if /I "%p:~0,2%" == "-D" ( +if "%p:~0,2%" == "-D" ( rem if "-Dscala.ext.dirs" (replace all = with nothing) == "-Dscala.ext.dirs" rem (e.g. verify it doesn't have the = already) From 9471fab91b0c18b16870a5ad8149ea47b708441d Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 16 Oct 2019 13:18:58 -0400 Subject: [PATCH 407/483] Remove debug echo --- src/universal/bin/sbt.bat | 1 - 1 file changed, 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index a9fc1617e..8ebfbb0ee 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -396,7 +396,6 @@ if "%g:~0,2%" == "-D" ( ) else ( call :dlog [args_loop] -D argument %~0 set "SBT_ARGS=!SBT_ARGS! %~0" - echo found !SBT_ARGS! goto args_loop ) ) From 1249bf4d8efcb5bb16e9bf8c3982423bbd1c92fd Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Sat, 19 Oct 2019 11:49:16 -0700 Subject: [PATCH 408/483] Run the full integrationTest/test on OSX --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 34e3c8e3f..20da207be 100755 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ matrix: - java -Xmx32m -version - unset SBT_OPTS script: - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - cd citest && ./test.sh - name: "build using JDK 8 test using JDK 8" From b04ecd9427bb3f312e7d06f604a9fed581074753 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Sat, 19 Oct 2019 12:13:08 -0700 Subject: [PATCH 409/483] Update javacOptions to target 1.8 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 2b8f7d072..c3b2d71d0 100755 --- a/build.sbt +++ b/build.sbt @@ -163,7 +163,7 @@ val root = (project in file(".")). packageDescription in Windows := "The interactive build tool.", wixProductId := "ce07be71-510d-414a-92d4-dff47631848a", wixProductUpgradeId := Hash.toHex(Hash((version in Windows).value)).take(32), - javacOptions := Seq("-source", "1.5", "-target", "1.5"), + javacOptions := Seq("-source", "1.8", "-target", "1.8"), // Universal ZIP download install. packageName in Universal := packageName.value, // needs to be set explicitly due to a bug in native-packager From d7d780e16effa428d995d7fa798423903b27f2d4 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Sat, 19 Oct 2019 12:21:35 -0700 Subject: [PATCH 410/483] Add IntelliJ run configuration for integrationTest/test --- .idea/runConfigurations/Run_integrationTest_test.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .idea/runConfigurations/Run_integrationTest_test.xml diff --git a/.idea/runConfigurations/Run_integrationTest_test.xml b/.idea/runConfigurations/Run_integrationTest_test.xml new file mode 100644 index 000000000..3d96baea8 --- /dev/null +++ b/.idea/runConfigurations/Run_integrationTest_test.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file From 819ee47071de5e7979d9416cbc1396b30801929d Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Sat, 19 Oct 2019 18:34:13 -0700 Subject: [PATCH 411/483] Remove unimplemented --sbt-rc and --sbt-snapshot arguments from docs and scripts --- README.md | 2 -- src/linux/usr/share/man/man1/sbt.1 | 4 ---- src/universal/bin/sbt | 2 -- src/universal/bin/sbt.bat | 2 -- 4 files changed, 10 deletions(-) diff --git a/README.md b/README.md index 2bb597383..9551dd528 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,6 @@ Usage: sbt [options] # sbt version (default: from project/build.properties if present, else latest release) -sbt-version use the specified version of sbt -sbt-jar use the specified jar as the sbt launcher - -sbt-rc use an RC version of sbt - -sbt-snapshot use a snapshot version of sbt # java version (default: java from PATH, currently openjdk version "1.8.0_172") -java-home alternate JAVA_HOME diff --git a/src/linux/usr/share/man/man1/sbt.1 b/src/linux/usr/share/man/man1/sbt.1 index 523b3fe56..914a99b50 100644 --- a/src/linux/usr/share/man/man1/sbt.1 +++ b/src/linux/usr/share/man/man1/sbt.1 @@ -57,10 +57,6 @@ Disable interactive mode Use the alternate system wide .IP "--sbt-jar " use the specified jar as the sbt launcher -.IP "--sbt-rc" -use an RC version of sbt -.IP --sbt-snapshot -use a snapshot version of sbt .SH Java Options .IP "--java-home " alternate JAVA_HOME diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 60fe5eeab..a95e916af 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -446,8 +446,6 @@ Usage: `basename "$0"` [options] # sbt version (default: from project/build.properties if present, else latest release) --sbt-version use the specified version of sbt --sbt-jar use the specified jar as the sbt launcher - --sbt-rc use an RC version of sbt - --sbt-snapshot use a snapshot version of sbt # java version (default: java from PATH, currently $(java -version 2>&1 | grep version)) --java-home alternate JAVA_HOME diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 8ebfbb0ee..ed74da0e5 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -766,8 +766,6 @@ echo. echo # sbt version ^(default: from project/build.properties if present, else latest release^) echo --sbt-version ^ use the specified version of sbt rem echo --sbt-jar ^ use the specified jar as the sbt launcher -rem echo --sbt-rc use an RC version of sbt -rem echo --sbt-snapshot use a snapshot version of sbt echo. echo # java version ^(default: java from PATH, currently !FULL_JAVA_VERSION!^) echo --java-home ^ alternate JAVA_HOME From 5991e803af37c88ed2eaaeef8f6848cd86164821 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Sat, 19 Oct 2019 19:05:06 -0700 Subject: [PATCH 412/483] Add --sbt-jar test and windows sbt.bat support --- .../src/test/scala/RunnerTest.scala | 8 ++++ src/universal/bin/sbt.bat | 46 ++++++++++++++++--- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 655eeb661..659c06406 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -137,4 +137,12 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { assert(out.matches(expectedVersion)) () } + + test("sbt --sbt-jar should run") { + val out = sbtProcess("compile -v --sbt-jar ../target/universal/stage/bin/sbt-launch.jar").!!.linesIterator.toList + assert(out.contains[String]("../target/universal/stage/bin/sbt-launch.jar") || + out.contains[String]("\"../target/universal/stage/bin/sbt-launch.jar\"") + ) + () + } } diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index ed74da0e5..577a2adac 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -22,6 +22,7 @@ set init_sbt_version=_to_be_replaced set sbt_default_mem=1024 set default_sbt_opts= set default_java_opts=-Dfile.encoding=UTF-8 +set sbt_jar= set sbt_args_print_version= set sbt_args_print_sbt_version= @@ -34,6 +35,7 @@ set sbt_args_color= set sbt_args_no_colors= set sbt_args_no_global= set sbt_args_no_share= +set sbt_args_sbt_jar= set sbt_args_ivy= set sbt_args_supershell= set sbt_args_timings= @@ -214,6 +216,26 @@ if defined _sbt_boot_arg ( ) ) +if "%~0" == "-sbt-jar" set _sbt_jar=true +if "%~0" == "--sbt-jar" set _sbt_jar=true + +if defined _sbt_jar ( + set _sbt_jar= + if not "%~1" == "" ( + if exist "%~1" ( + set sbt_args_sbt_jar=%1 + shift + goto args_loop + ) else ( + echo %~1 does not exist + goto error + ) + ) else ( + echo "%~0" is missing a value + goto error + ) +) + if "%~0" == "-ivy" set _sbt_ivy_arg=true if "%~0" == "--ivy" set _sbt_ivy_arg=true @@ -509,6 +531,14 @@ if defined sbt_args_traces ( set _SBT_OPTS=-Dsbt.traces=true !_SBT_OPTS! ) +if defined sbt_args_sbt_jar ( + set "sbt_jar=!sbt_args_sbt_jar!" +) else ( + set "sbt_jar=!SBT_HOME!\bin\sbt-launch.jar" +) + +set sbt_jar=!sbt_jar:"=! + rem TODO: _SBT_OPTS needs to be processed as args and diffed against SBT_ARGS if !sbt_args_print_sbt_script_version! equ 1 ( @@ -534,12 +564,14 @@ if defined sbt_args_verbose ( echo "!_JAVACMD!" if defined _JAVA_OPTS ( call :echolist !_JAVA_OPTS! ) if defined _SBT_OPTS ( call :echolist !_SBT_OPTS! ) - echo -cp "!SBT_HOME!\bin\sbt-launch.jar" xsbt.boot.Boot + echo -cp + echo "!sbt_jar!" + echo xsbt.boot.Boot if not [%~1] == [] ( call :echolist %* ) echo. ) -"!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -cp "!SBT_HOME!\bin\sbt-launch.jar" xsbt.boot.Boot %* +"!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -cp "!sbt_jar!" xsbt.boot.Boot %* goto :eof @@ -694,11 +726,11 @@ exit /B 1 :copyrt if /I !JAVA_VERSION! GEQ 9 ( - set rtexport=!SBT_BIN_DIR!java9-rt-export.jar + set "rtexport=!SBT_BIN_DIR!java9-rt-export.jar" "!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -jar "!rtexport!" --rt-ext-dir > "%TEMP%.\rtext.txt" set /p java9_ext= < "%TEMP%.\rtext.txt" - set java9_rt=!java9_ext!\rt.jar + set "java9_rt=!java9_ext!\rt.jar" if not exist "!java9_rt!" ( mkdir "!java9_ext!" @@ -765,7 +797,7 @@ rem echo --batch disable interactive mode echo. echo # sbt version ^(default: from project/build.properties if present, else latest release^) echo --sbt-version ^ use the specified version of sbt -rem echo --sbt-jar ^ use the specified jar as the sbt launcher +echo --sbt-jar ^ use the specified jar as the sbt launcher echo. echo # java version ^(default: java from PATH, currently !FULL_JAVA_VERSION!^) echo --java-home ^ alternate JAVA_HOME @@ -792,8 +824,8 @@ echo. exit /B 1 :set_sbt_version -rem print sbtVersion -for /F "usebackq tokens=2" %%G in (`CALL "!_JAVACMD!" -jar "!SBT_HOME!\bin\sbt-launch.jar" "sbtVersion" 2^>^&1`) do set "sbt_version=%%G" +rem set project sbtVersion +for /F "usebackq tokens=2" %%G in (`CALL "!_JAVACMD!" -jar "!sbt_jar!" "sbtVersion" 2^>^&1`) do set "sbt_version=%%G" exit /B 0 :error From 978ea3967629801ad574d42214704a09a02feeb8 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Sat, 19 Oct 2019 21:01:03 -0700 Subject: [PATCH 413/483] Make the script version regex test more windows-friendly --- integration-test/src/test/scala/RunnerTest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 659c06406..d810f9475 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -111,7 +111,7 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { test("sbt -V|-version|--version should print sbtVersion") { val out = sbtProcessWithOpts("-version", "", "").!!.trim val expectedVersion = - s"""|(?m)^sbt version in this project: $versionRegEx + s"""|(?m)^sbt version in this project: $versionRegEx(\\r)? |sbt script version: $versionRegEx$$ |""".stripMargin.trim.replace("\n", "\\n") assert(out.matches(expectedVersion)) From fe43d0b975b05d658d1443adbaa339e757a8d009 Mon Sep 17 00:00:00 2001 From: Michael Hsu Date: Fri, 8 Nov 2019 10:23:53 +0800 Subject: [PATCH 414/483] Add special handling for -XX Fix special handling for -D where > null should be > nul Fix the problem that only the first option of SBT_OPTS and JAVA_OPTS got processed --- src/universal/bin/sbt.bat | 67 +++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 577a2adac..547f7c000 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -49,7 +49,11 @@ rem users can set SBT_OPTS via .sbtopts if exist .sbtopts for /F %%A in (.sbtopts) do ( set _sbtopts_line=%%A if not "!_sbtopts_line:~0,1!" == "#" ( - set _SBT_OPTS=%%A %SBT_OPTS% + if defined _SBT_OPTS ( + set _SBT_OPTS=!_SBT_OPTS! %%A + ) else ( + set _SBT_OPTS=%%A + ) ) ) @@ -404,7 +408,7 @@ if "%~0" == "new" ( if "%g:~0,2%" == "-D" ( rem special handling for -D since '=' gets parsed away - echo "%g%" | find "=" > null + echo "%g%" | find "=" > nul if ERRORLEVEL 1 ( if not "%~1" == "" ( call :dlog [args_loop] -D argument %~0=%~1 @@ -422,6 +426,26 @@ if "%g:~0,2%" == "-D" ( ) ) +if "%g:~0,3%" == "-XX" ( + rem special handling for -XX since '=' gets parsed away + echo "%g%" | find "=" > nul + if ERRORLEVEL 1 ( + if not "%~1" == "" ( + call :dlog [args_loop] -XX argument %~0=%~1 + set "SBT_ARGS=!SBT_ARGS! %~0=%~1" + shift + goto args_loop + ) else ( + echo %g% is missing a value + goto error + ) + ) else ( + call :dlog [args_loop] -XX argument %~0 + set "SBT_ARGS=!SBT_ARGS! %~0" + goto args_loop + ) +) + rem the %0 (instead of %~0) preserves original argument quoting set SBT_ARGS=!SBT_ARGS! %0 @@ -584,16 +608,24 @@ shift if [%0] EQU [] goto echolist_end set "p=%0" -rem special handling for -D since '=' gets parsed away if "%p:~0,2%" == "-D" ( - rem if "-Dscala.ext.dirs" (replace all = with nothing) == "-Dscala.ext.dirs" - rem (e.g. verify it doesn't have the = already) - - if "x%p:^==%" == "x%p%" if not "%~1" == "" ( + rem special handling for -D since '=' gets parsed away + echo "%p%" | find "=" > nul + if ERRORLEVEL 1 if not "%~1" == "" ( echo %0=%1 shift goto echolist - ) + ) +) + +if "%p:~0,3%" == "-XX" ( + rem special handling for -D since '=' gets parsed away + echo "%p%" | find "=" > nul + if ERRORLEVEL 1 if not "%~1" == "" ( + echo %0=%1 + shift + goto echolist + ) ) echo %0 @@ -613,24 +645,33 @@ exit /B 0 rem evict memory related options set _new_java_opts= - - for /F %%g in ("!_JAVA_OPTS!") do ( + set _old_java_opts=!_JAVA_OPTS! +:next_java_opt + if "!_old_java_opts!" == "" goto :done_java_opt + for /F "tokens=1,*" %%g in ("!_old_java_opts!") do ( set "p=%%g" if not "!p:~0,4!" == "-Xmx" if not "!p:~0,4!" == "-Xms" if not "!p:~0,15!" == "-XX:MaxPermSize" if not "!p:~0,20!" == "-XX:MaxMetaspaceSize" if not "!p:~0,25!" == "-XX:ReservedCodeCacheSize" ( set _new_java_opts=!_new_java_opts! %%g ) + set "_old_java_opts=%%h" ) + goto :next_java_opt +:done_java_opt set _JAVA_OPTS=!_new_java_opts! set _new_sbt_opts= - - for /F %%g in ("!_SBT_OPTS!") do ( + set _old_sbt_opts=!_SBT_OPTS! +:next_sbt_opt + if "!_old_sbt_opts!" == "" goto :done_sbt_opt + for /F "tokens=1,*" %%g in ("!_old_sbt_opts!") do ( set "p=%%g" if not "!p:~0,4!" == "-Xmx" if not "!p:~0,4!" == "-Xms" if not "!p:~0,15!" == "-XX:MaxPermSize" if not "!p:~0,20!" == "-XX:MaxMetaspaceSize" if not "!p:~0,25!" == "-XX:ReservedCodeCacheSize" ( set _new_sbt_opts=!_new_sbt_opts! %%g ) + set "_old_sbt_opts=%%h" ) - + goto :next_sbt_opt +:done_sbt_opt set _SBT_OPTS=!_new_sbt_opts! rem a ham-fisted attempt to move some memory settings in concert From c742f66dd861e70c89dd86970057b42f65765047 Mon Sep 17 00:00:00 2001 From: Michael Hsu Date: Sat, 9 Nov 2019 22:44:13 +0800 Subject: [PATCH 415/483] Add tests for -XX and mutiple -D --- integration-test/src/test/scala/RunnerTest.scala | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index d810f9475..fd8b3a0dd 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -95,12 +95,25 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { } test("sbt with -Xms2048M -Xmx2048M -Xss6M in SBT_OPTS") { - if (isWindows) cancel("Test not supported on windows") val out = sbtProcessWithOpts("compile -v", "", "-Xms2048M -Xmx2048M -Xss6M").!!.linesIterator.toList assert(out.contains[String]("-Xss6M")) () } + test("sbt with -Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080 in SBT_OPTS") { + val out = sbtProcessWithOpts("compile -v", "", "-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080").!!.linesIterator.toList + assert(out.contains[String]("-Dhttp.proxyHost=proxy")) + assert(out.contains[String]("-Dhttp.proxyPort=8080")) + () + } + + test("sbt with -XX:ParallelGCThreads=16 -XX:PermSize=128M in SBT_OPTS") { + val out = sbtProcessWithOpts("compile -v", "", "-XX:ReservedCodeCacheSize=256m -XX:MaxPermSize=256m").!!.linesIterator.toList + assert(out.contains[String]("-XX:ParallelGCThreads=16")) + assert(out.contains[String]("-XX:PermSize=128M")) + () + } + test("sbt with --no-colors in SBT_OPTS") { if (isWindows) cancel("Test not supported on windows") val out = sbtProcessWithOpts("compile -v", "", "--no-colors").!!.linesIterator.toList From 34ca7297190c5f13a11fbebb8aa297949a28db56 Mon Sep 17 00:00:00 2001 From: Michael Hsu Date: Sun, 10 Nov 2019 20:46:55 +0800 Subject: [PATCH 416/483] Fix Travis CI error: find: '=': No such file or directory --- src/universal/bin/sbt.bat | 58 +++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 547f7c000..46fceb0a6 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -408,41 +408,45 @@ if "%~0" == "new" ( if "%g:~0,2%" == "-D" ( rem special handling for -D since '=' gets parsed away - echo "%g%" | find "=" > nul - if ERRORLEVEL 1 ( - if not "%~1" == "" ( - call :dlog [args_loop] -D argument %~0=%~1 - set "SBT_ARGS=!SBT_ARGS! %~0=%~1" - shift - goto args_loop + for /F "tokens=1 delims==" %%a in ("%g%") do ( + rem make sure it doesn't have the '=' already + if "%g%" == "%%a" ( + if not "%~1" == "" ( + call :dlog [args_loop] -D argument %~0=%~1 + set "SBT_ARGS=!SBT_ARGS! %~0=%~1" + shift + goto args_loop + ) else ( + echo %g% is missing a value + goto error + ) ) else ( - echo %g% is missing a value - goto error + call :dlog [args_loop] -D argument %~0 + set "SBT_ARGS=!SBT_ARGS! %~0" + goto args_loop ) - ) else ( - call :dlog [args_loop] -D argument %~0 - set "SBT_ARGS=!SBT_ARGS! %~0" - goto args_loop ) ) if "%g:~0,3%" == "-XX" ( - rem special handling for -XX since '=' gets parsed away - echo "%g%" | find "=" > nul - if ERRORLEVEL 1 ( - if not "%~1" == "" ( - call :dlog [args_loop] -XX argument %~0=%~1 - set "SBT_ARGS=!SBT_ARGS! %~0=%~1" - shift - goto args_loop + rem special handling for -D since '=' gets parsed away + for /F "tokens=1 delims==" %%a in ("%g%") do ( + rem make sure it doesn't have the '=' already + if "%g%" == "%%a" ( + if not "%~1" == "" ( + call :dlog [args_loop] -XX argument %~0=%~1 + set "SBT_ARGS=!SBT_ARGS! %~0=%~1" + shift + goto args_loop + ) else ( + echo %g% is missing a value + goto error + ) ) else ( - echo %g% is missing a value - goto error + call :dlog [args_loop] -XX argument %~0 + set "SBT_ARGS=!SBT_ARGS! %~0" + goto args_loop ) - ) else ( - call :dlog [args_loop] -XX argument %~0 - set "SBT_ARGS=!SBT_ARGS! %~0" - goto args_loop ) ) From cb19634350401cede4d41e5a30a4286b8c25f71e Mon Sep 17 00:00:00 2001 From: Michael Hsu Date: Mon, 11 Nov 2019 10:56:10 +0800 Subject: [PATCH 417/483] Fix tests for -XX, then add test for -XX:+ and -XX:- --- .../src/test/scala/RunnerTest.scala | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index fd8b3a0dd..d3dc0c580 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -108,12 +108,28 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { } test("sbt with -XX:ParallelGCThreads=16 -XX:PermSize=128M in SBT_OPTS") { - val out = sbtProcessWithOpts("compile -v", "", "-XX:ReservedCodeCacheSize=256m -XX:MaxPermSize=256m").!!.linesIterator.toList + val out = sbtProcessWithOpts("compile -v", "", "-XX:ParallelGCThreads=16 -XX:PermSize=128M").!!.linesIterator.toList assert(out.contains[String]("-XX:ParallelGCThreads=16")) assert(out.contains[String]("-XX:PermSize=128M")) () } + test("sbt with -XX:+UseG1GC -XX:+PrintGC in SBT_OPTS") { + val out = sbtProcessWithOpts("compile -v", "", "-XX:+UseG1GC -XX:+PrintGC").!!.linesIterator.toList + assert(out.contains[String]("-XX:+UseG1GC")) + assert(out.contains[String]("-XX:+PrintGC")) + assert(!out.contains[String]("-XX:+UseG1GC=-XX:+PrintGC")) + () + } + + test("sbt with -XX:-UseG1GC -XX:-PrintGC in SBT_OPTS") { + val out = sbtProcessWithOpts("compile -v", "", "-XX:-UseG1GC -XX:-PrintGC").!!.linesIterator.toList + assert(out.contains[String]("-XX:-UseG1GC")) + assert(out.contains[String]("-XX:-PrintGC")) + assert(!out.contains[String]("-XX:-UseG1GC=-XX:-PrintGC")) + () + } + test("sbt with --no-colors in SBT_OPTS") { if (isWindows) cancel("Test not supported on windows") val out = sbtProcessWithOpts("compile -v", "", "--no-colors").!!.linesIterator.toList From 1318c0f59407a0034d8ac7e1f8910f676e705824 Mon Sep 17 00:00:00 2001 From: Michael Hsu Date: Mon, 11 Nov 2019 10:59:06 +0800 Subject: [PATCH 418/483] Add special handling for -XX, -XX:+ and -XX:0 --- src/universal/bin/sbt.bat | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 46fceb0a6..417b79ad3 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -428,8 +428,8 @@ if "%g:~0,2%" == "-D" ( ) ) -if "%g:~0,3%" == "-XX" ( - rem special handling for -D since '=' gets parsed away +if not "%g:~0,5%" == "-XX:+" if not "%g:~0,5%" == "-XX:-" if "%g:~0,3%" == "-XX" ( + rem special handling for -XX since '=' gets parsed away for /F "tokens=1 delims==" %%a in ("%g%") do ( rem make sure it doesn't have the '=' already if "%g%" == "%%a" ( @@ -614,21 +614,25 @@ set "p=%0" if "%p:~0,2%" == "-D" ( rem special handling for -D since '=' gets parsed away - echo "%p%" | find "=" > nul - if ERRORLEVEL 1 if not "%~1" == "" ( - echo %0=%1 - shift - goto echolist + for /F "tokens=1 delims==" %%a in ("%p%") do ( + rem make sure it doesn't have the '=' already + if "%p%" == "%%a" if not "%~1" == "" ( + echo %0=%1 + shift + goto echolist + ) ) ) -if "%p:~0,3%" == "-XX" ( - rem special handling for -D since '=' gets parsed away - echo "%p%" | find "=" > nul - if ERRORLEVEL 1 if not "%~1" == "" ( - echo %0=%1 - shift - goto echolist +if not "%p:~0,5%" == "-XX:+" if not "%p:~0,5%" == "-XX:-" if "%p:~0,3%" == "-XX" ( + rem special handling for -XX since '=' gets parsed away + for /F "tokens=1 delims==" %%a in ("%p%") do ( + rem make sure it doesn't have the '=' already + if "%p%" == "%%a" if not "%~1" == "" ( + echo %0=%1 + shift + goto echolist + ) ) ) From 63eabf3c8fd0e04a476df22a36879bb49f9bfddd Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Sun, 17 Nov 2019 08:32:28 -0800 Subject: [PATCH 419/483] Update sbt.bat --script-version to execute early and avoid java check/robocopy bootstrap - Fixes #5220 --- integration-test/src/test/scala/RunnerTest.scala | 2 +- src/universal/bin/sbt.bat | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index d3dc0c580..f64685497 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -161,7 +161,7 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { } test("sbt --script-version should print sbtVersion") { - val out = sbtProcessWithOpts("--numeric-version", "", "").!!.trim + val out = sbtProcessWithOpts("--script-version", "", "").!!.trim val expectedVersion = "^"+versionRegEx+"$" assert(out.matches(expectedVersion)) () diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 417b79ad3..c05b63d64 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -459,8 +459,6 @@ goto args_loop rem Confirm a user's intent if the current directory does not look like an sbt rem top-level directory and the "new" command was not given. -rem TODO: if not -sbt-create - if not defined sbt_args_sbt_create if not defined sbt_args_print_version if not defined sbt_args_print_sbt_version if not defined sbt_args_print_sbt_script_version if not exist build.sbt ( if not exist project\ ( if not defined sbt_new ( @@ -486,6 +484,13 @@ if not defined sbt_args_sbt_create if not defined sbt_args_print_version if not call :process +rem avoid bootstrapping/java version check for script version + +if !sbt_args_print_sbt_script_version! equ 1 ( + echo !init_sbt_version! + goto :eof +) + call :checkjava call :copyrt @@ -569,11 +574,6 @@ set sbt_jar=!sbt_jar:"=! rem TODO: _SBT_OPTS needs to be processed as args and diffed against SBT_ARGS -if !sbt_args_print_sbt_script_version! equ 1 ( - echo !init_sbt_version! - goto :eof -) - if !sbt_args_print_sbt_version! equ 1 ( call :set_sbt_version echo !sbt_version! From 8122bd7020a562e263a8f1aff02df90dc413ae58 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Sun, 17 Nov 2019 11:49:58 -0800 Subject: [PATCH 420/483] Update citest to use 1.3.0 release --- citest/project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/citest/project/build.properties b/citest/project/build.properties index c491602bb..080a737ed 100644 --- a/citest/project/build.properties +++ b/citest/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.0-M4 +sbt.version=1.3.0 From a362c964dea58b1a20a3e042c01001b497553ae9 Mon Sep 17 00:00:00 2001 From: Edward Samson Date: Wed, 20 Nov 2019 13:57:33 +0800 Subject: [PATCH 421/483] Use exec to launch when not in cygwin This allows, for example, capturing the correct PID when launching sbt from within a bash script. The original change from 1a0715056050469b5b713d11d635f782b829f7bf was to address an issue specific to cygwin. --- src/universal/bin/sbt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index a95e916af..4240311da 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -118,9 +118,13 @@ execRunner () { echo "" } - # This used to be exec, but we loose the ability to re-hook stty then - # for cygwin... Maybe we should flag the feature here... - "$@" + if [[ "$CYGWIN_FLAG" == "true" ]]; then + # In cygwin we loose the ability to re-hook stty if exec is used + # https://github.com/sbt/sbt-launcher-package/issues/53 + "$@" + else + exec "$@" + fi } addJava () { From 595bf0fc2d62ffc3732a17516984799351e9f2fc Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 13 Dec 2019 10:45:13 -0500 Subject: [PATCH 422/483] Fix Coursier export by adding missing artifacts Ref https://github.com/sbt/sbt-launcher-package/pull/145 Ref https://github.com/sbt/sbt-launcher-package/pull/267 --- build.sbt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index c3b2d71d0..703b6f6ad 100755 --- a/build.sbt +++ b/build.sbt @@ -22,9 +22,10 @@ lazy val jansi = { if (sbtVersionToRelease startsWith "1.") "org.fusesource.jansi" % "jansi" % "1.12" else "org.fusesource.jansi" % "jansi" % "1.4" } -lazy val scala212Jline = "jline" % "jline" % "2.14.6" -lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.2.0" lazy val scala212Compiler = "org.scala-lang" % "scala-compiler" % scala212 +lazy val scala212Jline = "jline" % "jline" % "2.14.6" +// use the scala-xml version used by the compiler not the latest: https://github.com/scala/scala/blob/v2.12.10/versions.properties#L22 +lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6" lazy val sbtActual = "org.scala-sbt" % "sbt" % sbtVersionToRelease lazy val sbt013ExtraDeps = { @@ -177,7 +178,6 @@ val root = (project in file(".")). prev.toList map { case (k, BinSbt) => import java.nio.file.{Files, FileSystems} - val x = IO.read(k) IO.write(t / "sbt", x.replaceAllLiterally( "declare init_sbt_version=_to_be_replaced", @@ -341,6 +341,8 @@ def downloadUrl(uri: URI, out: File): Unit = } } +def colonName(m: ModuleID): String = s"${m.organization}:${m.name}:${m.revision}" + lazy val dist = (project in file("dist")) .enablePlugins(ExportRepoPlugin) .settings( @@ -376,6 +378,9 @@ lazy val dist = (project in file("dist")) IO.delete(cache) val v = sbtVersionToRelease s"$csr fetch --cache $cache org.scala-sbt:sbt:$v".! + s"$csr fetch --cache $cache ${colonName(jansi)}".! + s"$csr fetch --cache $cache ${colonName(scala212Compiler)}".! + s"$csr fetch --cache $cache ${colonName(scala212Xml)}".! val mavenCache = cache / "https" / "repo1.maven.org" / "maven2" val compilerBridgeVer = IO.listFiles(mavenCache / "org" / "scala-sbt" / "compiler-bridge_2.12", DirectoryFilter).toList.headOption compilerBridgeVer match { From 29548d7628f69df06701ec69dc46d1af838d241d Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Thu, 19 Dec 2019 16:14:37 -0800 Subject: [PATCH 423/483] Tweak sbt.bat to parse the -debug arguments first --- src/universal/bin/sbt.bat | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index c05b63d64..d9a467801 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -121,6 +121,17 @@ shift if [%0] EQU [] goto args_end set g=%~0 +rem make sure the sbt_args_debug gets set first incase any argument parsing uses :dlog +if "%~0" == "-d" set _debug_arg=true +if "%~0" == "--debug" set _debug_arg=true + +if defined _debug_arg ( + set _debug_arg= + set sbt_args_debug=1 + set SBT_ARGS=-debug !SBT_ARGS! + goto args_loop +) + if "%~0" == "-h" goto usage if "%~0" == "-help" goto usage if "%~0" == "--help" goto usage @@ -255,16 +266,6 @@ if defined _sbt_ivy_arg ( ) ) -if "%~0" == "-d" set _debug_arg=true -if "%~0" == "--debug" set _debug_arg=true - -if defined _debug_arg ( - set _debug_arg= - set sbt_args_debug=1 - set SBT_ARGS=-debug !SBT_ARGS! - goto args_loop -) - if "%~0" == "-debug-inc" set _debug_inc_arg=true if "%~0" == "--debug-inc" set _debug_inc_arg=true From 5559440739321c01b5bb5985e0ba30be3e397a9e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 23 Dec 2019 01:50:37 -0500 Subject: [PATCH 424/483] don't use execRunner to copy rt.jar Ref https://github.com/sbt/sbt-launcher-package/pull/308 Fixes https://github.com/sbt/sbt/issues/5270 The first time `sbt` runs on JDK 11, it copies the `rt.jar` by calling `execRunner java`.. it seems like the control never comes back from it and `sbt` just ends there. This fixes the problem by not calling `execRunner` for that operation. --- src/universal/bin/sbt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 4240311da..709c298e1 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -105,6 +105,7 @@ rt_export_file () { echo "${sbt_bin_dir}/java9-rt-export.jar" } +# execRunner should be called only once to give up control to java execRunner () { # print the arguments one to a line, quoting any containing spaces [[ $sbt_verbose || $sbt_debug ]] && echo "# Executing command line:" && { @@ -336,9 +337,9 @@ copyRt() { java9_rt=$(echo "$java9_ext/rt.jar") vlog "[copyRt] java9_rt = '$java9_rt'" if [[ ! -f "$java9_rt" ]]; then - echo Copying runtime jar. + echo copying runtime jar... mkdir -p "$java9_ext" - execRunner "$java_cmd" \ + "$java_cmd" \ "${sbt_options[@]}" \ "${java_args[@]}" \ -jar "$rtexport" \ From 8d06d14019a64481647670ebe867e1915bac6961 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 24 Dec 2019 15:12:30 -0500 Subject: [PATCH 425/483] Fix rsync check path Starting sbt 1.3.x we use Coursier to build the preloaded local repo using Maven layout. --- src/universal/bin/sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 709c298e1..e6e5afbb4 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -292,12 +292,12 @@ syncPreloaded() { # FIXME: better $init_sbt_version detection init_sbt_version="$(ls -1 "$source_preloaded/org/scala-sbt/sbt/")" fi - [[ -f "$target_preloaded/org.scala-sbt/sbt/$init_sbt_version/jars/sbt.jar" ]] || { + [[ -f "$target_preloaded/org/scala-sbt/sbt/$init_sbt_version/" ]] || { # lib/local-preloaded exists (This is optional) [[ -d "$source_preloaded" ]] && { command -v rsync >/dev/null 2>&1 && { mkdir -p "$target_preloaded" - rsync -a --ignore-existing "$source_preloaded" "$target_preloaded" + rsync -a --ignore-existing "$source_preloaded" "$target_preloaded" || true } } } From d35fe3aeafe372e383ef7d836fe12cd8a2169bbb Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 24 Dec 2019 21:35:01 -0500 Subject: [PATCH 426/483] rsync flags Fixes https://github.com/sbt/sbt/issues/5035 Currently `sbt` calls `rsync -a`, which expands to `-rlptgoD`, including `--group` and `--owner` flag that preserves the group and owner of the files. This drops the requirement since we just need to copy files around with the right timestamp. --- src/universal/bin/sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index e6e5afbb4..cd9b97358 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -297,7 +297,7 @@ syncPreloaded() { [[ -d "$source_preloaded" ]] && { command -v rsync >/dev/null 2>&1 && { mkdir -p "$target_preloaded" - rsync -a --ignore-existing "$source_preloaded" "$target_preloaded" || true + rsync --recursive --links --perms --times --ignore-existing "$source_preloaded" "$target_preloaded" || true } } } From 0ce5630633df6f86a696ce431d332eb45cd17cd9 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 28 Dec 2019 02:36:53 -0500 Subject: [PATCH 427/483] refactor sbtProcess to use vararg This allows passing whitespace as part of an argument. --- .../src/test/scala/RunnerTest.scala | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index f64685497..3fd609c69 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -13,109 +13,109 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { if (isWindows) new File("target/universal/stage/bin/sbt.bat") else new File("target/universal/stage/bin/sbt") - def sbtProcess(arg: String) = sbtProcessWithOpts(arg, "", "") - def sbtProcessWithOpts(arg: String, javaOpts: String, sbtOpts: String) = - sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest"), + def sbtProcess(args: String*) = sbtProcessWithOpts(args: _*)("", "") + def sbtProcessWithOpts(args: String*)(javaOpts: String, sbtOpts: String) = + sbt.internal.Process(Seq(sbtScript.getAbsolutePath) ++ args, new File("citest"), "JAVA_OPTS" -> javaOpts, "SBT_OPTS" -> sbtOpts) test("sbt runs") { assert(sbtScript.exists) - val out = sbtProcess("compile -v").! + val out = sbtProcess("compile", "-v").! assert(out == 0) () } test("sbt -no-colors") { - val out = sbtProcess("compile -no-colors -v").!!.linesIterator.toList + val out = sbtProcess("compile", "-no-colors", "-v").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.log.noformat=true")) () } test("sbt --no-colors") { - val out = sbtProcess("compile --no-colors -v").!!.linesIterator.toList + val out = sbtProcess("compile", "--no-colors", "-v").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.log.noformat=true")) () } test("sbt --color=false") { - val out = sbtProcess("compile --color=false -v").!!.linesIterator.toList + val out = sbtProcess("compile", "--color=false", "-v").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.color=false")) () } test("sbt --debug-inc") { - val out = sbtProcess("compile --debug-inc -v").!!.linesIterator.toList + val out = sbtProcess("compile", "--debug-inc", "-v").!!.linesIterator.toList assert(out.contains[String]("-Dxsbt.inc.debug=true")) () } test("sbt --supershell=never") { - val out = sbtProcess("compile --supershell=never -v").!!.linesIterator.toList + val out = sbtProcess("compile", "--supershell=never", "-v").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.supershell=never")) () } test("sbt --timings") { - val out = sbtProcess("compile --timings -v").!!.linesIterator.toList + val out = sbtProcess("compile", "--timings", "-v").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.task.timings=true")) () } test("sbt -D arguments") { - val out = sbtProcess("-Dsbt.supershell=false compile -v").!!.linesIterator.toList + val out = sbtProcess("-Dsbt.supershell=false", "compile", "-v").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.supershell=false")) () } test("sbt --sbt-version") { - val out = sbtProcess("--sbt-version 1.3.0 compile -v").!!.linesIterator.toList + val out = sbtProcess("--sbt-version", "1.3.0", "compile", "-v").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.version=1.3.0")) () } test("sbt -mem 503") { - val out = sbtProcess("compile -mem 503 -v").!!.linesIterator.toList + val out = sbtProcess("compile", "-mem", "503", "-v").!!.linesIterator.toList assert(out.contains[String]("-Xmx503m")) () } test("sbt with -mem 503, -Xmx in JAVA_OPTS") { - val out = sbtProcessWithOpts("compile -mem 503 -v", "-Xmx1024m", "").!!.linesIterator.toList + val out = sbtProcessWithOpts("compile", "-mem", "503", "-v")("-Xmx1024m", "").!!.linesIterator.toList assert(out.contains[String]("-Xmx503m")) assert(!out.contains[String]("-Xmx1024m")) () } test("sbt with -mem 503, -Xmx in SBT_OPTS") { - val out = sbtProcessWithOpts("compile -mem 503 -v", "", "-Xmx1024m").!!.linesIterator.toList + val out = sbtProcessWithOpts("compile", "-mem", "503", "-v")("", "-Xmx1024m").!!.linesIterator.toList assert(out.contains[String]("-Xmx503m")) assert(!out.contains[String]("-Xmx1024m")) () } test("sbt with -Xms2048M -Xmx2048M -Xss6M in SBT_OPTS") { - val out = sbtProcessWithOpts("compile -v", "", "-Xms2048M -Xmx2048M -Xss6M").!!.linesIterator.toList + val out = sbtProcessWithOpts("compile", "-v")("", "-Xms2048M -Xmx2048M -Xss6M").!!.linesIterator.toList assert(out.contains[String]("-Xss6M")) () } test("sbt with -Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080 in SBT_OPTS") { - val out = sbtProcessWithOpts("compile -v", "", "-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080").!!.linesIterator.toList + val out = sbtProcessWithOpts("compile", "-v")("", "-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080").!!.linesIterator.toList assert(out.contains[String]("-Dhttp.proxyHost=proxy")) assert(out.contains[String]("-Dhttp.proxyPort=8080")) () } test("sbt with -XX:ParallelGCThreads=16 -XX:PermSize=128M in SBT_OPTS") { - val out = sbtProcessWithOpts("compile -v", "", "-XX:ParallelGCThreads=16 -XX:PermSize=128M").!!.linesIterator.toList + val out = sbtProcessWithOpts("compile", "-v")("", "-XX:ParallelGCThreads=16 -XX:PermSize=128M").!!.linesIterator.toList assert(out.contains[String]("-XX:ParallelGCThreads=16")) assert(out.contains[String]("-XX:PermSize=128M")) () } test("sbt with -XX:+UseG1GC -XX:+PrintGC in SBT_OPTS") { - val out = sbtProcessWithOpts("compile -v", "", "-XX:+UseG1GC -XX:+PrintGC").!!.linesIterator.toList + val out = sbtProcessWithOpts("compile", "-v")("", "-XX:+UseG1GC -XX:+PrintGC").!!.linesIterator.toList assert(out.contains[String]("-XX:+UseG1GC")) assert(out.contains[String]("-XX:+PrintGC")) assert(!out.contains[String]("-XX:+UseG1GC=-XX:+PrintGC")) @@ -123,7 +123,7 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { } test("sbt with -XX:-UseG1GC -XX:-PrintGC in SBT_OPTS") { - val out = sbtProcessWithOpts("compile -v", "", "-XX:-UseG1GC -XX:-PrintGC").!!.linesIterator.toList + val out = sbtProcessWithOpts("compile", "-v")("", "-XX:-UseG1GC -XX:-PrintGC").!!.linesIterator.toList assert(out.contains[String]("-XX:-UseG1GC")) assert(out.contains[String]("-XX:-PrintGC")) assert(!out.contains[String]("-XX:-UseG1GC=-XX:-PrintGC")) @@ -132,43 +132,43 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { test("sbt with --no-colors in SBT_OPTS") { if (isWindows) cancel("Test not supported on windows") - val out = sbtProcessWithOpts("compile -v", "", "--no-colors").!!.linesIterator.toList + val out = sbtProcessWithOpts("compile", "-v")("", "--no-colors").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.log.noformat=true")) () } test("sbt -V|-version|--version should print sbtVersion") { - val out = sbtProcessWithOpts("-version", "", "").!!.trim + val out = sbtProcess("-version").!!.trim val expectedVersion = s"""|(?m)^sbt version in this project: $versionRegEx(\\r)? |sbt script version: $versionRegEx$$ |""".stripMargin.trim.replace("\n", "\\n") assert(out.matches(expectedVersion)) - val out2 = sbtProcessWithOpts("--version", "", "").!!.trim + val out2 = sbtProcess("--version").!!.trim assert(out2.matches(expectedVersion)) - val out3 = sbtProcessWithOpts("-V", "", "").!!.trim + val out3 = sbtProcess("-V").!!.trim assert(out3.matches(expectedVersion)) () } test("sbt --numeric-version should print sbt script version") { - val out = sbtProcessWithOpts("--numeric-version", "", "").!!.trim + val out = sbtProcess("--numeric-version").!!.trim val expectedVersion = "^"+versionRegEx+"$" assert(out.matches(expectedVersion)) () } test("sbt --script-version should print sbtVersion") { - val out = sbtProcessWithOpts("--script-version", "", "").!!.trim + val out = sbtProcess("--script-version").!!.trim val expectedVersion = "^"+versionRegEx+"$" assert(out.matches(expectedVersion)) () } test("sbt --sbt-jar should run") { - val out = sbtProcess("compile -v --sbt-jar ../target/universal/stage/bin/sbt-launch.jar").!!.linesIterator.toList + val out = sbtProcess("compile", "-v", "--sbt-jar", "../target/universal/stage/bin/sbt-launch.jar").!!.linesIterator.toList assert(out.contains[String]("../target/universal/stage/bin/sbt-launch.jar") || out.contains[String]("\"../target/universal/stage/bin/sbt-launch.jar\"") ) From c11040c968d8761515d8e57db1872e1c889b3a06 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 28 Dec 2019 02:37:14 -0500 Subject: [PATCH 428/483] Fixes quoted arugment with whitespace Ref https://github.com/sbt/sbt/issues/5343 Fixes https://github.com/sbt/sbt/issues/5210 --- CONTRIBUTING.md | 15 +++++++++++++++ citest/build.sbt | 2 ++ citest/src/test/scala/HelloTest.scala | 7 +++++++ integration-test/src/test/scala/RunnerTest.scala | 6 ++++++ src/universal/bin/sbt.bat | 14 +++++++------- 5 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 citest/src/test/scala/HelloTest.scala diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 499d2e429..dfb55c095 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,3 +11,18 @@ $ sbt -Dsbt.build.version=1.0.3 -Dsbt.build.offline=true > rpm:releaseAllStaged ``` +## Notes on batch + +### Testing if a variable is blank + +``` +if not defined _JAVACMD set _JAVACMD=java +``` + +### Testing if an argument %0 is blank + +``` +if "%~0" == "" goto echolist_end +``` + +The above would work in case `%0` contains either double quote (`"`) or whitespace. diff --git a/citest/build.sbt b/citest/build.sbt index 567f42ae1..c6f2f6ac5 100644 --- a/citest/build.sbt +++ b/citest/build.sbt @@ -5,6 +5,8 @@ lazy val root = (project in file(".")) .settings( scalaVersion := "2.12.4", name := "Hello", + libraryDependencies += "com.eed3si9n.verify" %% "verify" % "0.2.0" % Test, + testFrameworks += new TestFramework("verify.runner.Framework"), check := { val xs = IO.readLines(file("output.txt")).toVector diff --git a/citest/src/test/scala/HelloTest.scala b/citest/src/test/scala/HelloTest.scala new file mode 100644 index 000000000..863715d84 --- /dev/null +++ b/citest/src/test/scala/HelloTest.scala @@ -0,0 +1,7 @@ +import verify._ + +object HelloTest extends BasicTestSuite { + test("addition") { + assert(2 == 1 + 1) + } +} diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 3fd609c69..0fd04878b 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -174,4 +174,10 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { ) () } + + test("sbt \"testOnly *\"") { + val out = sbtProcess("testOnly *", "--no-colors", "-v").!!.linesIterator.toList + assert(out.contains[String]("[info] HelloTest")) + () + } } diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index d9a467801..105c9e7b2 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -118,7 +118,7 @@ if not defined _SBT_OPTS if defined default_sbt_opts set _SBT_OPTS=!default_sbt_ :args_loop shift -if [%0] EQU [] goto args_end +if "%~0" == "" goto args_end set g=%~0 rem make sure the sbt_args_debug gets set first incase any argument parsing uses :dlog @@ -369,7 +369,7 @@ if "%~0" == "--jvm-debug" set _jvm_debug_arg=true if defined _jvm_debug_arg ( set _jvm_debug_arg= - if [%1] NEQ [] ( + if not "%~1" == "" ( set /a JVM_DEBUG_PORT=%~1 2>nul >nul if !JVM_DEBUG_PORT! EQU 0 ( rem next argument wasn't a port, set a default and process next arg @@ -384,7 +384,7 @@ if "%~0" == "--java-home" set _java_home_arg=true if defined _java_home_arg ( set _java_home_arg= - if [%1] NEQ [] ( + if not "%~1" == "" ( if exist "%~1\bin\java.exe" ( set "_JAVACMD=%~1\bin\java.exe" set "JAVA_HOME=%~1" @@ -596,7 +596,7 @@ if defined sbt_args_verbose ( echo -cp echo "!sbt_jar!" echo xsbt.boot.Boot - if not [%~1] == [] ( call :echolist %* ) + if not "%~1" == "" ( call :echolist %* ) echo. ) @@ -610,8 +610,8 @@ rem fixes dealing with quotes after = args: -Dscala.ext.dirs="C:\Users\First Las rem call method is in first call of %0 shift -if [%0] EQU [] goto echolist_end -set "p=%0" +if "%~0" == "" goto echolist_end +set "p=%~0" if "%p:~0,2%" == "-D" ( rem special handling for -D since '=' gets parsed away @@ -791,7 +791,7 @@ if /I !JAVA_VERSION! GEQ 9 ( exit /B 0 :sync_preloaded -if [!init_sbt_version] == [] ( +if not defined init_sbt_version ( rem FIXME: better !init_sbt_version! detection FOR /F "tokens=* usebackq" %%F IN (`dir /b "!SBT_HOME!\lib\local-preloaded\org\scala-sbt\sbt" /B`) DO ( SET init_sbt_version=%%F From d2818865847339210bb9bdf85454f912ac536d6f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 4 Jan 2020 15:12:31 -0500 Subject: [PATCH 429/483] consolidate Travis CI build jobs --- .travis.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 20da207be..61df38bfb 100755 --- a/.travis.yml +++ b/.travis.yml @@ -48,21 +48,14 @@ matrix: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - cd citest && ./test.sh - - name: "build using JDK 8 test using JDK 8" - script: - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - - cd citest && ./test.sh - - - name: "build using JDK 8, test using OpenJDK 11" - script: - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - - $JABBA_HOME/bin/jabba install $TRAVIS_JDK11 && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK11" && export PATH="$JAVA_HOME/bin:$PATH" - - java -Xmx32m -version - - cd citest && ./test.sh - - - name: "Linux package testing" + - name: "build using JDK 8 test using JDK 8 and JDK 11" script: - sbt -Dsbt.build.version=$SBT_VER rpm:packageBin debian:packageBin + - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test + - cd citest && ./test.sh + - $JABBA_HOME/bin/jabba install $TRAVIS_JDK11 && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK11" && export PATH="$JAVA_HOME/bin:$PATH" + - java -Xmx32m -version + - ./test.sh addons: apt: packages: From 1a2ca2610beee749355488caf310f9da39ad626e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 7 Jan 2020 13:56:35 -0500 Subject: [PATCH 430/483] Fix unintended glob expansion Fixes https://github.com/sbt/sbt/issues/5343 --- integration-test/src/test/scala/RunnerTest.scala | 10 ++++++++++ src/universal/bin/sbt | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 0fd04878b..b907828ec 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -180,4 +180,14 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { assert(out.contains[String]("[info] HelloTest")) () } + + test("quoted * should not glob expand to local files") { + val out = sbtProcess("testOnly * ", "--no-colors", "-v", "-debug").!!.linesIterator.toList + + // Ensure the "*" doesn't get glob expanded to individual files or directories + // (e.g. Hello.scala gets added to the testOnly arguments) https://github.com/sbt/sbt/issues/5343 + assert(!out.exists(x => x.contains("testOnly") && x.contains("Hello.scala"))) + assert(out.contains[String]("[info] HelloTest")) + () + } } diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index cd9b97358..7b881031d 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -353,8 +353,8 @@ run() { local retarr=() java_args=($JAVA_OPTS) sbt_options0=(${SBT_OPTS:-$default_sbt_opts}) - miniscript=$(map_args "${sbt_options0[@]}") && eval ${miniscript/retarr/sbt_options} - miniscript=$(map_args "$@") && eval ${miniscript/retarr/args1} + miniscript=$(map_args "${sbt_options0[@]}") && eval "${miniscript/retarr/sbt_options}" + miniscript=$(map_args "$@") && eval "${miniscript/retarr/args1}" # process the combined args, then reset "$@" to the residuals process_args "${args1[@]}" vlog "[sbt_options] $(declare -p sbt_options)" From 415e5665771509c6abd51b4439362586f5d92826 Mon Sep 17 00:00:00 2001 From: Gunnar Lilleaasen Date: Mon, 13 Jan 2020 10:44:28 +0100 Subject: [PATCH 431/483] Fixed expansion of args with whitespace in JDK 9+. Solves the issue where providing sbt_options and java_args containing whitespaces on Java 9 and higher would fail. Expansion of sbt_options and java_args containing whitespaces would not expand correctly in copyRt(), but instead would create an invalid java command due to missing quotes. --- src/universal/bin/sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 7b881031d..23d309e21 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -332,7 +332,7 @@ copyRt() { if [[ "$at_least_9" == "1" ]]; then rtexport=$(rt_export_file) # The grep for java9-rt-ext- matches the filename prefix printed in Export.java - java9_ext=$("$java_cmd" ${sbt_options[@]} ${java_args[@]} \ + java9_ext=$("$java_cmd" "${sbt_options[@]}" "${java_args[@]}" \ -jar "$rtexport" --rt-ext-dir | grep java9-rt-ext-) java9_rt=$(echo "$java9_ext/rt.jar") vlog "[copyRt] java9_rt = '$java9_rt'" From 2b5ed6529bec3c6538b8fa0acc78716e634c476a Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 24 Jan 2020 11:56:29 -0500 Subject: [PATCH 432/483] Add sbt.build.patch --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 703b6f6ad..8896455ab 100755 --- a/build.sbt +++ b/build.sbt @@ -107,7 +107,7 @@ val root = (project in file(".")). }, // DEBIAN SPECIFIC - debianBuildId := 0, + debianBuildId := sys.props.getOrElse("sbt.build.patch", sys.env.getOrElse("DIST_PATCHVER", "0")).toInt, version in Debian := { if (debianBuildId.value == 0) sbtVersionToRelease else sbtVersionToRelease + "." + debianBuildId.value @@ -127,7 +127,7 @@ val root = (project in file(".")). debianNativeBuildOptions in Debian := Seq("-Zgzip", "-z3"), // RPM SPECIFIC - rpmRelease := "0", + rpmRelease := debianBuildId.value.toString, version in Rpm := { val stable0 = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".") val stable = if (rpmRelease.value == "0") stable0 From c6ac5619ed500cf71e99a8ea9c0aa8a4c26f6c80 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 24 Jan 2020 15:03:40 -0500 Subject: [PATCH 433/483] BINTRAY_USER --- build.sbt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.sbt b/build.sbt index 8896455ab..421e5a1a7 100755 --- a/build.sbt +++ b/build.sbt @@ -70,6 +70,12 @@ val root = (project in file(".")). val _ = (clean in dist).value clean.value }, + credentials ++= { + (sys.env.get("BINTRAY_USER"), sys.env.get("BINTRAY_PASS")) match { + case (Some(u), Some(p)) => Seq(Credentials("Bintray API Realm", "api.bintray.com", u, p)) + case _ => Nil + } + }, useGpg := true, usePgpKeyHex("642AC823"), pgpSecretRing := file(s"""${sys.props("user.home")}""") / ".ssh" / "scalasbt.key", From 8143bbfc2406f89a0f82116fe8c6566993d02140 Mon Sep 17 00:00:00 2001 From: abe Date: Tue, 3 Mar 2020 14:33:49 +0900 Subject: [PATCH 434/483] Fix --jvm-debug not working on Windows --- src/universal/bin/sbt.bat | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 105c9e7b2..d4fb4dbf3 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -375,6 +375,9 @@ if defined _jvm_debug_arg ( rem next argument wasn't a port, set a default and process next arg set /A JVM_DEBUG_PORT=5005 goto args_loop + ) else ( + shift + goto args_loop ) ) ) From bcf5f020fe610d406feded90f95a3440deab96ff Mon Sep 17 00:00:00 2001 From: abe Date: Wed, 4 Mar 2020 11:48:56 +0900 Subject: [PATCH 435/483] Fix --verbose output with --jvm-debug on Windows --- src/universal/bin/sbt.bat | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index d4fb4dbf3..f063cac4b 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -640,6 +640,18 @@ if not "%p:~0,5%" == "-XX:+" if not "%p:~0,5%" == "-XX:-" if "%p:~0,3%" == "-XX" ) ) +if "%p:~0,14%" == "-agentlib:jdwp" ( + rem special handling for --jvm-debug since '=' and ',' gets parsed away + for /F "tokens=1 delims==" %%a in ("%p%") do ( + rem make sure it doesn't have the '=' already + if "%p%" == "%%a" if not "%~1" == "" if not "%~2" == "" if not "%~3" == "" if not "%~4" == "" if not "%~5" == "" if not "%~6" == "" if not "%~7" == "" if not "%~8" == "" ( + echo %0=%1=%2,%3=%4,%5=%6,%7=%8 + shift & shift & shift & shift & shift & shift & shift & shift + goto echolist + ) + ) +) + echo %0 goto echolist From 2242091012afd8d63514af28a0e0f101f7c6d078 Mon Sep 17 00:00:00 2001 From: abe Date: Wed, 4 Mar 2020 12:05:41 +0900 Subject: [PATCH 436/483] Add test for --jvm-debug --- integration-test/src/test/scala/RunnerTest.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index b907828ec..29a0be9bb 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -190,4 +190,10 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { assert(out.contains[String]("[info] HelloTest")) () } + + test("sbt --jvm-debug ") { + val out = sbtProcess("--jvm-debug", "12345", "compile", "-v").!!.linesIterator.toList + assert(out.contains[String]("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=12345")) + () + } } From b7558e11b91e6f00c0227852e92627af6d4c99e9 Mon Sep 17 00:00:00 2001 From: Henri Cook Date: Mon, 25 May 2020 18:57:53 +0100 Subject: [PATCH 437/483] Support debug flags in SBT_OPTs --- src/universal/bin/sbt | 50 ++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 23d309e21..17ae8f426 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -133,7 +133,7 @@ addJava () { java_args=( "${java_args[@]}" "$1" ) } addSbt () { - dlog "[addSbt] arg = '$1'" + echoerr "[addSbt] arg = '$1'" sbt_commands=( "${sbt_commands[@]}" "$1" ) } addResidual () { @@ -350,14 +350,21 @@ copyRt() { } run() { - local retarr=() java_args=($JAVA_OPTS) sbt_options0=(${SBT_OPTS:-$default_sbt_opts}) - miniscript=$(map_args "${sbt_options0[@]}") && eval "${miniscript/retarr/sbt_options}" - miniscript=$(map_args "$@") && eval "${miniscript/retarr/args1}" + + # Split SBT_OPTs into options/commands + miniscript=$(map_args "${sbt_options0[@]}") && eval "${miniscript/options/sbt_options}" && \ + eval "${miniscript/commands/sbt_additional_commands}" + + # Combine command line options/commands and commands from SBT_OPTs + miniscript=$(map_args "$@") && eval "${miniscript/options/cli_options}" && eval "${miniscript/commands/cli_commands}" + args1=( "${cli_options[@]}" "${cli_commands[@]}" "${sbt_additional_commands[@]}" ) + # process the combined args, then reset "$@" to the residuals process_args "${args1[@]}" vlog "[sbt_options] $(declare -p sbt_options)" + addDefaultMemory set -- "${residual_args[@]}" argumentCount=$# @@ -378,7 +385,7 @@ run() { # Java 9 support copyRt - #If we're in cygwin, we should use the windows config, and terminal hacks + # If we're in cygwin, we should use the windows config, and terminal hacks if [[ "$CYGWIN_FLAG" == "true" ]]; then #" stty -icanon min 1 -echo > /dev/null 2>&1 addJava "-Djline.terminal=jline.UnixTerminal" @@ -509,25 +516,28 @@ process_my_args () { ## map over argument array. this is used to process both command line arguments and SBT_OPTS map_args () { - local retarr=() + local options=() + local commands=() while [[ $# -gt 0 ]]; do case "$1" in - -no-colors|--no-colors) retarr=( "${retarr[@]}" "-Dsbt.log.noformat=true" ) && shift ;; - -timings|--timings) retarr=( "${retarr[@]}" "-Dsbt.task.timings=true" "-Dsbt.task.timings.on.shutdown=true" ) && shift ;; - -traces|--traces) retarr=( "${retarr[@]}" "-Dsbt.traces=true" ) && shift ;; - --supershell=*) retarr=( "${retarr[@]}" "-Dsbt.supershell=${1:13}" ) && shift ;; - -supershell=*) retarr=( "${retarr[@]}" "-Dsbt.supershell=${1:12}" ) && shift ;; - --color=*) retarr=( "${retarr[@]}" "-Dsbt.color=${1:8}" ) && shift ;; - -color=*) retarr=( "${retarr[@]}" "-Dsbt.color=${1:7}" ) && shift ;; - -no-share|--no-share) retarr=( "${retarr[@]}" "$noshare_opts" ) && shift ;; - -no-global|--no-global) retarr=( "${retarr[@]}" "-Dsbt.global.base=$(pwd)/project/.sbtboot" ) && shift ;; - -sbt-boot|--sbt-boot) require_arg path "$1" "$2" && retarr=( "${retarr[@]}" "-Dsbt.boot.directory=$2" ) && shift 2 ;; - -sbt-dir|--sbt-dir) require_arg path "$1" "$2" && retarr=( "${retarr[@]}" "-Dsbt.global.base=$2" ) && shift 2 ;; - -debug-inc|--debug-inc) retarr=( "${retarr[@]}" "-Dxsbt.inc.debug=true" ) && shift ;; - *) retarr=( "${retarr[@]}" "$1" ) && shift ;; + -no-colors|--no-colors) options=( "${options[@]}" "-Dsbt.log.noformat=true" ) && shift ;; + -timings|--timings) options=( "${options[@]}" "-Dsbt.task.timings=true" "-Dsbt.task.timings.on.shutdown=true" ) && shift ;; + -traces|--traces) options=( "${options[@]}" "-Dsbt.traces=true" ) && shift ;; + --supershell=*) options=( "${options[@]}" "-Dsbt.supershell=${1:13}" ) && shift ;; + -supershell=*) options=( "${options[@]}" "-Dsbt.supershell=${1:12}" ) && shift ;; + --color=*) options=( "${options[@]}" "-Dsbt.color=${1:8}" ) && shift ;; + -color=*) options=( "${options[@]}" "-Dsbt.color=${1:7}" ) && shift ;; + -no-share|--no-share) options=( "${options[@]}" "$noshare_opts" ) && shift ;; + -no-global|--no-global) options=( "${options[@]}" "-Dsbt.global.base=$(pwd)/project/.sbtboot" ) && shift ;; + -sbt-boot|--sbt-boot) require_arg path "$1" "$2" && options=( "${options[@]}" "-Dsbt.boot.directory=$2" ) && shift 2 ;; + -sbt-dir|--sbt-dir) require_arg path "$1" "$2" && options=( "${options[@]}" "-Dsbt.global.base=$2" ) && shift 2 ;; + -debug|--debug) commands=( "${commands[@]}" "-debug" ) && shift ;; + -debug-inc|--debug-inc) options=( "${options[@]}" "-Dxsbt.inc.debug=true" ) && shift ;; + *) options=( "${options[@]}" "$1" ) && shift ;; esac done - declare -p retarr + declare -p options + declare -p commands } process_args () { From 4872ddf3efe4b84b780544d7877473ac94da6902 Mon Sep 17 00:00:00 2001 From: Henri Cook Date: Mon, 25 May 2020 19:31:20 +0100 Subject: [PATCH 438/483] Add tests for supporting -debug flag in SBT_OPTSs --- integration-test/src/test/scala/RunnerTest.scala | 14 ++++++++++++++ src/universal/bin/sbt | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 29a0be9bb..7f0ec31d7 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -137,6 +137,20 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } + test("sbt with -debug in SBT_OPTS appears in sbt commands") { + val out: List[String] = sbtProcessWithOpts("compile", "-v")("", "-debug").!!.linesIterator.toList + // Debug argument must appear in the 'commands' section after sbt-launch.jar to work + val locationOfSbtLaunchJarArg = out.zipWithIndex.collectFirst { + case (arg, index) if arg.endsWith("sbt-launch.jar") => index + } + + assert(locationOfSbtLaunchJarArg.nonEmpty) + + val argsAfterSbtLaunch = out.drop(locationOfSbtLaunchJarArg.get) + assert(argsAfterSbtLaunch.contains("-debug")) + () + } + test("sbt -V|-version|--version should print sbtVersion") { val out = sbtProcess("-version").!!.trim val expectedVersion = diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 17ae8f426..2408265b7 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -353,11 +353,11 @@ run() { java_args=($JAVA_OPTS) sbt_options0=(${SBT_OPTS:-$default_sbt_opts}) - # Split SBT_OPTs into options/commands + # Split SBT_OPTS into options/commands miniscript=$(map_args "${sbt_options0[@]}") && eval "${miniscript/options/sbt_options}" && \ eval "${miniscript/commands/sbt_additional_commands}" - # Combine command line options/commands and commands from SBT_OPTs + # Combine command line options/commands and commands from SBT_OPTS miniscript=$(map_args "$@") && eval "${miniscript/options/cli_options}" && eval "${miniscript/commands/cli_commands}" args1=( "${cli_options[@]}" "${cli_commands[@]}" "${sbt_additional_commands[@]}" ) From c55cccd4d506dbdd20cca9650474299bebacc405 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 28 May 2020 23:32:53 -0400 Subject: [PATCH 439/483] Remove Homebrew from CI Ref https://github.com/Homebrew/homebrew-core/issues/50649 --- .travis.yml | 9 +++++---- citest/project/build.properties | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 61df38bfb..884261bad 100755 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ scala: 2.10.7 env: global: - - SBT_VER=1.3.0 + - SBT_VER=1.3.10 - TRAVIS_JDK=adopt@1.8.0-222 - JABBA_HOME=$HOME/.jabba - TRAVIS_JDK11=openjdk@1.11.0 @@ -23,7 +23,7 @@ matrix: install: - $JABBA_HOME/bin/jabba.exe install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" - java -Xmx32m -version - - curl https://piccolo.link/sbt-1.2.8.zip -L --output /tmp/sbt.zip + - curl https://piccolo.link/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip - unzip /tmp/sbt.zip -d $HOME/sbt - export PATH="$HOME/sbt/sbt/bin:$PATH" script: @@ -38,12 +38,13 @@ matrix: language: java before_install: - curl -sL https://raw.githubusercontent.com/shyiko/jabba/0.11.2/install.sh | bash && . ~/.jabba/jabba.sh - - brew update - - brew install sbt install: - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK/Contents/Home" && export PATH="$JAVA_HOME/bin:$PATH" - java -Xmx32m -version - unset SBT_OPTS + - curl https://piccolo.link/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip + - unzip /tmp/sbt.zip -d $HOME/sbt + - export PATH="$HOME/sbt/sbt/bin:$PATH" script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - cd citest && ./test.sh diff --git a/citest/project/build.properties b/citest/project/build.properties index 080a737ed..797e7ccfd 100644 --- a/citest/project/build.properties +++ b/citest/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.0 +sbt.version=1.3.10 From 5ce1b4b61be2c26042cb8eb545d24cf8341e5898 Mon Sep 17 00:00:00 2001 From: l-konov Date: Thu, 11 Jun 2020 16:40:10 +0300 Subject: [PATCH 440/483] Fix issue https://github.com/sbt/sbt/issues/5420 --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index f063cac4b..58707d340 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -466,7 +466,7 @@ rem top-level directory and the "new" command was not given. if not defined sbt_args_sbt_create if not defined sbt_args_print_version if not defined sbt_args_print_sbt_version if not defined sbt_args_print_sbt_script_version if not exist build.sbt ( if not exist project\ ( if not defined sbt_new ( - echo [warn] Neither build.sbt nor a 'project' directory in the current directory: %CD% + echo [warn] Neither build.sbt nor a 'project' directory in the current directory: "%CD%" setlocal :confirm echo c^) continue From 4e5e3fbb29eedf74396df0710b764e7f527e2306 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Fri, 19 Jun 2020 08:07:48 -0700 Subject: [PATCH 441/483] Make robocopy output silent in sbt.bat to match bash bootstrap copy output --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 58707d340..2f09cfdd6 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -819,7 +819,7 @@ if /I !JAVA_VERSION! GEQ 8 ( if %ERRORLEVEL% EQU 0 ( if not exist !PRELOAD_SBT_JAR! ( if exist "!SBT_HOME!\lib\local-preloaded\" ( - robocopy "!SBT_HOME!\lib\local-preloaded" "%UserProfile%\.sbt\preloaded" /E + robocopy "!SBT_HOME!\lib\local-preloaded" "%UserProfile%\.sbt\preloaded" /E >nul 2>nul ) ) ) From 1769f23b3cd6dc4f1f1355d6853222ad611c2d29 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Fri, 19 Jun 2020 08:11:51 -0700 Subject: [PATCH 442/483] Add metals project files to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f495d67cb..48633bd52 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ /SbtTemplateProject.scala target /project/boot +/project/metals.sbt +/.metals /project/plugins lib_managed src_managed From 1bc60adbe75dc708f4e1495b2593c2d650698df0 Mon Sep 17 00:00:00 2001 From: Henri Cook Date: Mon, 25 May 2020 19:40:36 +0100 Subject: [PATCH 443/483] Tidy up -debug in SBT_OPTS for submission --- integration-test/src/test/scala/RunnerTest.scala | 7 +++++-- src/universal/bin/sbt | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 7f0ec31d7..f94c26e76 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -138,10 +138,13 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { } test("sbt with -debug in SBT_OPTS appears in sbt commands") { + if (isWindows) cancel("Test not supported on windows") + val out: List[String] = sbtProcessWithOpts("compile", "-v")("", "-debug").!!.linesIterator.toList - // Debug argument must appear in the 'commands' section after sbt-launch.jar to work + // Debug argument must appear in the 'commands' section (after the sbt-launch.jar argument) to work + val sbtLaunchMatcher = """^.+sbt-launch.jar["]{0,1}$""".r val locationOfSbtLaunchJarArg = out.zipWithIndex.collectFirst { - case (arg, index) if arg.endsWith("sbt-launch.jar") => index + case (arg, index) if sbtLaunchMatcher.findFirstIn(arg).nonEmpty => index } assert(locationOfSbtLaunchJarArg.nonEmpty) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 2408265b7..a3f9443e3 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -133,7 +133,7 @@ addJava () { java_args=( "${java_args[@]}" "$1" ) } addSbt () { - echoerr "[addSbt] arg = '$1'" + dlog "[addSbt] arg = '$1'" sbt_commands=( "${sbt_commands[@]}" "$1" ) } addResidual () { From 19da0b75e9e07078b1ab3c1bebd9e912baf5ebeb Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Wed, 15 Jul 2020 13:21:45 -0700 Subject: [PATCH 444/483] Use java9rtexport library --- build.sbt | 19 ++---- .../github/retronym/java9rtexport/Export.java | 58 ------------------- .../io/github/retronym/java9rtexport/IO.java | 49 ---------------- 3 files changed, 5 insertions(+), 121 deletions(-) delete mode 100644 java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java delete mode 100644 java9-rt-export/src/main/java/io/github/retronym/java9rtexport/IO.java diff --git a/build.sbt b/build.sbt index 421e5a1a7..8da8afc10 100755 --- a/build.sbt +++ b/build.sbt @@ -27,6 +27,8 @@ lazy val scala212Jline = "jline" % "jline" % "2.14.6" // use the scala-xml version used by the compiler not the latest: https://github.com/scala/scala/blob/v2.12.10/versions.properties#L22 lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6" lazy val sbtActual = "org.scala-sbt" % "sbt" % sbtVersionToRelease +val java9rtexportVersion = "0.1.0" +lazy val java9rtexport = "org.scala-sbt.rt" % "java9-rt-export" % java9rtexportVersion % Runtime lazy val sbt013ExtraDeps = { if (sbtVersionToRelease startsWith "0.13.") Seq(scala210Jline) @@ -207,7 +209,7 @@ val root = (project in file(".")). mappings in Universal ++= { val launchJar = sbtLaunchJar.value - val rtExportJar = (packageBin in Compile in java9rtexport).value + val rtExportJar = ((exportRepoCsrDirectory in dist).value / "org/scala-sbt/rt/java9-rt-export" / java9rtexportVersion / s"java9-rt-export-${java9rtexportVersion}.jar") Seq(launchJar -> "bin/sbt-launch.jar", rtExportJar -> "bin/java9-rt-export.jar") }, mappings in Universal ++= (Def.taskDyn { @@ -260,18 +262,6 @@ lazy val integrationTest = (project in file("integration-test")) testFrameworks += new TestFramework("minitest.runner.Framework") ) -lazy val java9rtexport = (project in file("java9-rt-export")) - .settings( - name := "java9-rt-export", - autoScalaLibrary := false, - crossPaths := false, - description := "Exports the contents of the Java 9. JEP-220 runtime image to a JAR for compatibility with older tools.", - homepage := Some(url("http://github.com/retronym/" + name.value)), - startYear := Some(2017), - licenses += ("Scala license", url(homepage.value.get.toString + "/blob/master/LICENSE")), - mainClass in Compile := Some("io.github.retronym.java9rtexport.Export") - ) - def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching(classOf[Exception]) opt (i.toInt))) match { case Array(0, 11, 3, _*) => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.11.3-2/sbt-launch.jar" case Array(0, 11, x, _*) if x >= 3 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" @@ -357,7 +347,7 @@ lazy val dist = (project in file("dist")) if (sbtVersionToRelease startsWith "0.13.") scala210 else scala212 }, - libraryDependencies ++= Seq(sbtActual, jansi, scala212Compiler, scala212Jline, scala212Xml) ++ sbt013ExtraDeps, + libraryDependencies ++= Seq(sbtActual, java9rtexport, jansi, scala212Compiler, scala212Jline, scala212Xml) ++ sbt013ExtraDeps, exportRepo := { val old = exportRepo.value sbtVersionToRelease match { @@ -387,6 +377,7 @@ lazy val dist = (project in file("dist")) s"$csr fetch --cache $cache ${colonName(jansi)}".! s"$csr fetch --cache $cache ${colonName(scala212Compiler)}".! s"$csr fetch --cache $cache ${colonName(scala212Xml)}".! + s"$csr fetch --cache $cache ${colonName(java9rtexport)}".! val mavenCache = cache / "https" / "repo1.maven.org" / "maven2" val compilerBridgeVer = IO.listFiles(mavenCache / "org" / "scala-sbt" / "compiler-bridge_2.12", DirectoryFilter).toList.headOption compilerBridgeVer match { diff --git a/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java b/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java deleted file mode 100644 index 806ab7d2b..000000000 --- a/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/Export.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.github.retronym.java9rtexport; - -import java.io.IOException; -import java.net.URI; -import java.nio.file.*; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -public class Export { - public static void main(String[] args) { - try { - if (args.length == 0) { - System.err.println("Usage:"); - System.err.println(" java -jar java9-rt-export-*.jar $HOME/.sbt/java9-rt-ext/rt.jar"); - System.err.println(" Exports rt.jar to the specified path."); - System.err.println(""); - System.err.println(" java -jar java9-rt-export-*.jar --rt-ext-dir"); - System.err.println(" Prints sbt global base."); - System.exit(-1); - } - String destination = args[0]; - Path defaultGlobalBase = Paths.get(System.getProperty("user.home"), ".sbt", "0.13"); - String globalBase = System.getProperty("sbt.global.base", defaultGlobalBase.toString()); - if (destination.equals("--global-base")) { - System.out.println(globalBase); - System.exit(0); - } - if (destination.equals("--rt-ext-dir")) { - String v = System.getProperty("java.vendor") + "_" + System.getProperty("java.version"); - v = v.replaceAll("\\W", "_").toLowerCase(); - /* - * The launch script greps for output starting with "java9-rt-ext-" so changing this - * string will require changing the grep command in sbt-launch-lib.bash. - */ - Path rtExtDir = Paths.get(globalBase, "java9-rt-ext-" + v); - System.out.println(rtExtDir.toString()); - System.exit(0); - } - FileSystem fileSystem = FileSystems.getFileSystem(URI.create("jrt:/")); - Path path = fileSystem.getPath("/modules"); - Path destPath = Paths.get(destination); - URI uri = URI.create( "jar:" + destPath.toUri() ); - Map env = new HashMap<>(); - env.put( "create", "true" ); - try ( FileSystem zipfs = FileSystems.newFileSystem( uri, env ) ) { - Iterator iterator = Files.list(path).iterator(); - while(iterator.hasNext()) { - Path next = iterator.next(); - IO.copyDirectory(next, zipfs.getPath("/")); - } - } - } catch (IOException e) { - e.printStackTrace(); - System.exit(-1); - } - } -} diff --git a/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/IO.java b/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/IO.java deleted file mode 100644 index a57eaa392..000000000 --- a/java9-rt-export/src/main/java/io/github/retronym/java9rtexport/IO.java +++ /dev/null @@ -1,49 +0,0 @@ -package io.github.retronym.java9rtexport; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.file.*; -import java.nio.file.attribute.*; -import java.util.EnumSet; - -import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES; -import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; - -public class IO { - public static void copyDirectory(final Path source, final Path target) - throws IOException { - Files.walkFileTree(source, EnumSet.of(FileVisitOption.FOLLOW_LINKS), - Integer.MAX_VALUE, new FileVisitor() { - - @Override - public FileVisitResult preVisitDirectory(Path dir, - BasicFileAttributes sourceBasic) throws IOException { - - String relative = source.relativize(dir).toString(); - if (!Files.exists(target.getFileSystem().getPath(relative))) - Files.createDirectory(target.getFileSystem().getPath(relative)); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult visitFile(Path file, - BasicFileAttributes attrs) throws IOException { - String relative = source.relativize(file).toString(); - Files.copy(file, target.getFileSystem().getPath(relative), COPY_ATTRIBUTES, REPLACE_EXISTING); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult visitFileFailed(Path file, IOException e) throws IOException { - throw e; - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException { - if (e != null) throw e; - return FileVisitResult.CONTINUE; - } - }); - } - -} From cfc8ca7d67547bd90dba623f10907ac812d2a07c Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 19 Sep 2020 22:18:49 -0400 Subject: [PATCH 445/483] Use HTTPS --- build.sbt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index 421e5a1a7..98b8e2f6b 100755 --- a/build.sbt +++ b/build.sbt @@ -266,19 +266,19 @@ lazy val java9rtexport = (project in file("java9-rt-export")) autoScalaLibrary := false, crossPaths := false, description := "Exports the contents of the Java 9. JEP-220 runtime image to a JAR for compatibility with older tools.", - homepage := Some(url("http://github.com/retronym/" + name.value)), + homepage := Some(url("https://github.com/retronym/" + name.value)), startYear := Some(2017), licenses += ("Scala license", url(homepage.value.get.toString + "/blob/master/LICENSE")), mainClass in Compile := Some("io.github.retronym.java9rtexport.Export") ) def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching(classOf[Exception]) opt (i.toInt))) match { - case Array(0, 11, 3, _*) => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.11.3-2/sbt-launch.jar" - case Array(0, 11, x, _*) if x >= 3 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" - case Array(0, y, _*) if y >= 12 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" - case Array(1, _, _*) if v contains ("-20") => "http://repo.scala-sbt.org/scalasbt/maven-snapshots/org/scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" - case Array(1, _, _*) => "http://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" - case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" + case Array(0, 11, 3, _*) => "https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.11.3-2/sbt-launch.jar" + case Array(0, 11, x, _*) if x >= 3 => "https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" + case Array(0, y, _*) if y >= 12 => "https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" + case Array(1, _, _*) if v contains ("-20") => "https://repo.scala-sbt.org/scalasbt/maven-snapshots/org/scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" + case Array(1, _, _*) => "https://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" + case _ => "https://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" } def makePublishToForConfig(config: Configuration) = { From 2514a25013e37d216be5efdb1b3d677643cb2407 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 20 Sep 2020 13:13:19 -0400 Subject: [PATCH 446/483] Bump 1.3 version used for testing --- .travis.yml | 2 +- integration-test/src/test/scala/RunnerTest.scala | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 884261bad..f66d9e45c 100755 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ scala: 2.10.7 env: global: - - SBT_VER=1.3.10 + - SBT_VER=1.3.13 - TRAVIS_JDK=adopt@1.8.0-222 - JABBA_HOME=$HOME/.jabba - TRAVIS_JDK11=openjdk@1.11.0 diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index f94c26e76..ff340e751 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -69,8 +69,8 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { } test("sbt --sbt-version") { - val out = sbtProcess("--sbt-version", "1.3.0", "compile", "-v").!!.linesIterator.toList - assert(out.contains[String]("-Dsbt.version=1.3.0")) + val out = sbtProcess("--sbt-version", "1.3.13", "compile", "-v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.version=1.3.13")) () } From 2def5ef636ab3eeb74a459f3ebdd0c947e056c5e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 19 Sep 2020 22:03:23 -0400 Subject: [PATCH 447/483] sbtn support Ref https://github.com/sbt/sbt/issues/5665 This implements `--client` option to use `sbt` script as the sbtn runner. The build user can also set the env variable `SBT_NATIVE_CLIENT` to `true`. The script will attempt to parse `project/build.properties` and use sbtn only when it's sbt 1.4 or above. --- .gitignore | 1 + build.sbt | 63 +++++++++- citest/build.sbt | 8 +- citest/project/build.properties | 2 +- .../src/test/scala/RunnerTest.scala | 16 +++ src/universal/bin/sbt | 112 ++++++++++++++---- src/universal/bin/sbt.bat | 71 +++++++++++ 7 files changed, 246 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 48633bd52..aa7261561 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ src_managed *~ /citest/freshly-baked/ /upload/cookies +.bsp diff --git a/build.sbt b/build.sbt index 789fc6c48..0f2fe30bc 100755 --- a/build.sbt +++ b/build.sbt @@ -41,6 +41,9 @@ val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url") val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") val moduleID = (organization) apply { (o) => ModuleID(o, "sbt", sbtVersionToRelease) } +val sbtnVersion = SettingKey[String]("sbtn-version") +val sbtnJarsMappings = TaskKey[Seq[(File, String)]]("sbtn-jars", "Resolves sbtn JARs") +val sbtnJarsBaseUrl = SettingKey[String]("sbtn-jars-base-url") lazy val bintrayDebianUrl = settingKey[String]("API point for Debian packages") lazy val bintrayDebianExperimentalUrl = settingKey[String]("API point for Debian experimental packages") @@ -58,6 +61,13 @@ val debianBuildId = settingKey[Int]("build id for Debian") val exportRepoUsingCoursier = taskKey[File]("export Maven style repository") val exportRepoCsrDirectory = settingKey[File]("") +val x86MacPlatform = "x86_64-apple-darwin" +val x86LinuxPlatform = "x86_64-pc-linux" +val x86WindowsPlatform = "x86_64-pc-win32" +val x86MacImageName = s"sbtn-$x86MacPlatform" +val x86LinuxImageName = s"sbtn-$x86LinuxPlatform" +val x86WindowsImageName = s"sbtn-$x86WindowsPlatform.exe" + // This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution. val root = (project in file(".")). enablePlugins(UniversalPlugin, LinuxPlugin, DebianPlugin, RpmPlugin, WindowsPlugin, @@ -99,6 +109,54 @@ val root = (project in file(".")). // TODO - GPG Trust validation. file }, + sbtnVersion := "1.4.0-M2", + sbtnJarsBaseUrl := "https://github.com/sbt/sbtn-dist/releases/download", + sbtnJarsMappings := { + val baseUrl = sbtnJarsBaseUrl.value + val v = sbtnVersion.value + val macosImageTar = s"sbtn-darwin-amd64-$v.tar.gz" + val linuxImageTar = s"sbtn-linux-amd64-$v.tar.gz" + val windowsImageZip = s"sbtn-windows-amd64-$v.zip" + val t = target.value + val macosTar = t / macosImageTar + val linuxTar = t / linuxImageTar + val windowsZip = t / windowsImageZip + import dispatch.classic._ + if(!macosTar.exists && !isWindows) { + IO.touch(macosTar) + val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(macosTar)) + try Http(url(s"$baseUrl/v$v/$macosImageTar") >>> writer) + finally writer.close() + val platformDir = t / x86MacPlatform + IO.createDirectory(platformDir) + s"tar zxvf $macosTar --directory $platformDir".! + IO.move(platformDir / "sbtn", t / x86MacImageName) + } + if(!linuxTar.exists && !isWindows) { + IO.touch(linuxTar) + val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(linuxTar)) + try Http(url(s"$baseUrl/v$v/$linuxImageTar") >>> writer) + finally writer.close() + val platformDir = t / x86LinuxPlatform + IO.createDirectory(platformDir) + s"""tar zxvf $linuxTar --directory $platformDir""".! + IO.move(platformDir / "sbtn", t / x86LinuxImageName) + } + if(!windowsZip.exists) { + IO.touch(windowsZip) + val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(windowsZip)) + try Http(url(s"$baseUrl/v$v/$windowsImageZip") >>> writer) + finally writer.close() + val platformDir = t / x86WindowsPlatform + IO.unzip(windowsZip, platformDir) + IO.move(platformDir / "sbtn.exe", t / x86WindowsImageName) + } + if (isWindows) Seq(t / x86WindowsImageName -> s"bin/$x86WindowsImageName") + else + Seq(t / x86MacImageName -> s"bin/$x86MacImageName", + t / x86LinuxImageName -> s"bin/$x86LinuxImageName", + t / x86WindowsImageName -> s"bin/$x86WindowsImageName") + }, // GENERAL LINUX PACKAGING STUFFS maintainer := "Eugene Yokota ", @@ -210,7 +268,10 @@ val root = (project in file(".")). mappings in Universal ++= { val launchJar = sbtLaunchJar.value val rtExportJar = ((exportRepoCsrDirectory in dist).value / "org/scala-sbt/rt/java9-rt-export" / java9rtexportVersion / s"java9-rt-export-${java9rtexportVersion}.jar") - Seq(launchJar -> "bin/sbt-launch.jar", rtExportJar -> "bin/java9-rt-export.jar") + Seq( + launchJar -> "bin/sbt-launch.jar", + rtExportJar -> "bin/java9-rt-export.jar" + ) ++ sbtnJarsMappings.value }, mappings in Universal ++= (Def.taskDyn { if (sbtOfflineInstall && sbtVersionToRelease.startsWith("1.")) diff --git a/citest/build.sbt b/citest/build.sbt index c6f2f6ac5..cd4f0ab9f 100644 --- a/citest/build.sbt +++ b/citest/build.sbt @@ -11,11 +11,9 @@ lazy val root = (project in file(".")) val xs = IO.readLines(file("output.txt")).toVector println(xs) - assert(xs(0) startsWith "[info] Loading project definition") - assert(xs(1) startsWith "[info] Loading settings") - assert(xs(2) startsWith "[info] Set current project to Hello") - assert(xs(3) startsWith "[info] This is sbt") - assert(xs(4) startsWith "[info] The current project") + assert(xs(0) contains "welcome to sbt") + assert(xs(1) contains "loading project definition") + assert(xs(2) contains "loading settings") val ys = IO.readLines(file("err.txt")).toVector.distinct diff --git a/citest/project/build.properties b/citest/project/build.properties index 797e7ccfd..ea379cf2d 100644 --- a/citest/project/build.properties +++ b/citest/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.10 +sbt.version=1.4.0-RC1 diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index ff340e751..b87f723b5 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -213,4 +213,20 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { assert(out.contains[String]("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=12345")) () } + + test("sbt --client") { + val out = sbtProcess("--client", "--no-colors", "compile").!!.linesIterator.toList + if (isWindows) { + println(out) + } else { + assert(out exists { _.contains("server was not detected") }) + } + val out2 = sbtProcess("--client", "--no-colors", "shutdown").!!.linesIterator.toList + if (isWindows) { + println(out) + } else { + assert(out2 exists { _.contains("disconnected") }) + } + () + } } diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index a3f9443e3..cc8d830e8 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -9,6 +9,7 @@ declare -a sbt_options declare -a print_version declare -a print_sbt_version declare -a print_sbt_script_version +declare -a original_args declare java_cmd=java declare java_version declare init_sbt_version=_to_be_replaced @@ -17,6 +18,9 @@ declare -r default_sbt_opts="" declare -r default_java_opts="-Dfile.encoding=UTF-8" declare sbt_verbose= declare sbt_debug= +declare build_props_sbt_version= +declare use_sbtn= +declare sbtn_command="$SBTN_CMD" ### ------------------------------- ### ### Helper methods for BASH scripts ### @@ -350,25 +354,6 @@ copyRt() { } run() { - java_args=($JAVA_OPTS) - sbt_options0=(${SBT_OPTS:-$default_sbt_opts}) - - # Split SBT_OPTS into options/commands - miniscript=$(map_args "${sbt_options0[@]}") && eval "${miniscript/options/sbt_options}" && \ - eval "${miniscript/commands/sbt_additional_commands}" - - # Combine command line options/commands and commands from SBT_OPTS - miniscript=$(map_args "$@") && eval "${miniscript/options/cli_options}" && eval "${miniscript/commands/cli_commands}" - args1=( "${cli_options[@]}" "${cli_commands[@]}" "${sbt_additional_commands[@]}" ) - - # process the combined args, then reset "$@" to the residuals - process_args "${args1[@]}" - vlog "[sbt_options] $(declare -p sbt_options)" - - addDefaultMemory - set -- "${residual_args[@]}" - argumentCount=$# - # Copy preloaded repo to user's preloaded directory syncPreloaded @@ -420,6 +405,7 @@ run() { declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" declare -r sbt_opts_file=".sbtopts" +declare -r build_props_file="$(pwd)/project/build.properties" declare -r etc_sbt_opts_file="/etc/sbt/sbtopts" # this allows /etc/sbt/sbtopts location to be changed declare -r etc_file="${SBT_ETC_FILE:-$etc_sbt_opts_file}" @@ -549,6 +535,8 @@ process_args () { --numeric-version) print_sbt_version=1 && shift ;; --script-version) print_sbt_script_version=1 && shift ;; -d|-debug|--debug) sbt_debug=1 && addSbt "-debug" && shift ;; + --client) use_sbtn=1 && shift ;; + --server) use_sbtn=0 && shift ;; -ivy|--ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; -mem|--mem) require_arg integer "$1" "$2" && addMemory "$2" && shift 2 ;; @@ -587,6 +575,60 @@ loadConfigFile() { done } +loadPropFile() { + while IFS='=' read -r k v; do + if [[ "$k" == "sbt.version" ]]; then + build_props_sbt_version="$v" + fi + done <<< "$(cat "$1" | sed $'/^\#/d;s/\r$//')" +} + +detectNativeClient() { + if [[ "$sbtn_command" != "" ]]; then + : + elif [[ "$OSTYPE" == "linux-gnu"* ]]; then + [[ -f "${sbt_bin_dir}/sbtn-x86_64-pc-linux" ]] && sbtn_command="${sbt_bin_dir}/sbtn-x86_64-pc-linux" + elif [[ "$OSTYPE" == "darwin"* ]]; then + [[ -f "${sbt_bin_dir}/sbtn-x86_64-apple-darwin" ]] && sbtn_command="${sbt_bin_dir}/sbtn-x86_64-apple-darwin" + elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then + [[ -f "${sbt_bin_dir}/sbtn-x86_64-pc-win32.exe" ]] && sbtn_command="${sbt_bin_dir}/sbtn-x86_64-pc-win32.exe" + elif [[ "$OSTYPE" == "freebsd"* ]]; then + : + else + : + fi +} + +# Run native client if build.properties points to 1.4+ and has SBT_NATIVE_CLIENT +isRunNativeClient() { + sbtV="$build_props_sbt_version" + [[ "$sbtV" == "" ]] && sbtV="$init_sbt_version" + [[ "$sbtV" == "" ]] && sbtV="0.0.0" + sbtBinaryV_1=$(echo "$sbtV" | sed 's/^\([0-9]*\)\.\([0-9]*\).*$/\1/') + sbtBinaryV_2=$(echo "$sbtV" | sed 's/^\([0-9]*\)\.\([0-9]*\).*$/\2/') + if (( $sbtBinaryV_1 >= 2 )) || ( (( $sbtBinaryV_1 >= 1 )) && (( $sbtBinaryV_2 >= 4 )) ); then + if [[ "$use_sbtn" == "1" ]] && [[ "$sbtn_command" != "" ]]; then + echo "true" + else + echo "false" + fi + else + echo "false" + fi +} + +runNativeClient() { + vlog "[debug] running native client" + for i in "${!original_args[@]}"; do + if [[ "${original_args[i]}" = "--client" ]]; then + unset 'original_args[i]' + fi + done + execRunner "$sbtn_command" "${original_args[@]}" +} + +original_args=("$@") + # Here we pull in the default settings configuration. [[ -f "$dist_sbt_opts_file" ]] && set -- $(loadConfigFile "$dist_sbt_opts_file") "$@" @@ -602,4 +644,34 @@ loadConfigFile() { # Pull in default JAVA_OPTS [[ -z "${JAVA_OPTS// }" ]] && export JAVA_OPTS="$default_java_opts" -run "$@" +[[ -f "$build_props_file" ]] && loadPropFile "$build_props_file" + +detectNativeClient + +java_args=($JAVA_OPTS) +sbt_options0=(${SBT_OPTS:-$default_sbt_opts}) +if [[ "$SBT_NATIVE_CLIENT" == "true" ]]; then + use_sbtn=1 +fi + +# Split SBT_OPTS into options/commands +miniscript=$(map_args "${sbt_options0[@]}") && eval "${miniscript/options/sbt_options}" && \ +eval "${miniscript/commands/sbt_additional_commands}" + +# Combine command line options/commands and commands from SBT_OPTS +miniscript=$(map_args "$@") && eval "${miniscript/options/cli_options}" && eval "${miniscript/commands/cli_commands}" +args1=( "${cli_options[@]}" "${cli_commands[@]}" "${sbt_additional_commands[@]}" ) + +# process the combined args, then reset "$@" to the residuals +process_args "${args1[@]}" +vlog "[sbt_options] $(declare -p sbt_options)" + +addDefaultMemory +set -- "${residual_args[@]}" +argumentCount=$# + +if [[ "$(isRunNativeClient)" == "true" ]]; then + runNativeClient +else + run +fi diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 2f09cfdd6..e868271ba 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -23,6 +23,8 @@ set sbt_default_mem=1024 set default_sbt_opts= set default_java_opts=-Dfile.encoding=UTF-8 set sbt_jar= +set build_props_sbt_version= +set run_native_client= set sbt_args_print_version= set sbt_args_print_sbt_version= @@ -44,6 +46,7 @@ set sbt_args_sbt_create= set sbt_args_sbt_dir= set sbt_args_sbt_version= set sbt_args_mem= +set sbt_args_client= rem users can set SBT_OPTS via .sbtopts if exist .sbtopts for /F %%A in (.sbtopts) do ( @@ -77,6 +80,14 @@ if defined JAVA_HOMES ( ) ) +if exist "project\build.properties" ( + for /F "eol=# delims== tokens=1*" %%a in (project\build.properties) do ( + if "%%a" == "sbt.version" if not "%%b" == "" ( + set build_props_sbt_version=%%b + ) + ) +) + rem must set PATH or wrong javac is used for java projects if defined JAVA_HOME set "PATH=%JAVA_HOME%\bin;%PATH%" @@ -115,6 +126,12 @@ if not defined _SBT_OPTS if defined SBT_OPTS set _SBT_OPTS=%SBT_OPTS% if not defined _SBT_OPTS if defined SBT_CFG_OPTS set _SBT_OPTS=!SBT_CFG_OPTS! if not defined _SBT_OPTS if defined default_sbt_opts set _SBT_OPTS=!default_sbt_opts! +if defined SBT_NATIVE_CLIENT ( + if "%SBT_NATIVE_CLIENT%" == "true" ( + set sbt_args_client=1 + ) +) + :args_loop shift @@ -156,6 +173,14 @@ if defined _version_arg ( goto args_loop ) +if "%~0" == "--client" set _client_arg=true + +if defined _client_arg ( + set _client_arg= + set sbt_args_client=1 + goto args_loop +) + if "%~0" == "-batch" set _batch_arg=true if "%~0" == "--batch" set _batch_arg=true @@ -495,6 +520,11 @@ if !sbt_args_print_sbt_script_version! equ 1 ( goto :eof ) +if !run_native_client! equ 1 ( + goto :runnative !SBT_ARGS! + goto :eof +) + call :checkjava call :copyrt @@ -607,6 +637,21 @@ if defined sbt_args_verbose ( goto :eof +:runnative + +set "_SBTNCMD=!SBT_BIN_DIR!sbtn-x86_64-pc-win32.exe" + +if defined sbt_args_verbose ( + echo # running native client + if not "%~1" == "" ( call :echolist %* ) +) + +rem Microsoft Visual C++ 2010 SP1 Redistributable Package (x64) is required +rem https://www.microsoft.com/en-us/download/details.aspx?id=13523 +"!_SBTNCMD!" %* + +goto :eof + rem for expression tries to interpret files, so simply loop over %* instead rem fixes dealing with quotes after = args: -Dscala.ext.dirs="C:\Users\First Last\.sbt\0.13\java9-rt-ext-adoptopenjdk_11_0_3" :echolist @@ -772,6 +817,32 @@ for /f "delims=.-_ tokens=1-2" %%v in ("!JAVA_VERSION!") do ( ) ) +rem parse the first two segments of sbt.version and set run_native_client to +rem 1 if the user has also indicated they want to use native client. +set sbtV=!build_props_sbt_version! +set sbtBinaryV_1= +set sbtBinaryV_2= +for /F "delims=.-_ tokens=1-2" %%v in ("!sbtV!") do ( + set sbtBinaryV_1=%%v + set sbtBinaryV_2=%%w +) +set native_client_ready= +if !sbtBinaryV_1! geq 2 ( + set native_client_ready=1 +) else ( + if !sbtBinaryV_1! geq 1 ( + if !sbtBinaryV_2! geq 4 ( + set native_client_ready=1 + ) + ) +) +if !native_client_ready! equ 1 ( + if !sbt_args_client! equ 1 ( + set run_native_client=1 + ) +) +set native_client_ready= + exit /B 0 :checkjava From e8808297629ecf95db143fbf70e51f6e7da1850f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 20 Sep 2020 20:15:35 -0400 Subject: [PATCH 448/483] Use the real sbt --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index f66d9e45c..0fe2a3dea 100755 --- a/.travis.yml +++ b/.travis.yml @@ -70,6 +70,9 @@ install: - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" - java -Xmx32m -version - unset SBT_OPTS + - curl https://piccolo.link/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip + - unzip /tmp/sbt.zip -d $HOME/sbt + - export PATH="$HOME/sbt/sbt/bin:$PATH" cache: directories: From 8559b0ece703fbd555e87662ea0a2252f7394c78 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 20 Sep 2020 20:39:48 -0400 Subject: [PATCH 449/483] Exclude sbtn from RPM file --- build.sbt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build.sbt b/build.sbt index 0f2fe30bc..106a5a7a6 100755 --- a/build.sbt +++ b/build.sbt @@ -203,6 +203,14 @@ val root = (project in file(".")). }) else stable }, + // remove sbtn from RPM because it complains about it being noarch + linuxPackageMappings in Rpm := { + val orig = (linuxPackageMappings in Rpm).value + val nativeMappings = sbtnJarsMappings.value + orig.map(o => o.copy(mappings = o.mappings.toList filterNot { + case (x, p) => p.contains("sbtn-x86_64") + })) + }, rpmVendor := "lightbend", rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"), rpmLicense := Some("BSD"), From adbd541c9707f705d0d0255c02c6c9a41e41292d Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 23 Sep 2020 02:53:13 -0400 Subject: [PATCH 450/483] Update sbtn --- build.sbt | 10 +++++----- citest/project/build.properties | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index 106a5a7a6..4c39051e5 100755 --- a/build.sbt +++ b/build.sbt @@ -42,7 +42,7 @@ val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") val moduleID = (organization) apply { (o) => ModuleID(o, "sbt", sbtVersionToRelease) } val sbtnVersion = SettingKey[String]("sbtn-version") -val sbtnJarsMappings = TaskKey[Seq[(File, String)]]("sbtn-jars", "Resolves sbtn JARs") +val sbtnJarsMappings = TaskKey[Seq[(File, String)]]("sbtn-jars-mappings", "Resolves sbtn JARs") val sbtnJarsBaseUrl = SettingKey[String]("sbtn-jars-base-url") lazy val bintrayDebianUrl = settingKey[String]("API point for Debian packages") @@ -109,14 +109,14 @@ val root = (project in file(".")). // TODO - GPG Trust validation. file }, - sbtnVersion := "1.4.0-M2", + sbtnVersion := "1.4.0-RC2", sbtnJarsBaseUrl := "https://github.com/sbt/sbtn-dist/releases/download", sbtnJarsMappings := { val baseUrl = sbtnJarsBaseUrl.value val v = sbtnVersion.value - val macosImageTar = s"sbtn-darwin-amd64-$v.tar.gz" - val linuxImageTar = s"sbtn-linux-amd64-$v.tar.gz" - val windowsImageZip = s"sbtn-windows-amd64-$v.zip" + val macosImageTar = s"sbtn-$x86MacPlatform-$v.tar.gz" + val linuxImageTar = s"sbtn-$x86LinuxPlatform-$v.tar.gz" + val windowsImageZip = s"sbtn-$x86WindowsPlatform-$v.zip" val t = target.value val macosTar = t / macosImageTar val linuxTar = t / linuxImageTar diff --git a/citest/project/build.properties b/citest/project/build.properties index ea379cf2d..ea3a73ab1 100644 --- a/citest/project/build.properties +++ b/citest/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.0-RC1 +sbt.version=1.4.0-RC2 From 55cd02be036af2dae74c8b8d66cdfd4df3feab53 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 26 Sep 2020 06:38:51 -0400 Subject: [PATCH 451/483] Fix fetching of RT Export Previously it was depending on the side effect of export repo. This doesn't work when we don't construct offline installer. --- build.sbt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 4c39051e5..d05577998 100755 --- a/build.sbt +++ b/build.sbt @@ -59,6 +59,7 @@ val windowsBuildId = settingKey[Int]("build id for Windows installer") val debianBuildId = settingKey[Int]("build id for Debian") val exportRepoUsingCoursier = taskKey[File]("export Maven style repository") +val rtExportUsingCoursier = taskKey[File]("Grab RT export utility") val exportRepoCsrDirectory = settingKey[File]("") val x86MacPlatform = "x86_64-apple-darwin" @@ -244,6 +245,15 @@ val root = (project in file(".")). packageName in Universal := packageName.value, // needs to be set explicitly due to a bug in native-packager version in Universal := sbtVersionToRelease, + rtExportUsingCoursier := { + val csr = + if (isWindows) (baseDirectory in LocalRootProject).value / "bin" / "coursier.bat" + else (baseDirectory in LocalRootProject).value / "bin" / "coursier" + val cache = target.value / "coursier" + s"$csr fetch --cache $cache ${colonName(java9rtexport)}".! + (cache ** "*.jar").get.head + }, + mappings in Universal := { val t = (target in Universal).value val prev = (mappings in Universal).value @@ -275,7 +285,7 @@ val root = (project in file(".")). mappings in Universal ++= { val launchJar = sbtLaunchJar.value - val rtExportJar = ((exportRepoCsrDirectory in dist).value / "org/scala-sbt/rt/java9-rt-export" / java9rtexportVersion / s"java9-rt-export-${java9rtexportVersion}.jar") + val rtExportJar = rtExportUsingCoursier.value Seq( launchJar -> "bin/sbt-launch.jar", rtExportJar -> "bin/java9-rt-export.jar" @@ -446,7 +456,6 @@ lazy val dist = (project in file("dist")) s"$csr fetch --cache $cache ${colonName(jansi)}".! s"$csr fetch --cache $cache ${colonName(scala212Compiler)}".! s"$csr fetch --cache $cache ${colonName(scala212Xml)}".! - s"$csr fetch --cache $cache ${colonName(java9rtexport)}".! val mavenCache = cache / "https" / "repo1.maven.org" / "maven2" val compilerBridgeVer = IO.listFiles(mavenCache / "org" / "scala-sbt" / "compiler-bridge_2.12", DirectoryFilter).toList.headOption compilerBridgeVer match { From 0e459fc9f3f8cd5fd2ef9e2f362ea45075517156 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 26 Sep 2020 07:13:49 -0400 Subject: [PATCH 452/483] Resolve Coursier first? --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0fe2a3dea..7d8675b1a 100755 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ matrix: - curl https://piccolo.link/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip - unzip /tmp/sbt.zip -d $HOME/sbt - export PATH="$HOME/sbt/sbt/bin:$PATH" + - bin/coursier.bat resolve script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - cd citest @@ -45,6 +46,7 @@ matrix: - curl https://piccolo.link/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip - unzip /tmp/sbt.zip -d $HOME/sbt - export PATH="$HOME/sbt/sbt/bin:$PATH" + - bin/coursier resolve script: - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - cd citest && ./test.sh @@ -73,6 +75,7 @@ install: - curl https://piccolo.link/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip - unzip /tmp/sbt.zip -d $HOME/sbt - export PATH="$HOME/sbt/sbt/bin:$PATH" + - bin/coursier resolve cache: directories: From a7c034aa99db557719a5bdde2dd9fa3e4f269d33 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Thu, 24 Sep 2020 11:29:15 +0200 Subject: [PATCH 453/483] Fix handling of `--no-share` option Using `--no-share` as a command line option resulted in a single additional argument added to the java command: `-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy` Actually, three separate arguments need to be added. --- integration-test/src/test/scala/RunnerTest.scala | 8 ++++++++ src/universal/bin/sbt | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index b87f723b5..a5973cd09 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -229,4 +229,12 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { } () } + + test("sbt --no-share adds three system properties") { + val out = sbtProcess("--no-share").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.global.base=project/.sbtboot")) + assert(out.contains[String]("-Dsbt.boot.directory=project/.boot")) + assert(out.contains[String]("-Dsbt.ivy.home=project/.ivy")) + () + } } diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index cc8d830e8..ae5a56c4b 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -403,7 +403,7 @@ run() { exit $exit_code } -declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" +declare -ra noshare_opts=(-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy) declare -r sbt_opts_file=".sbtopts" declare -r build_props_file="$(pwd)/project/build.properties" declare -r etc_sbt_opts_file="/etc/sbt/sbtopts" @@ -513,7 +513,7 @@ map_args () { -supershell=*) options=( "${options[@]}" "-Dsbt.supershell=${1:12}" ) && shift ;; --color=*) options=( "${options[@]}" "-Dsbt.color=${1:8}" ) && shift ;; -color=*) options=( "${options[@]}" "-Dsbt.color=${1:7}" ) && shift ;; - -no-share|--no-share) options=( "${options[@]}" "$noshare_opts" ) && shift ;; + -no-share|--no-share) options=( "${options[@]}" "${noshare_opts[@]}" ) && shift ;; -no-global|--no-global) options=( "${options[@]}" "-Dsbt.global.base=$(pwd)/project/.sbtboot" ) && shift ;; -sbt-boot|--sbt-boot) require_arg path "$1" "$2" && options=( "${options[@]}" "-Dsbt.boot.directory=$2" ) && shift 2 ;; -sbt-dir|--sbt-dir) require_arg path "$1" "$2" && options=( "${options[@]}" "-Dsbt.global.base=$2" ) && shift 2 ;; From 234273db418f46b357c2044cf8558b909106ea19 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Thu, 24 Sep 2020 11:30:53 +0200 Subject: [PATCH 454/483] Handle `--ivy` option in `SBT_OPTS` too Fixes sbt/sbt#5885 --- integration-test/src/test/scala/RunnerTest.scala | 6 ++++++ src/universal/bin/sbt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index a5973cd09..5e0133de3 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -237,4 +237,10 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { assert(out.contains[String]("-Dsbt.ivy.home=project/.ivy")) () } + + test("accept `--ivy` in `SBT_OPTS`") { + val out = sbtProcessWithOpts("")("", sbtOpts = "--ivy /ivy/dir").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.ivy.home=/ivy/dir")) + () + } } diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index ae5a56c4b..1a046a9d6 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -515,6 +515,7 @@ map_args () { -color=*) options=( "${options[@]}" "-Dsbt.color=${1:7}" ) && shift ;; -no-share|--no-share) options=( "${options[@]}" "${noshare_opts[@]}" ) && shift ;; -no-global|--no-global) options=( "${options[@]}" "-Dsbt.global.base=$(pwd)/project/.sbtboot" ) && shift ;; + -ivy|--ivy) require_arg path "$1" "$2" && options=( "${options[@]}" "-Dsbt.ivy.home=$2" ) && shift 2 ;; -sbt-boot|--sbt-boot) require_arg path "$1" "$2" && options=( "${options[@]}" "-Dsbt.boot.directory=$2" ) && shift 2 ;; -sbt-dir|--sbt-dir) require_arg path "$1" "$2" && options=( "${options[@]}" "-Dsbt.global.base=$2" ) && shift 2 ;; -debug|--debug) commands=( "${commands[@]}" "-debug" ) && shift ;; @@ -538,7 +539,6 @@ process_args () { --client) use_sbtn=1 && shift ;; --server) use_sbtn=0 && shift ;; - -ivy|--ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; -mem|--mem) require_arg integer "$1" "$2" && addMemory "$2" && shift 2 ;; -jvm-debug|--jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; -batch|--batch) exec Date: Sun, 27 Sep 2020 22:46:03 +0200 Subject: [PATCH 455/483] Add `java` mock scripts to avoid running a JVM during tests The script simply prints out each argument in an unambigous form on a single line and handles to the `--version` option. For windows, add `java.cmd` script which simply calls the former `java` script. --- integration-test/bin/java | 9 +++++++++ integration-test/bin/java.cmd | 1 + 2 files changed, 10 insertions(+) create mode 100755 integration-test/bin/java create mode 100644 integration-test/bin/java.cmd diff --git a/integration-test/bin/java b/integration-test/bin/java new file mode 100755 index 000000000..56920a236 --- /dev/null +++ b/integration-test/bin/java @@ -0,0 +1,9 @@ +#!/usr/bin/env python + +import sys + +if '--version' in sys.argv or '-version' in sys.argv: + print 'openjdk version "1.8.0_212"' +else: + for arg in sys.argv[1:]: + print(repr(arg)[1:-1]) diff --git a/integration-test/bin/java.cmd b/integration-test/bin/java.cmd new file mode 100644 index 000000000..4b214dbf6 --- /dev/null +++ b/integration-test/bin/java.cmd @@ -0,0 +1 @@ +@python "%~dp0%~n0" %* From eb38ac57e7b4fd1ea06eee08767684bc6a92f830 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Sun, 27 Sep 2020 22:49:25 +0200 Subject: [PATCH 456/483] Split up integration tests Separate them into those that do not need to run a JVM, using the newly added `java` script, and those that really need to run the sbt-launch.jar --- .../src/test/scala/RunnerTest.scala | 158 ---------------- .../src/test/scala/ScriptTest.scala | 175 ++++++++++++++++++ 2 files changed, 175 insertions(+), 158 deletions(-) create mode 100644 integration-test/src/test/scala/ScriptTest.scala diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 5e0133de3..81386e990 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -26,134 +26,6 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } - test("sbt -no-colors") { - val out = sbtProcess("compile", "-no-colors", "-v").!!.linesIterator.toList - assert(out.contains[String]("-Dsbt.log.noformat=true")) - () - } - - test("sbt --no-colors") { - val out = sbtProcess("compile", "--no-colors", "-v").!!.linesIterator.toList - assert(out.contains[String]("-Dsbt.log.noformat=true")) - () - } - - test("sbt --color=false") { - val out = sbtProcess("compile", "--color=false", "-v").!!.linesIterator.toList - assert(out.contains[String]("-Dsbt.color=false")) - () - } - - test("sbt --debug-inc") { - val out = sbtProcess("compile", "--debug-inc", "-v").!!.linesIterator.toList - assert(out.contains[String]("-Dxsbt.inc.debug=true")) - () - } - - test("sbt --supershell=never") { - val out = sbtProcess("compile", "--supershell=never", "-v").!!.linesIterator.toList - assert(out.contains[String]("-Dsbt.supershell=never")) - () - } - - test("sbt --timings") { - val out = sbtProcess("compile", "--timings", "-v").!!.linesIterator.toList - assert(out.contains[String]("-Dsbt.task.timings=true")) - () - } - - test("sbt -D arguments") { - val out = sbtProcess("-Dsbt.supershell=false", "compile", "-v").!!.linesIterator.toList - assert(out.contains[String]("-Dsbt.supershell=false")) - () - } - - test("sbt --sbt-version") { - val out = sbtProcess("--sbt-version", "1.3.13", "compile", "-v").!!.linesIterator.toList - assert(out.contains[String]("-Dsbt.version=1.3.13")) - () - } - - test("sbt -mem 503") { - val out = sbtProcess("compile", "-mem", "503", "-v").!!.linesIterator.toList - assert(out.contains[String]("-Xmx503m")) - () - } - - test("sbt with -mem 503, -Xmx in JAVA_OPTS") { - val out = sbtProcessWithOpts("compile", "-mem", "503", "-v")("-Xmx1024m", "").!!.linesIterator.toList - assert(out.contains[String]("-Xmx503m")) - assert(!out.contains[String]("-Xmx1024m")) - () - } - - test("sbt with -mem 503, -Xmx in SBT_OPTS") { - val out = sbtProcessWithOpts("compile", "-mem", "503", "-v")("", "-Xmx1024m").!!.linesIterator.toList - assert(out.contains[String]("-Xmx503m")) - assert(!out.contains[String]("-Xmx1024m")) - () - } - - test("sbt with -Xms2048M -Xmx2048M -Xss6M in SBT_OPTS") { - val out = sbtProcessWithOpts("compile", "-v")("", "-Xms2048M -Xmx2048M -Xss6M").!!.linesIterator.toList - assert(out.contains[String]("-Xss6M")) - () - } - - test("sbt with -Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080 in SBT_OPTS") { - val out = sbtProcessWithOpts("compile", "-v")("", "-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080").!!.linesIterator.toList - assert(out.contains[String]("-Dhttp.proxyHost=proxy")) - assert(out.contains[String]("-Dhttp.proxyPort=8080")) - () - } - - test("sbt with -XX:ParallelGCThreads=16 -XX:PermSize=128M in SBT_OPTS") { - val out = sbtProcessWithOpts("compile", "-v")("", "-XX:ParallelGCThreads=16 -XX:PermSize=128M").!!.linesIterator.toList - assert(out.contains[String]("-XX:ParallelGCThreads=16")) - assert(out.contains[String]("-XX:PermSize=128M")) - () - } - - test("sbt with -XX:+UseG1GC -XX:+PrintGC in SBT_OPTS") { - val out = sbtProcessWithOpts("compile", "-v")("", "-XX:+UseG1GC -XX:+PrintGC").!!.linesIterator.toList - assert(out.contains[String]("-XX:+UseG1GC")) - assert(out.contains[String]("-XX:+PrintGC")) - assert(!out.contains[String]("-XX:+UseG1GC=-XX:+PrintGC")) - () - } - - test("sbt with -XX:-UseG1GC -XX:-PrintGC in SBT_OPTS") { - val out = sbtProcessWithOpts("compile", "-v")("", "-XX:-UseG1GC -XX:-PrintGC").!!.linesIterator.toList - assert(out.contains[String]("-XX:-UseG1GC")) - assert(out.contains[String]("-XX:-PrintGC")) - assert(!out.contains[String]("-XX:-UseG1GC=-XX:-PrintGC")) - () - } - - test("sbt with --no-colors in SBT_OPTS") { - if (isWindows) cancel("Test not supported on windows") - val out = sbtProcessWithOpts("compile", "-v")("", "--no-colors").!!.linesIterator.toList - assert(out.contains[String]("-Dsbt.log.noformat=true")) - () - } - - test("sbt with -debug in SBT_OPTS appears in sbt commands") { - if (isWindows) cancel("Test not supported on windows") - - val out: List[String] = sbtProcessWithOpts("compile", "-v")("", "-debug").!!.linesIterator.toList - // Debug argument must appear in the 'commands' section (after the sbt-launch.jar argument) to work - val sbtLaunchMatcher = """^.+sbt-launch.jar["]{0,1}$""".r - val locationOfSbtLaunchJarArg = out.zipWithIndex.collectFirst { - case (arg, index) if sbtLaunchMatcher.findFirstIn(arg).nonEmpty => index - } - - assert(locationOfSbtLaunchJarArg.nonEmpty) - - val argsAfterSbtLaunch = out.drop(locationOfSbtLaunchJarArg.get) - assert(argsAfterSbtLaunch.contains("-debug")) - () - } - test("sbt -V|-version|--version should print sbtVersion") { val out = sbtProcess("-version").!!.trim val expectedVersion = @@ -198,22 +70,6 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } - test("quoted * should not glob expand to local files") { - val out = sbtProcess("testOnly * ", "--no-colors", "-v", "-debug").!!.linesIterator.toList - - // Ensure the "*" doesn't get glob expanded to individual files or directories - // (e.g. Hello.scala gets added to the testOnly arguments) https://github.com/sbt/sbt/issues/5343 - assert(!out.exists(x => x.contains("testOnly") && x.contains("Hello.scala"))) - assert(out.contains[String]("[info] HelloTest")) - () - } - - test("sbt --jvm-debug ") { - val out = sbtProcess("--jvm-debug", "12345", "compile", "-v").!!.linesIterator.toList - assert(out.contains[String]("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=12345")) - () - } - test("sbt --client") { val out = sbtProcess("--client", "--no-colors", "compile").!!.linesIterator.toList if (isWindows) { @@ -229,18 +85,4 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { } () } - - test("sbt --no-share adds three system properties") { - val out = sbtProcess("--no-share").!!.linesIterator.toList - assert(out.contains[String]("-Dsbt.global.base=project/.sbtboot")) - assert(out.contains[String]("-Dsbt.boot.directory=project/.boot")) - assert(out.contains[String]("-Dsbt.ivy.home=project/.ivy")) - () - } - - test("accept `--ivy` in `SBT_OPTS`") { - val out = sbtProcessWithOpts("")("", sbtOpts = "--ivy /ivy/dir").!!.linesIterator.toList - assert(out.contains[String]("-Dsbt.ivy.home=/ivy/dir")) - () - } } diff --git a/integration-test/src/test/scala/ScriptTest.scala b/integration-test/src/test/scala/ScriptTest.scala new file mode 100644 index 000000000..2bbbb86b4 --- /dev/null +++ b/integration-test/src/test/scala/ScriptTest.scala @@ -0,0 +1,175 @@ +package example.test + +import minitest._ +import java.io.File + +object SbtScriptTest extends SimpleTestSuite with PowerAssertions { + lazy val isWindows: Boolean = sys.props("os.name").toLowerCase(java.util.Locale.ENGLISH).contains("windows") + lazy val sbtScript = + if (isWindows) new File("target/universal/stage/bin/sbt.bat") + else new File("target/universal/stage/bin/sbt") + + private val javaBinDir = new File("integration-test", "bin").getAbsolutePath + + def sbtProcess(args: String*) = sbtProcessWithOpts(args: _*)("", "") + def sbtProcessWithOpts(args: String*)(javaOpts: String, sbtOpts: String) = { + val path = sys.env("PATH") + sbt.internal.Process(Seq(sbtScript.getAbsolutePath) ++ args, new File("citest"), + "JAVA_OPTS" -> javaOpts, + "SBT_OPTS" -> sbtOpts, + if (isWindows) + "JAVACMD" -> new File(javaBinDir, "java.cmd").getAbsolutePath() + else + "PATH" -> (javaBinDir + File.pathSeparator + path) + ) + } + + test("sbt -no-colors") { + val out = sbtProcess("compile", "-no-colors").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.log.noformat=true")) + () + } + + test("sbt --no-colors") { + val out = sbtProcess("compile", "--no-colors").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.log.noformat=true")) + () + } + + test("sbt --color=false") { + val out = sbtProcess("compile", "--color=false", "-v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.color=false")) + () + } + + test("sbt --debug-inc") { + val out = sbtProcess("compile", "--debug-inc", "-v").!!.linesIterator.toList + assert(out.contains[String]("-Dxsbt.inc.debug=true")) + () + } + + test("sbt --supershell=never") { + val out = sbtProcess("compile", "--supershell=never", "-v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.supershell=never")) + () + } + + test("sbt --timings") { + val out = sbtProcess("compile", "--timings", "-v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.task.timings=true")) + () + } + + test("sbt -D arguments") { + val out = sbtProcess("-Dsbt.supershell=false", "compile", "-v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.supershell=false")) + () + } + + test("sbt --sbt-version") { + val out = sbtProcess("--sbt-version", "1.3.13", "compile", "-v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.version=1.3.13")) + () + } + + test("sbt -mem 503") { + val out = sbtProcess("compile", "-mem", "503", "-v").!!.linesIterator.toList + assert(out.contains[String]("-Xmx503m")) + () + } + + test("sbt with -mem 503, -Xmx in JAVA_OPTS") { + val out = sbtProcessWithOpts("compile", "-mem", "503", "-v")("-Xmx1024m", "").!!.linesIterator.toList + assert(out.contains[String]("-Xmx503m")) + assert(!out.contains[String]("-Xmx1024m")) + () + } + + test("sbt with -mem 503, -Xmx in SBT_OPTS") { + val out = sbtProcessWithOpts("compile", "-mem", "503", "-v")("", "-Xmx1024m").!!.linesIterator.toList + assert(out.contains[String]("-Xmx503m")) + assert(!out.contains[String]("-Xmx1024m")) + () + } + + test("sbt with -Xms2048M -Xmx2048M -Xss6M in SBT_OPTS") { + val out = sbtProcessWithOpts("compile", "-v")("", "-Xms2048M -Xmx2048M -Xss6M").!!.linesIterator.toList + assert(out.contains[String]("-Xss6M")) + () + } + + test("sbt with -Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080 in SBT_OPTS") { + val out = sbtProcessWithOpts("compile", "-v")("", "-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080").!!.linesIterator.toList + assert(out.contains[String]("-Dhttp.proxyHost=proxy")) + assert(out.contains[String]("-Dhttp.proxyPort=8080")) + () + } + + test("sbt with -XX:ParallelGCThreads=16 -XX:PermSize=128M in SBT_OPTS") { + val out = sbtProcessWithOpts("compile", "-v")("", "-XX:ParallelGCThreads=16 -XX:PermSize=128M").!!.linesIterator.toList + assert(out.contains[String]("-XX:ParallelGCThreads=16")) + assert(out.contains[String]("-XX:PermSize=128M")) + () + } + + test("sbt with -XX:+UseG1GC -XX:+PrintGC in SBT_OPTS") { + val out = sbtProcessWithOpts("compile", "-v")("", "-XX:+UseG1GC -XX:+PrintGC").!!.linesIterator.toList + assert(out.contains[String]("-XX:+UseG1GC")) + assert(out.contains[String]("-XX:+PrintGC")) + assert(!out.contains[String]("-XX:+UseG1GC=-XX:+PrintGC")) + () + } + + test("sbt with -XX:-UseG1GC -XX:-PrintGC in SBT_OPTS") { + val out = sbtProcessWithOpts("compile", "-v")("", "-XX:-UseG1GC -XX:-PrintGC").!!.linesIterator.toList + assert(out.contains[String]("-XX:-UseG1GC")) + assert(out.contains[String]("-XX:-PrintGC")) + assert(!out.contains[String]("-XX:-UseG1GC=-XX:-PrintGC")) + () + } + + test("sbt with --no-colors in SBT_OPTS") { + if (isWindows) cancel("Test not supported on windows") + val out = sbtProcessWithOpts("compile", "-v")("", "--no-colors").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.log.noformat=true")) + () + } + + test("sbt with -debug in SBT_OPTS appears in sbt commands") { + if (isWindows) cancel("Test not supported on windows") + + val out: List[String] = sbtProcessWithOpts("compile", "-v")("", "-debug").!!.linesIterator.toList + // Debug argument must appear in the 'commands' section (after the sbt-launch.jar argument) to work + val sbtLaunchMatcher = """^.+sbt-launch.jar["]{0,1}$""".r + val locationOfSbtLaunchJarArg = out.zipWithIndex.collectFirst { + case (arg, index) if sbtLaunchMatcher.findFirstIn(arg).nonEmpty => index + } + + assert(locationOfSbtLaunchJarArg.nonEmpty) + + val argsAfterSbtLaunch = out.drop(locationOfSbtLaunchJarArg.get) + assert(argsAfterSbtLaunch.contains("-debug")) + () + } + + test("sbt --jvm-debug ") { + val out = sbtProcess("--jvm-debug", "12345", "compile", "-v").!!.linesIterator.toList + assert(out.contains[String]("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=12345")) + () + } + + test("sbt --no-share adds three system properties") { + val out = sbtProcess("--no-share").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.global.base=project/.sbtboot")) + assert(out.contains[String]("-Dsbt.boot.directory=project/.boot")) + assert(out.contains[String]("-Dsbt.ivy.home=project/.ivy")) + () + } + + test("accept `--ivy` in `SBT_OPTS`") { + if (isWindows) cancel("Test not supported on windows") + val out = sbtProcessWithOpts("")("", sbtOpts = "--ivy /ivy/dir").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.ivy.home=/ivy/dir")) + () + } +} From 57cf5231aba8ee831edd4c4f2d1fb86b83f409a3 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Thu, 1 Oct 2020 10:42:56 +0200 Subject: [PATCH 457/483] CI: piccolo.link is broken, switch to direct github link It returns a 500 internal server error. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d8675b1a..5d9e56ad5 100755 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ matrix: install: - $JABBA_HOME/bin/jabba.exe install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" - java -Xmx32m -version - - curl https://piccolo.link/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip + - curl --fail https://github.com/sbt/sbt/releases/download/v$SBT_VER/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip - unzip /tmp/sbt.zip -d $HOME/sbt - export PATH="$HOME/sbt/sbt/bin:$PATH" - bin/coursier.bat resolve @@ -43,7 +43,7 @@ matrix: - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK/Contents/Home" && export PATH="$JAVA_HOME/bin:$PATH" - java -Xmx32m -version - unset SBT_OPTS - - curl https://piccolo.link/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip + - curl --fail https://github.com/sbt/sbt/releases/download/v$SBT_VER/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip - unzip /tmp/sbt.zip -d $HOME/sbt - export PATH="$HOME/sbt/sbt/bin:$PATH" - bin/coursier resolve @@ -72,7 +72,7 @@ install: - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" - java -Xmx32m -version - unset SBT_OPTS - - curl https://piccolo.link/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip + - curl --fail https://github.com/sbt/sbt/releases/download/v$SBT_VER/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip - unzip /tmp/sbt.zip -d $HOME/sbt - export PATH="$HOME/sbt/sbt/bin:$PATH" - bin/coursier resolve From 8237eff942fb5f85a7f78694605a422fb07b767a Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 4 Oct 2020 20:13:49 -0400 Subject: [PATCH 458/483] sbtn 1.4.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index d05577998..97244848a 100755 --- a/build.sbt +++ b/build.sbt @@ -110,7 +110,7 @@ val root = (project in file(".")). // TODO - GPG Trust validation. file }, - sbtnVersion := "1.4.0-RC2", + sbtnVersion := "1.4.0", sbtnJarsBaseUrl := "https://github.com/sbt/sbtn-dist/releases/download", sbtnJarsMappings := { val baseUrl = sbtnJarsBaseUrl.value From 75257e759b455552c3007df1ec13c351ff1db2f5 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 19 Oct 2020 15:13:23 -0400 Subject: [PATCH 459/483] Fix sbt --client slowness Before: ``` $ time sbt --client exit [info] entering *experimental* thin client - BEEP WHIRR [info] terminate the server with `shutdown` sbt --client exit 0.16s user 0.15s system 101% cpu 0.303 total ``` sbt --client was running around 303ms (median out of 5) on my machine. ``` $ time sbtn exit [info] entering *experimental* thin client - BEEP WHIRR [info] terminate the server with `shutdown` sbtn exit 0.05s user 0.05s system 112% cpu 0.085 total ``` On the other hand, sbtn ran in 85ms (median out of 5). After: ``` $ time ~/work/sbt-modules/sbt-launcher-package/target/universal/stage/bin/sbt --client exit [info] entering *experimental* thin client - BEEP WHIRR [info] terminate the server with `shutdown` ~/work/sbt-modules/sbt-launcher-package/target/universal/stage/bin/sbt exit 0.06s user 0.08s system 111% cpu 0.127 total ``` By delaying the java version detection, I got it down to 127ms. --- src/universal/bin/sbt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 1a046a9d6..a2ded2146 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -563,9 +563,6 @@ process_args () { residual_args=() process_my_args "${myargs[@]}" } - - java_version="$(jdk_version)" - vlog "[process_args] java_version = '$java_version'" } loadConfigFile() { @@ -671,7 +668,14 @@ set -- "${residual_args[@]}" argumentCount=$# if [[ "$(isRunNativeClient)" == "true" ]]; then + set -- "${residual_args[@]}" + argumentCount=$# runNativeClient else + java_version="$(jdk_version)" + vlog "[process_args] java_version = '$java_version'" + addDefaultMemory + set -- "${residual_args[@]}" + argumentCount=$# run fi From d4156d3ed77a6aa2aded6e7a35ea0b92606b3354 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sat, 24 Oct 2020 12:40:25 -0700 Subject: [PATCH 460/483] Set sbt script when running sbtn There are scenarios where sbt is not on the path and may be invoked as an absolute path from the shell. When this is the case, sbtn will fail to start a server because of the missing sbt on the path. We can fix this by setting the --sbt-script parameter. --- src/universal/bin/sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index a2ded2146..d0fac18cd 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -621,7 +621,7 @@ runNativeClient() { unset 'original_args[i]' fi done - execRunner "$sbtn_command" "${original_args[@]}" + execRunner "$sbtn_command" "--sbt-script=$0" "${original_args[@]}" } original_args=("$@") From 3aa2f5eb7513d02a890e2dc6139fb3b14da5dc69 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sun, 25 Oct 2020 17:10:40 -0700 Subject: [PATCH 461/483] Pass verbose flag to sbtn when running sbt --client --- src/universal/bin/sbt.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index e868271ba..9a65ed3a1 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -644,6 +644,7 @@ set "_SBTNCMD=!SBT_BIN_DIR!sbtn-x86_64-pc-win32.exe" if defined sbt_args_verbose ( echo # running native client if not "%~1" == "" ( call :echolist %* ) + set "SBT_ARGS=-v !SBT_ARGS!" ) rem Microsoft Visual C++ 2010 SP1 Redistributable Package (x64) is required From ff638e36bca4d1c57f10701eb6c6423bb425beb4 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sun, 25 Oct 2020 17:10:55 -0700 Subject: [PATCH 462/483] Set sbt script parameter for sbt.bat This brings parity with the bash script. --- src/universal/bin/sbt.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 9a65ed3a1..33d0d8b4c 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -646,6 +646,7 @@ if defined sbt_args_verbose ( if not "%~1" == "" ( call :echolist %* ) set "SBT_ARGS=-v !SBT_ARGS!" ) +set "SBT_ARGS=--sbt-script=!SBT_BIN_DIR!sbt.bat %SBT_ARGS%" rem Microsoft Visual C++ 2010 SP1 Redistributable Package (x64) is required rem https://www.microsoft.com/en-us/download/details.aspx?id=13523 From 9ffddfbd25bada20efe9c2177c27f80a6bdc90eb Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sun, 25 Oct 2020 17:11:07 -0700 Subject: [PATCH 463/483] Pass the sanitized args to thin client in sbt.bat Passing the unsanitized arguments was problematic in sbt.bat because it caused sbt --client to run sbtn with --client as a parameter. This caused sbtn to launch sbt with the --client which caused a loop. This manifested as a weird error about not being able to get the console mode. --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 33d0d8b4c..a651eecb2 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -650,7 +650,7 @@ set "SBT_ARGS=--sbt-script=!SBT_BIN_DIR!sbt.bat %SBT_ARGS%" rem Microsoft Visual C++ 2010 SP1 Redistributable Package (x64) is required rem https://www.microsoft.com/en-us/download/details.aspx?id=13523 -"!_SBTNCMD!" %* +"!_SBTNCMD!" %SBT_ARGS% goto :eof From 19dc8d1bfd2b4aa8eaf19ac2b7391191ec3681e6 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sun, 25 Oct 2020 18:59:53 -0700 Subject: [PATCH 464/483] Replace spaces with %20 in path names If there are strings in the path name, the sbt-script argument will be interpreted as multiple arguments. The thin client also needs to be updated to handle %20 in path names. --- src/universal/bin/sbt | 4 +++- src/universal/bin/sbt.bat | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index d0fac18cd..ae707bc7d 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -621,7 +621,9 @@ runNativeClient() { unset 'original_args[i]' fi done - execRunner "$sbtn_command" "--sbt-script=$0" "${original_args[@]}" + sbt_script=$0 + sbt_script=${sbt_script/ /%20} + execRunner "$sbtn_command" "--sbt-script=$sbt_script" "${original_args[@]}" } original_args=("$@") diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index a651eecb2..41ce56f87 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -646,7 +646,9 @@ if defined sbt_args_verbose ( if not "%~1" == "" ( call :echolist %* ) set "SBT_ARGS=-v !SBT_ARGS!" ) -set "SBT_ARGS=--sbt-script=!SBT_BIN_DIR!sbt.bat %SBT_ARGS%" + +set "SBT_SCRIPT=!SBT_BIN_DIR: =%%20!sbt.bat" +set "SBT_ARGS=--sbt-script=!SBT_SCRIPT! %SBT_ARGS%" rem Microsoft Visual C++ 2010 SP1 Redistributable Package (x64) is required rem https://www.microsoft.com/en-us/download/details.aspx?id=13523 From 93af7b9cc9290ba4acf93768cb27243ada12bed3 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 1 Nov 2020 23:27:19 -0500 Subject: [PATCH 465/483] sbtn 1.4.2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 97244848a..0953d9bd0 100755 --- a/build.sbt +++ b/build.sbt @@ -110,7 +110,7 @@ val root = (project in file(".")). // TODO - GPG Trust validation. file }, - sbtnVersion := "1.4.0", + sbtnVersion := "1.4.2", sbtnJarsBaseUrl := "https://github.com/sbt/sbtn-dist/releases/download", sbtnJarsMappings := { val baseUrl = sbtnJarsBaseUrl.value From 8511c4bbbe1ae355c0c71dec0f1df78216bc251d Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 4 Nov 2020 22:28:18 -0500 Subject: [PATCH 466/483] Don't include sbtn into Debian or RPM Ref https://github.com/sbt/sbt/issues/6053 --- build.sbt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 97244848a..7576930f1 100755 --- a/build.sbt +++ b/build.sbt @@ -11,6 +11,12 @@ lazy val sbtOfflineInstall = case "false" | "0" => false case _ => false } +lazy val sbtIncludeSbtn = + sys.props.getOrElse("sbt.build.includesbtn", sys.env.getOrElse("sbt.build.includesbtn", "true")) match { + case "true" | "1" => true + case "false" | "0" => false + case _ => false + } lazy val sbtVersionToRelease = sys.props.getOrElse("sbt.build.version", sys.env.getOrElse("sbt.build.version", { sys.error("-Dsbt.build.version must be set") })) @@ -123,7 +129,7 @@ val root = (project in file(".")). val linuxTar = t / linuxImageTar val windowsZip = t / windowsImageZip import dispatch.classic._ - if(!macosTar.exists && !isWindows) { + if(!macosTar.exists && !isWindows && sbtIncludeSbtn) { IO.touch(macosTar) val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(macosTar)) try Http(url(s"$baseUrl/v$v/$macosImageTar") >>> writer) @@ -133,7 +139,7 @@ val root = (project in file(".")). s"tar zxvf $macosTar --directory $platformDir".! IO.move(platformDir / "sbtn", t / x86MacImageName) } - if(!linuxTar.exists && !isWindows) { + if(!linuxTar.exists && !isWindows && sbtIncludeSbtn) { IO.touch(linuxTar) val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(linuxTar)) try Http(url(s"$baseUrl/v$v/$linuxImageTar") >>> writer) @@ -143,7 +149,7 @@ val root = (project in file(".")). s"""tar zxvf $linuxTar --directory $platformDir""".! IO.move(platformDir / "sbtn", t / x86LinuxImageName) } - if(!windowsZip.exists) { + if(!windowsZip.exists && sbtIncludeSbtn) { IO.touch(windowsZip) val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(windowsZip)) try Http(url(s"$baseUrl/v$v/$windowsImageZip") >>> writer) @@ -152,7 +158,8 @@ val root = (project in file(".")). IO.unzip(windowsZip, platformDir) IO.move(platformDir / "sbtn.exe", t / x86WindowsImageName) } - if (isWindows) Seq(t / x86WindowsImageName -> s"bin/$x86WindowsImageName") + if (!sbtIncludeSbtn) Seq() + else if (isWindows) Seq(t / x86WindowsImageName -> s"bin/$x86WindowsImageName") else Seq(t / x86MacImageName -> s"bin/$x86MacImageName", t / x86LinuxImageName -> s"bin/$x86LinuxImageName", From 1d957bdef23ee50c17cef4e17f1b39b477e74a3e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 9 Nov 2020 01:17:07 -0500 Subject: [PATCH 467/483] Preparatory GitHub Actions --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..d948efbf1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI +on: + pull_request: + push: + +jobs: + test: + strategy: + matrix: + include: + - os: ubuntu-latest + java: 8 + jobtype: 1 + - os: ubuntu-latest + java: 11 + jobtype: 1 + runs-on: ${{ matrix.os }} + env: + JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Setup + uses: olafurpg/setup-scala@v10 + with: + java-version: "adopt@1.${{ matrix.java }}" + - name: Coursier cache + uses: coursier/cache-action@v5 + - name: Cache sbt + uses: actions/cache@v1 + with: + path: ~/.sbt + key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + - name: Build and test + run: echo hello GitHub From 86f9061faede79603a9a8cff16cd5858fe055d88 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 9 Nov 2020 01:51:21 -0500 Subject: [PATCH 468/483] Migrate to GitHub Actions --- .github/workflows/ci.yml | 51 ++++++++++++++++++++--- .travis.yml | 88 ---------------------------------------- 2 files changed, 46 insertions(+), 93 deletions(-) delete mode 100755 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d948efbf1..1248faee1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,12 +11,18 @@ jobs: - os: ubuntu-latest java: 8 jobtype: 1 - - os: ubuntu-latest - java: 11 - jobtype: 1 + - os: macos-latest + java: 8 + jobtype: 2 + - os: windows-latest + java: 8 + jobtype: 3 runs-on: ${{ matrix.os }} env: - JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M + JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 + SBT_VER: 1.4.2 + SBT_ETC_FILE: $HOME/etc/sbt/sbtopts + JDK11: adopt@1.11.0-9 steps: - name: Checkout uses: actions/checkout@v1 @@ -32,4 +38,39 @@ jobs: path: ~/.sbt key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - name: Build and test - run: echo hello GitHub + shell: bash + run: | + case ${{ matrix.jobtype }} in + 1) + echo build using JDK 8 test using JDK 8 and JDK 11 + sbt -Dsbt.build.version=$SBT_VER rpm:packageBin debian:packageBin + sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test + cd citest && ./test.sh + $HOME/bin/jabba install $JDK11 && exec $HOME/bin/jabba which --home $JDK11 + java -Xmx32m -version + ./test.sh + ;; + 2) + echo build using JDK 8, test using JDK 8, on macOS + bin/coursier resolve + sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test + cd citest && ./test.sh + ;; + 3) + echo build using JDK 8, test using JDK 8, on Windows + bin/coursier.bat resolve + sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test + cd citest + ./test.bat + test3/test3.bat + ;; + *) + echo unknown jobtype + exit 1 + esac + rm -rf "$HOME/.ivy2/local" || true + rm -r $(find $HOME/.sbt/boot -name "*-SNAPSHOT") || true + find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true + find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true + find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true + find $HOME/.sbt -name "*.lock" -delete || true diff --git a/.travis.yml b/.travis.yml deleted file mode 100755 index 5d9e56ad5..000000000 --- a/.travis.yml +++ /dev/null @@ -1,88 +0,0 @@ -sudo: false -dist: xenial -group: stable - -language: scala -scala: 2.10.7 - -env: - global: - - SBT_VER=1.3.13 - - TRAVIS_JDK=adopt@1.8.0-222 - - JABBA_HOME=$HOME/.jabba - - TRAVIS_JDK11=openjdk@1.11.0 - ## ignore Travis CI's default /etc/sbt/sbtopts - - SBT_ETC_FILE=$HOME/etc/sbt/sbtopts - -matrix: - include: - - os: windows - language: bash - before_install: - - "PowerShell -ExecutionPolicy Bypass -Command '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-Expression (Invoke-WebRequest https://raw.githubusercontent.com/shyiko/jabba/0.11.2/install.ps1 -UseBasicParsing).Content'" - install: - - $JABBA_HOME/bin/jabba.exe install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" - - java -Xmx32m -version - - curl --fail https://github.com/sbt/sbt/releases/download/v$SBT_VER/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip - - unzip /tmp/sbt.zip -d $HOME/sbt - - export PATH="$HOME/sbt/sbt/bin:$PATH" - - bin/coursier.bat resolve - script: - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - - cd citest - - "./test.bat" - - "test3/test3.bat" - - ## build using JDK 8, test using JDK 8, on macOS - - os: osx - osx_image: xcode9.2 - language: java - before_install: - - curl -sL https://raw.githubusercontent.com/shyiko/jabba/0.11.2/install.sh | bash && . ~/.jabba/jabba.sh - install: - - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK/Contents/Home" && export PATH="$JAVA_HOME/bin:$PATH" - - java -Xmx32m -version - - unset SBT_OPTS - - curl --fail https://github.com/sbt/sbt/releases/download/v$SBT_VER/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip - - unzip /tmp/sbt.zip -d $HOME/sbt - - export PATH="$HOME/sbt/sbt/bin:$PATH" - - bin/coursier resolve - script: - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - - cd citest && ./test.sh - - - name: "build using JDK 8 test using JDK 8 and JDK 11" - script: - - sbt -Dsbt.build.version=$SBT_VER rpm:packageBin debian:packageBin - - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - - cd citest && ./test.sh - - $JABBA_HOME/bin/jabba install $TRAVIS_JDK11 && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK11" && export PATH="$JAVA_HOME/bin:$PATH" - - java -Xmx32m -version - - ./test.sh - addons: - apt: - packages: - - fakeroot - - rpm - -before_install: - - curl -sL https://raw.githubusercontent.com/shyiko/jabba/0.10.1/install.sh | bash && . ~/.jabba/jabba.sh - -install: - - $JABBA_HOME/bin/jabba install $TRAVIS_JDK && export JAVA_HOME="$JABBA_HOME/jdk/$TRAVIS_JDK" && export PATH="$JAVA_HOME/bin:$PATH" - - java -Xmx32m -version - - unset SBT_OPTS - - curl --fail https://github.com/sbt/sbt/releases/download/v$SBT_VER/sbt-$SBT_VER.zip -L --output /tmp/sbt.zip - - unzip /tmp/sbt.zip -d $HOME/sbt - - export PATH="$HOME/sbt/sbt/bin:$PATH" - - bin/coursier resolve - -cache: - directories: - - $HOME/.ivy2/cache - - $HOME/.sbt/boot - - $HOME/.jabba/jdk - -before_cache: - - find $HOME/.ivy2 -name "ivydata-*.properties" -delete - - find $HOME/.sbt -name "*.lock" -delete From 0939c1c78e85115b65edd6161c5313a9dd873a76 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 9 Nov 2020 11:46:36 -0500 Subject: [PATCH 469/483] Comment out sbt --client test --- integration-test/src/test/scala/RunnerTest.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 81386e990..721fff23e 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -70,6 +70,7 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } + /* test("sbt --client") { val out = sbtProcess("--client", "--no-colors", "compile").!!.linesIterator.toList if (isWindows) { @@ -85,4 +86,5 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { } () } + */ } From e8eda762781bd122272c463501be8095644b4e52 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 9 Nov 2020 11:58:06 -0500 Subject: [PATCH 470/483] Downgrade integration test to use sbt 1.3.13 --- .github/workflows/ci.yml | 1 + citest/project/build.properties | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1248faee1..fbddddc8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,7 @@ on: jobs: test: strategy: + fail-fast: false matrix: include: - os: ubuntu-latest diff --git a/citest/project/build.properties b/citest/project/build.properties index ea3a73ab1..0837f7a13 100644 --- a/citest/project/build.properties +++ b/citest/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.0-RC2 +sbt.version=1.3.13 From 39a2492ae75c314f4a1820bb05e3f6b579cefd0f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 9 Nov 2020 12:15:45 -0500 Subject: [PATCH 471/483] Python 3.7 --- .github/workflows/ci.yml | 4 ++++ integration-test/bin/java | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fbddddc8c..f00f86426 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,10 @@ jobs: uses: olafurpg/setup-scala@v10 with: java-version: "adopt@1.${{ matrix.java }}" + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 - name: Coursier cache uses: coursier/cache-action@v5 - name: Cache sbt diff --git a/integration-test/bin/java b/integration-test/bin/java index 56920a236..dc584d35b 100755 --- a/integration-test/bin/java +++ b/integration-test/bin/java @@ -1,9 +1,9 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys if '--version' in sys.argv or '-version' in sys.argv: - print 'openjdk version "1.8.0_212"' + print('openjdk version "1.8.0_212"') else: for arg in sys.argv[1:]: print(repr(arg)[1:-1]) From 06c1f6ce97ff5398cac7139893ca851b4d77cdcb Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Mon, 26 Oct 2020 14:54:50 -0700 Subject: [PATCH 472/483] Remove extra addDefaultMemory I think this was inadvertently left out of 75257e759b455552c3007df1ec13c351ff1db2f5. Prior to removing this, `sbt --client exit` took about 200ms on my computer compared to about 50ms for sbtn. The sbt --client result dropped to about 80ms after this change. --- src/universal/bin/sbt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index ae707bc7d..ca1ddf562 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -665,10 +665,6 @@ args1=( "${cli_options[@]}" "${cli_commands[@]}" "${sbt_additional_commands[@]}" process_args "${args1[@]}" vlog "[sbt_options] $(declare -p sbt_options)" -addDefaultMemory -set -- "${residual_args[@]}" -argumentCount=$# - if [[ "$(isRunNativeClient)" == "true" ]]; then set -- "${residual_args[@]}" argumentCount=$# From abc929687e3ce43ec6d2998a51cdbb485e777d6c Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Thu, 19 Nov 2020 10:19:14 -0800 Subject: [PATCH 473/483] Remove leading -J from .sbtopts lines The windows batch script for sbt does not strip -J from lines in the .sbtopts file, which can cause sbt to fail to run since they end up getting passed in as unknown vm arguments. --- src/universal/bin/sbt.bat | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 41ce56f87..7640ea3d0 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -52,10 +52,13 @@ rem users can set SBT_OPTS via .sbtopts if exist .sbtopts for /F %%A in (.sbtopts) do ( set _sbtopts_line=%%A if not "!_sbtopts_line:~0,1!" == "#" ( + if "!_sbtopts_line:~0,2!" == "-J" ( + set _sbtopts_line=!_sbtopts_line:~2,1000! + ) if defined _SBT_OPTS ( - set _SBT_OPTS=!_SBT_OPTS! %%A + set _SBT_OPTS=!_SBT_OPTS! !_sbtopts_line! ) else ( - set _SBT_OPTS=%%A + set _SBT_OPTS=!_sbtopts_line! ) ) ) From 44ba8e7dee6547d95f609055e44b3b7fd16fa8e9 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 22 Nov 2020 20:19:16 -0500 Subject: [PATCH 474/483] sbtn 1.4.4 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 157e1a9d0..d241e33e2 100755 --- a/build.sbt +++ b/build.sbt @@ -116,7 +116,7 @@ val root = (project in file(".")). // TODO - GPG Trust validation. file }, - sbtnVersion := "1.4.2", + sbtnVersion := "1.4.4", sbtnJarsBaseUrl := "https://github.com/sbt/sbtn-dist/releases/download", sbtnJarsMappings := { val baseUrl = sbtnJarsBaseUrl.value From 04eac0421b962d55eec553ee8f3628d0a885f200 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 14 Dec 2020 01:32:32 -0500 Subject: [PATCH 475/483] sbtn 1.4.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index d241e33e2..6fe059e2c 100755 --- a/build.sbt +++ b/build.sbt @@ -116,7 +116,7 @@ val root = (project in file(".")). // TODO - GPG Trust validation. file }, - sbtnVersion := "1.4.4", + sbtnVersion := "1.4.5", sbtnJarsBaseUrl := "https://github.com/sbt/sbtn-dist/releases/download", sbtnJarsMappings := { val baseUrl = sbtnJarsBaseUrl.value From bf34bad1a6bf684522d3010f52e3520b744a8d39 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Tue, 29 Dec 2020 11:56:22 -0800 Subject: [PATCH 476/483] Fix #5181 - add -Xss to java_options ignore --- src/universal/bin/sbt | 7 +++++-- src/universal/bin/sbt.bat | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index ca1ddf562..c5bb32333 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -154,14 +154,14 @@ addMemory () { local xs=("${java_args[@]}") java_args=() for i in "${xs[@]}"; do - if ! [[ "${i}" == *-Xmx* ]] && ! [[ "${i}" == *-Xms* ]] && ! [[ "${i}" == *-XX:MaxPermSize* ]] && ! [[ "${i}" == *-XX:MaxMetaspaceSize* ]] && ! [[ "${i}" == *-XX:ReservedCodeCacheSize* ]]; then + if ! [[ "${i}" == *-Xmx* ]] && ! [[ "${i}" == *-Xms* ]] && ! [[ "${i}" == *-Xss* ]] && ! [[ "${i}" == *-XX:MaxPermSize* ]] && ! [[ "${i}" == *-XX:MaxMetaspaceSize* ]] && ! [[ "${i}" == *-XX:ReservedCodeCacheSize* ]]; then java_args+=("${i}") fi done local ys=("${sbt_options[@]}") sbt_options=() for i in "${ys[@]}"; do - if ! [[ "${i}" == *-Xmx* ]] && ! [[ "${i}" == *-Xms* ]] && ! [[ "${i}" == *-XX:MaxPermSize* ]] && ! [[ "${i}" == *-XX:MaxMetaspaceSize* ]] && ! [[ "${i}" == *-XX:ReservedCodeCacheSize* ]]; then + if ! [[ "${i}" == *-Xmx* ]] && ! [[ "${i}" == *-Xms* ]] && ! [[ "${i}" == *-Xss* ]] && ! [[ "${i}" == *-XX:MaxPermSize* ]] && ! [[ "${i}" == *-XX:MaxMetaspaceSize* ]] && ! [[ "${i}" == *-XX:ReservedCodeCacheSize* ]]; then sbt_options+=("${i}") fi done @@ -187,6 +187,7 @@ addDefaultMemory() { # The reason is the Xms/Xmx, if they don't line up, cause errors. if [[ "${java_args[@]}" == *-Xmx* ]] || \ [[ "${java_args[@]}" == *-Xms* ]] || \ + [[ "${java_args[@]}" == *-Xss* ]] || \ [[ "${java_args[@]}" == *-XX:+UseCGroupMemoryLimitForHeap* ]] || \ [[ "${java_args[@]}" == *-XX:MaxRAM* ]] || \ [[ "${java_args[@]}" == *-XX:InitialRAMPercentage* ]] || \ @@ -195,6 +196,7 @@ addDefaultMemory() { : elif [[ "${JAVA_TOOL_OPTIONS}" == *-Xmx* ]] || \ [[ "${JAVA_TOOL_OPTIONS}" == *-Xms* ]] || \ + [[ "${JAVA_TOOL_OPTIONS}" == *-Xss* ]] || \ [[ "${JAVA_TOOL_OPTIONS}" == *-XX:+UseCGroupMemoryLimitForHeap* ]] || \ [[ "${JAVA_TOOL_OPTIONS}" == *-XX:MaxRAM* ]] || \ [[ "${JAVA_TOOL_OPTIONS}" == *-XX:InitialRAMPercentage* ]] || \ @@ -203,6 +205,7 @@ addDefaultMemory() { : elif [[ "${sbt_options[@]}" == *-Xmx* ]] || \ [[ "${sbt_options[@]}" == *-Xms* ]] || \ + [[ "${sbt_options[@]}" == *-Xss* ]] || \ [[ "${sbt_options[@]}" == *-XX:+UseCGroupMemoryLimitForHeap* ]] || \ [[ "${sbt_options[@]}" == *-XX:MaxRAM* ]] || \ [[ "${sbt_options[@]}" == *-XX:InitialRAMPercentage* ]] || \ diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 7640ea3d0..ccab7ad19 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -726,7 +726,7 @@ exit /B 0 if "!_old_java_opts!" == "" goto :done_java_opt for /F "tokens=1,*" %%g in ("!_old_java_opts!") do ( set "p=%%g" - if not "!p:~0,4!" == "-Xmx" if not "!p:~0,4!" == "-Xms" if not "!p:~0,15!" == "-XX:MaxPermSize" if not "!p:~0,20!" == "-XX:MaxMetaspaceSize" if not "!p:~0,25!" == "-XX:ReservedCodeCacheSize" ( + if not "!p:~0,4!" == "-Xmx" if not "!p:~0,4!" == "-Xms" if not "!p:~0,4!" == "-Xss" if not "!p:~0,15!" == "-XX:MaxPermSize" if not "!p:~0,20!" == "-XX:MaxMetaspaceSize" if not "!p:~0,25!" == "-XX:ReservedCodeCacheSize" ( set _new_java_opts=!_new_java_opts! %%g ) set "_old_java_opts=%%h" @@ -741,7 +741,7 @@ exit /B 0 if "!_old_sbt_opts!" == "" goto :done_sbt_opt for /F "tokens=1,*" %%g in ("!_old_sbt_opts!") do ( set "p=%%g" - if not "!p:~0,4!" == "-Xmx" if not "!p:~0,4!" == "-Xms" if not "!p:~0,15!" == "-XX:MaxPermSize" if not "!p:~0,20!" == "-XX:MaxMetaspaceSize" if not "!p:~0,25!" == "-XX:ReservedCodeCacheSize" ( + if not "!p:~0,4!" == "-Xmx" if not "!p:~0,4!" == "-Xms" if not "!p:~0,4!" == "-Xss" if not "!p:~0,15!" == "-XX:MaxPermSize" if not "!p:~0,20!" == "-XX:MaxMetaspaceSize" if not "!p:~0,25!" == "-XX:ReservedCodeCacheSize" ( set _new_sbt_opts=!_new_sbt_opts! %%g ) set "_old_sbt_opts=%%h" @@ -779,18 +779,21 @@ exit /B 0 set "p=%%g" if "!p:~0,4!" == "-Xmx" set _has_memory_args=1 if "!p:~0,4!" == "-Xms" set _has_memory_args=1 + if "!p:~0,4!" == "-Xss" set _has_memory_args=1 ) if defined JAVA_TOOL_OPTIONS for /F %%g in ("%JAVA_TOOL_OPTIONS%") do ( set "p=%%g" if "!p:~0,4!" == "-Xmx" set _has_memory_args=1 if "!p:~0,4!" == "-Xms" set _has_memory_args=1 + if "!p:~0,4!" == "-Xss" set _has_memory_args=1 ) if defined _SBT_OPTS for /F %%g in ("!_SBT_OPTS!") do ( set "p=%%g" if "!p:~0,4!" == "-Xmx" set _has_memory_args=1 if "!p:~0,4!" == "-Xms" set _has_memory_args=1 + if "!p:~0,4!" == "-Xss" set _has_memory_args=1 ) if not defined _has_memory_args ( From cab425afe78e34deaf04ef346cbd8de65fae8851 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Tue, 29 Dec 2020 14:10:34 -0800 Subject: [PATCH 477/483] Refactor ScriptTest a bit and add tests for -Xss script launcher params --- .../src/test/scala/ScriptTest.scala | 133 +++++++++--------- 1 file changed, 65 insertions(+), 68 deletions(-) diff --git a/integration-test/src/test/scala/ScriptTest.scala b/integration-test/src/test/scala/ScriptTest.scala index 2bbbb86b4..1db0c50dc 100644 --- a/integration-test/src/test/scala/ScriptTest.scala +++ b/integration-test/src/test/scala/ScriptTest.scala @@ -11,6 +11,18 @@ object SbtScriptTest extends SimpleTestSuite with PowerAssertions { private val javaBinDir = new File("integration-test", "bin").getAbsolutePath + private def makeTest( + name: String, + javaOpts: String = "", + sbtOpts: String = "", + )(args: String*)(f: List[String] => Any) = { + test(name) { + val out = sbtProcessWithOpts(args: _*)(javaOpts = javaOpts, sbtOpts = sbtOpts).!!.linesIterator.toList + f(out) + () + } + } + def sbtProcess(args: String*) = sbtProcessWithOpts(args: _*)("", "") def sbtProcessWithOpts(args: String*)(javaOpts: String, sbtOpts: String) = { val path = sys.env("PATH") @@ -24,121 +36,112 @@ object SbtScriptTest extends SimpleTestSuite with PowerAssertions { ) } - test("sbt -no-colors") { - val out = sbtProcess("compile", "-no-colors").!!.linesIterator.toList + makeTest("sbt -no-colors")("compile", "-no-colors", "-v") { out: List[String] => assert(out.contains[String]("-Dsbt.log.noformat=true")) - () } - test("sbt --no-colors") { - val out = sbtProcess("compile", "--no-colors").!!.linesIterator.toList + makeTest("sbt --no-colors")("compile", "--no-colors", "-v") { out: List[String] => assert(out.contains[String]("-Dsbt.log.noformat=true")) - () } - test("sbt --color=false") { - val out = sbtProcess("compile", "--color=false", "-v").!!.linesIterator.toList + makeTest("sbt --color=false")("compile", "--color=false", "-v") { out: List[String] => assert(out.contains[String]("-Dsbt.color=false")) - () } - test("sbt --debug-inc") { - val out = sbtProcess("compile", "--debug-inc", "-v").!!.linesIterator.toList + makeTest("sbt --no-colors in SBT_OPTS", sbtOpts = "--no-colors")("compile", "-v") { out: List[String] => + if (isWindows) cancel("Test not supported on windows") + assert(out.contains[String]("-Dsbt.log.noformat=true")) + } + + makeTest("sbt --debug-inc")("compile", "--debug-inc", "-v") { out: List[String] => assert(out.contains[String]("-Dxsbt.inc.debug=true")) - () } - test("sbt --supershell=never") { - val out = sbtProcess("compile", "--supershell=never", "-v").!!.linesIterator.toList + makeTest("sbt --supershell=never")("compile", "--supershell=never", "-v") { out: List[String] => assert(out.contains[String]("-Dsbt.supershell=never")) - () } - test("sbt --timings") { - val out = sbtProcess("compile", "--timings", "-v").!!.linesIterator.toList + makeTest("sbt --timings")("compile", "--timings", "-v") { out: List[String] => assert(out.contains[String]("-Dsbt.task.timings=true")) - () } - test("sbt -D arguments") { - val out = sbtProcess("-Dsbt.supershell=false", "compile", "-v").!!.linesIterator.toList + makeTest("sbt -D arguments")("-Dsbt.supershell=false", "compile", "-v") { out: List[String] => assert(out.contains[String]("-Dsbt.supershell=false")) - () } - test("sbt --sbt-version") { - val out = sbtProcess("--sbt-version", "1.3.13", "compile", "-v").!!.linesIterator.toList + makeTest("sbt --sbt-version")("--sbt-version", "1.3.13", "-v") { out: List[String] => assert(out.contains[String]("-Dsbt.version=1.3.13")) - () } - test("sbt -mem 503") { - val out = sbtProcess("compile", "-mem", "503", "-v").!!.linesIterator.toList + makeTest("sbt -mem 503")("-mem", "503", "-v") { out: List[String] => assert(out.contains[String]("-Xmx503m")) - () } - test("sbt with -mem 503, -Xmx in JAVA_OPTS") { - val out = sbtProcessWithOpts("compile", "-mem", "503", "-v")("-Xmx1024m", "").!!.linesIterator.toList + makeTest("sbt with -mem 503, -Xmx in JAVA_OPTS", javaOpts = "-Xmx1024m")("-mem", "503", "-v") { out: List[String] => assert(out.contains[String]("-Xmx503m")) assert(!out.contains[String]("-Xmx1024m")) - () } - test("sbt with -mem 503, -Xmx in SBT_OPTS") { - val out = sbtProcessWithOpts("compile", "-mem", "503", "-v")("", "-Xmx1024m").!!.linesIterator.toList + makeTest("sbt with -mem 503, -Xmx in SBT_OPTS", sbtOpts = "-Xmx1024m")("-mem", "503", "-v") { out: List[String] => assert(out.contains[String]("-Xmx503m")) assert(!out.contains[String]("-Xmx1024m")) - () } - test("sbt with -Xms2048M -Xmx2048M -Xss6M in SBT_OPTS") { - val out = sbtProcessWithOpts("compile", "-v")("", "-Xms2048M -Xmx2048M -Xss6M").!!.linesIterator.toList + makeTest("sbt with -mem 503, -Xss in JAVA_OPTS", javaOpts = "-Xss6m")("-mem", "503", "-v") { out: List[String] => + assert(out.contains[String]("-Xmx503m")) + assert(!out.contains[String]("-Xss6m")) + } + + makeTest("sbt with -mem 503, -Xss in SBT_OPTS", sbtOpts = "-Xss6m")("-mem", "503", "-v") { out: List[String] => + assert(out.contains[String]("-Xmx503m")) + assert(!out.contains[String]("-Xss6m")) + } + + makeTest("sbt with -Xms2048M -Xmx2048M -Xss6M in JAVA_OPTS", javaOpts = "-Xms2048M -Xmx2048M -Xss6M")("-v") { out: List[String] => + assert(out.contains[String]("-Xms2048M")) + assert(out.contains[String]("-Xmx2048M")) assert(out.contains[String]("-Xss6M")) - () } - test("sbt with -Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080 in SBT_OPTS") { - val out = sbtProcessWithOpts("compile", "-v")("", "-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080").!!.linesIterator.toList + makeTest("sbt with -Xms2048M -Xmx2048M -Xss6M in SBT_OPTS", sbtOpts = "-Xms2048M -Xmx2048M -Xss6M")( "-v") { out: List[String] => + assert(out.contains[String]("-Xms2048M")) + assert(out.contains[String]("-Xmx2048M")) + assert(out.contains[String]("-Xss6M")) + } + + + makeTest( + name = "sbt with -Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080 in SBT_OPTS", + sbtOpts = "-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080", + )("-v") { out: List[String] => assert(out.contains[String]("-Dhttp.proxyHost=proxy")) assert(out.contains[String]("-Dhttp.proxyPort=8080")) - () } - test("sbt with -XX:ParallelGCThreads=16 -XX:PermSize=128M in SBT_OPTS") { - val out = sbtProcessWithOpts("compile", "-v")("", "-XX:ParallelGCThreads=16 -XX:PermSize=128M").!!.linesIterator.toList + makeTest( + name = "sbt with -XX:ParallelGCThreads=16 -XX:PermSize=128M in SBT_OPTS", + sbtOpts = "-XX:ParallelGCThreads=16 -XX:PermSize=128M", + )("-v") { out: List[String] => assert(out.contains[String]("-XX:ParallelGCThreads=16")) assert(out.contains[String]("-XX:PermSize=128M")) - () } - test("sbt with -XX:+UseG1GC -XX:+PrintGC in SBT_OPTS") { - val out = sbtProcessWithOpts("compile", "-v")("", "-XX:+UseG1GC -XX:+PrintGC").!!.linesIterator.toList + makeTest("sbt with -XX:+UseG1GC -XX:+PrintGC in JAVA_OPTS", javaOpts = "-XX:+UseG1GC -XX:+PrintGC")("-v") { out: List[String] => assert(out.contains[String]("-XX:+UseG1GC")) assert(out.contains[String]("-XX:+PrintGC")) assert(!out.contains[String]("-XX:+UseG1GC=-XX:+PrintGC")) - () } - test("sbt with -XX:-UseG1GC -XX:-PrintGC in SBT_OPTS") { - val out = sbtProcessWithOpts("compile", "-v")("", "-XX:-UseG1GC -XX:-PrintGC").!!.linesIterator.toList - assert(out.contains[String]("-XX:-UseG1GC")) - assert(out.contains[String]("-XX:-PrintGC")) - assert(!out.contains[String]("-XX:-UseG1GC=-XX:-PrintGC")) - () - } - - test("sbt with --no-colors in SBT_OPTS") { - if (isWindows) cancel("Test not supported on windows") - val out = sbtProcessWithOpts("compile", "-v")("", "--no-colors").!!.linesIterator.toList - assert(out.contains[String]("-Dsbt.log.noformat=true")) - () + makeTest("sbt with -XX:-UseG1GC -XX:-PrintGC in SBT_OPTS", sbtOpts = "-XX:+UseG1GC -XX:+PrintGC")( "-v") { out: List[String] => + assert(out.contains[String]("-XX:+UseG1GC")) + assert(out.contains[String]("-XX:+PrintGC")) + assert(!out.contains[String]("-XX:+UseG1GC=-XX:+PrintGC")) } test("sbt with -debug in SBT_OPTS appears in sbt commands") { if (isWindows) cancel("Test not supported on windows") - val out: List[String] = sbtProcessWithOpts("compile", "-v")("", "-debug").!!.linesIterator.toList + val out: List[String] = sbtProcessWithOpts("compile", "-v")(javaOpts = "", sbtOpts = "-debug").!!.linesIterator.toList // Debug argument must appear in the 'commands' section (after the sbt-launch.jar argument) to work val sbtLaunchMatcher = """^.+sbt-launch.jar["]{0,1}$""".r val locationOfSbtLaunchJarArg = out.zipWithIndex.collectFirst { @@ -152,24 +155,18 @@ object SbtScriptTest extends SimpleTestSuite with PowerAssertions { () } - test("sbt --jvm-debug ") { - val out = sbtProcess("--jvm-debug", "12345", "compile", "-v").!!.linesIterator.toList + makeTest("sbt --jvm-debug ")("--jvm-debug", "12345", "-v") { out: List[String] => assert(out.contains[String]("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=12345")) - () } - test("sbt --no-share adds three system properties") { - val out = sbtProcess("--no-share").!!.linesIterator.toList + makeTest("sbt --no-share adds three system properties")("--no-share") { out: List[String] => assert(out.contains[String]("-Dsbt.global.base=project/.sbtboot")) assert(out.contains[String]("-Dsbt.boot.directory=project/.boot")) assert(out.contains[String]("-Dsbt.ivy.home=project/.ivy")) - () } - test("accept `--ivy` in `SBT_OPTS`") { + makeTest("accept `--ivy` in `SBT_OPTS`", sbtOpts = "--ivy /ivy/dir")("-v") { out: List[String] => if (isWindows) cancel("Test not supported on windows") - val out = sbtProcessWithOpts("")("", sbtOpts = "--ivy /ivy/dir").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.ivy.home=/ivy/dir")) - () } } From 4c9b3158312b6e2050fd48f2e452328f2f9d3499 Mon Sep 17 00:00:00 2001 From: Luc Henninger Date: Sun, 17 Jan 2021 19:18:09 +0100 Subject: [PATCH 478/483] Update sbt for cygwin environment support See issue #6260 --- src/universal/bin/sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index c5bb32333..64c8527be 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -106,7 +106,7 @@ acquire_sbt_jar () { } rt_export_file () { - echo "${sbt_bin_dir}/java9-rt-export.jar" + echo "$(cygwinpath "${sbt_bin_dir}/java9-rt-export.jar")" } # execRunner should be called only once to give up control to java @@ -340,7 +340,7 @@ copyRt() { rtexport=$(rt_export_file) # The grep for java9-rt-ext- matches the filename prefix printed in Export.java java9_ext=$("$java_cmd" "${sbt_options[@]}" "${java_args[@]}" \ - -jar "$rtexport" --rt-ext-dir | grep java9-rt-ext-) + -jar "$rtexport" --rt-ext-dir | grep java9-rt-ext- | tr -d '\r') java9_rt=$(echo "$java9_ext/rt.jar") vlog "[copyRt] java9_rt = '$java9_rt'" if [[ ! -f "$java9_rt" ]]; then From 635f05f2f38a166178fa18aeeb6a4e285bd595e4 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 31 Jan 2021 00:43:23 -0500 Subject: [PATCH 479/483] sbtn 1.4.7 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6fe059e2c..f81c060a6 100755 --- a/build.sbt +++ b/build.sbt @@ -116,7 +116,7 @@ val root = (project in file(".")). // TODO - GPG Trust validation. file }, - sbtnVersion := "1.4.5", + sbtnVersion := "1.4.7", sbtnJarsBaseUrl := "https://github.com/sbt/sbtn-dist/releases/download", sbtnJarsMappings := { val baseUrl = sbtnJarsBaseUrl.value From 0e15d5629190b79814cdea8ce4c73c86e74addc1 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 7 Mar 2021 19:10:07 -0500 Subject: [PATCH 480/483] Update launcher URL --- build.sbt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index f81c060a6..0cddf8238 100755 --- a/build.sbt +++ b/build.sbt @@ -353,8 +353,7 @@ def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching( case Array(0, 11, x, _*) if x >= 3 => "https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case Array(0, y, _*) if y >= 12 => "https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case Array(1, _, _*) if v contains ("-20") => "https://repo.scala-sbt.org/scalasbt/maven-snapshots/org/scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" - case Array(1, _, _*) => "https://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" - case _ => "https://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar" + case _ => "https://repo1.maven.org/maven2/org/scala-sbt/sbt-launch/"+v+"/sbt-launch"+v+".jar" } def makePublishToForConfig(config: Configuration) = { From 729197418c8e4cd666821b85a8092df6fe1b885b Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 7 Mar 2021 19:24:05 -0500 Subject: [PATCH 481/483] Update launcher URL, take 2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 0cddf8238..23474eb73 100755 --- a/build.sbt +++ b/build.sbt @@ -353,7 +353,7 @@ def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching( case Array(0, 11, x, _*) if x >= 3 => "https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case Array(0, y, _*) if y >= 12 => "https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" case Array(1, _, _*) if v contains ("-20") => "https://repo.scala-sbt.org/scalasbt/maven-snapshots/org/scala-sbt/sbt-launch/"+v+"/sbt-launch.jar" - case _ => "https://repo1.maven.org/maven2/org/scala-sbt/sbt-launch/"+v+"/sbt-launch"+v+".jar" + case _ => "https://repo1.maven.org/maven2/org/scala-sbt/sbt-launch/"+v+"/sbt-launch-"+v+".jar" } def makePublishToForConfig(config: Configuration) = { From 73f473efce7d485ebb434e83477012722504549e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 22 Mar 2021 04:19:27 -0400 Subject: [PATCH 482/483] Remove export-rt The feature of export-rt is now folded into sbt-launcher --- build.sbt | 18 ++---------------- src/universal/bin/sbt | 10 +++------- src/universal/bin/sbt.bat | 22 ++++++++++------------ 3 files changed, 15 insertions(+), 35 deletions(-) diff --git a/build.sbt b/build.sbt index 23474eb73..c2459f8a3 100755 --- a/build.sbt +++ b/build.sbt @@ -33,8 +33,6 @@ lazy val scala212Jline = "jline" % "jline" % "2.14.6" // use the scala-xml version used by the compiler not the latest: https://github.com/scala/scala/blob/v2.12.10/versions.properties#L22 lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6" lazy val sbtActual = "org.scala-sbt" % "sbt" % sbtVersionToRelease -val java9rtexportVersion = "0.1.0" -lazy val java9rtexport = "org.scala-sbt.rt" % "java9-rt-export" % java9rtexportVersion % Runtime lazy val sbt013ExtraDeps = { if (sbtVersionToRelease startsWith "0.13.") Seq(scala210Jline) @@ -65,7 +63,6 @@ val windowsBuildId = settingKey[Int]("build id for Windows installer") val debianBuildId = settingKey[Int]("build id for Debian") val exportRepoUsingCoursier = taskKey[File]("export Maven style repository") -val rtExportUsingCoursier = taskKey[File]("Grab RT export utility") val exportRepoCsrDirectory = settingKey[File]("") val x86MacPlatform = "x86_64-apple-darwin" @@ -252,15 +249,6 @@ val root = (project in file(".")). packageName in Universal := packageName.value, // needs to be set explicitly due to a bug in native-packager version in Universal := sbtVersionToRelease, - rtExportUsingCoursier := { - val csr = - if (isWindows) (baseDirectory in LocalRootProject).value / "bin" / "coursier.bat" - else (baseDirectory in LocalRootProject).value / "bin" / "coursier" - val cache = target.value / "coursier" - s"$csr fetch --cache $cache ${colonName(java9rtexport)}".! - (cache ** "*.jar").get.head - }, - mappings in Universal := { val t = (target in Universal).value val prev = (mappings in Universal).value @@ -292,10 +280,8 @@ val root = (project in file(".")). mappings in Universal ++= { val launchJar = sbtLaunchJar.value - val rtExportJar = rtExportUsingCoursier.value Seq( - launchJar -> "bin/sbt-launch.jar", - rtExportJar -> "bin/java9-rt-export.jar" + launchJar -> "bin/sbt-launch.jar" ) ++ sbtnJarsMappings.value }, mappings in Universal ++= (Def.taskDyn { @@ -432,7 +418,7 @@ lazy val dist = (project in file("dist")) if (sbtVersionToRelease startsWith "0.13.") scala210 else scala212 }, - libraryDependencies ++= Seq(sbtActual, java9rtexport, jansi, scala212Compiler, scala212Jline, scala212Xml) ++ sbt013ExtraDeps, + libraryDependencies ++= Seq(sbtActual, jansi, scala212Compiler, scala212Jline, scala212Xml) ++ sbt013ExtraDeps, exportRepo := { val old = exportRepo.value sbtVersionToRelease match { diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 64c8527be..ac198cc8b 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -105,10 +105,6 @@ acquire_sbt_jar () { fi } -rt_export_file () { - echo "$(cygwinpath "${sbt_bin_dir}/java9-rt-export.jar")" -} - # execRunner should be called only once to give up control to java execRunner () { # print the arguments one to a line, quoting any containing spaces @@ -337,10 +333,9 @@ checkJava() { copyRt() { local at_least_9="$(expr $java_version ">=" 9)" if [[ "$at_least_9" == "1" ]]; then - rtexport=$(rt_export_file) # The grep for java9-rt-ext- matches the filename prefix printed in Export.java java9_ext=$("$java_cmd" "${sbt_options[@]}" "${java_args[@]}" \ - -jar "$rtexport" --rt-ext-dir | grep java9-rt-ext- | tr -d '\r') + -jar "$sbt_jar" --rt-ext-dir | grep java9-rt-ext- | tr -d '\r') java9_rt=$(echo "$java9_ext/rt.jar") vlog "[copyRt] java9_rt = '$java9_rt'" if [[ ! -f "$java9_rt" ]]; then @@ -349,7 +344,8 @@ copyRt() { "$java_cmd" \ "${sbt_options[@]}" \ "${java_args[@]}" \ - -jar "$rtexport" \ + -jar "$sbt_jar" \ + --export-rt \ "${java9_rt}" fi addJava "-Dscala.ext.dirs=${java9_ext}" diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index ccab7ad19..cda987c9e 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -530,6 +530,14 @@ if !run_native_client! equ 1 ( call :checkjava +if defined sbt_args_sbt_jar ( + set "sbt_jar=!sbt_args_sbt_jar!" +) else ( + set "sbt_jar=!SBT_HOME!\bin\sbt-launch.jar" +) + +set sbt_jar=!sbt_jar:"=! + call :copyrt if defined JVM_DEBUG_PORT ( @@ -601,14 +609,6 @@ if defined sbt_args_traces ( set _SBT_OPTS=-Dsbt.traces=true !_SBT_OPTS! ) -if defined sbt_args_sbt_jar ( - set "sbt_jar=!sbt_args_sbt_jar!" -) else ( - set "sbt_jar=!SBT_HOME!\bin\sbt-launch.jar" -) - -set sbt_jar=!sbt_jar:"=! - rem TODO: _SBT_OPTS needs to be processed as args and diffed against SBT_ARGS if !sbt_args_print_sbt_version! equ 1 ( @@ -872,15 +872,13 @@ exit /B 1 :copyrt if /I !JAVA_VERSION! GEQ 9 ( - set "rtexport=!SBT_BIN_DIR!java9-rt-export.jar" - - "!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -jar "!rtexport!" --rt-ext-dir > "%TEMP%.\rtext.txt" + "!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -jar "!sbt_jar!" --rt-ext-dir > "%TEMP%.\rtext.txt" set /p java9_ext= < "%TEMP%.\rtext.txt" set "java9_rt=!java9_ext!\rt.jar" if not exist "!java9_rt!" ( mkdir "!java9_ext!" - "!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -jar "!rtexport!" "!java9_rt!" + "!_JAVACMD!" !_JAVA_OPTS! !_SBT_OPTS! -jar "!sbt_jar!" --export-rt "!java9_rt!" ) set _JAVA_OPTS=!_JAVA_OPTS! -Dscala.ext.dirs="!java9_ext!" ) From eb1c5461deaccd9fd57a43060daed6751dc8f2fb Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 19 Apr 2021 10:45:29 -0400 Subject: [PATCH 483/483] move to launcher-package/ --- .gitattributes | 1 - .github/ISSUE_TEMPLATE/no-new-issues.md | 9 -- .github/workflows/ci.yml | 81 ------------------ .gitignore | 15 ---- .../Run_integrationTest_test.xml | 12 --- .../CONTRIBUTING.md | 0 LICENSE => launcher-package/LICENSE | 0 NOTICE => launcher-package/NOTICE | 0 README.md => launcher-package/README.md | 0 {bin => launcher-package/bin}/coursier | Bin {bin => launcher-package/bin}/coursier.bat | 0 build.sbt => launcher-package/build.sbt | 0 .../citest}/Hello.scala | 0 {citest => launcher-package/citest}/build.sbt | 0 .../citest}/project/build.properties | 0 .../citest}/src/test/scala/HelloTest.scala | 0 {citest => launcher-package/citest}/test.bat | 0 {citest => launcher-package/citest}/test.sh | 0 .../citest}/test3/.jvmopts | 0 .../citest}/test3/build.sbt | 0 .../citest}/test3/test3.bat | 0 .../integration-test}/bin/java | 0 .../integration-test}/bin/java.cmd | 0 .../src/test/scala/InheritInput.scala | 0 .../src/test/scala/PowerAssertions.scala | 0 .../src/test/scala/Process.scala | 0 .../src/test/scala/ProcessImpl.scala | 0 .../src/test/scala/RunnerTest.scala | 0 .../src/test/scala/ScriptTest.scala | 0 .../src/test/scala/SyncVar.scala | 0 .../project}/PackageSignerPlugin.scala | 0 .../project}/build.properties | 0 .../project}/plugins.sbt | 0 .../src}/debian/changelog | 0 .../src}/debian/usr/share/doc/sbt/copyright | 0 .../src}/linux/usr/share/doc/sbt/copyright | 0 .../src}/linux/usr/share/man/man1/sbt.1 | 0 .../src}/universal/bin/sbt | 0 .../src}/universal/bin/sbt.bat | 0 .../src}/universal/conf/sbtconfig.txt | 0 .../src}/universal/conf/sbtopts | 0 .../src}/windows/License.rtf | Bin {src => launcher-package/src}/windows/sbt | 0 .../upload}/sbt-upload.sh | 0 44 files changed, 118 deletions(-) delete mode 100644 .gitattributes delete mode 100644 .github/ISSUE_TEMPLATE/no-new-issues.md delete mode 100644 .github/workflows/ci.yml delete mode 100644 .gitignore delete mode 100644 .idea/runConfigurations/Run_integrationTest_test.xml rename CONTRIBUTING.md => launcher-package/CONTRIBUTING.md (100%) rename LICENSE => launcher-package/LICENSE (100%) rename NOTICE => launcher-package/NOTICE (100%) rename README.md => launcher-package/README.md (100%) rename {bin => launcher-package/bin}/coursier (100%) rename {bin => launcher-package/bin}/coursier.bat (100%) rename build.sbt => launcher-package/build.sbt (100%) rename {citest => launcher-package/citest}/Hello.scala (100%) rename {citest => launcher-package/citest}/build.sbt (100%) rename {citest => launcher-package/citest}/project/build.properties (100%) rename {citest => launcher-package/citest}/src/test/scala/HelloTest.scala (100%) rename {citest => launcher-package/citest}/test.bat (100%) rename {citest => launcher-package/citest}/test.sh (100%) rename {citest => launcher-package/citest}/test3/.jvmopts (100%) rename {citest => launcher-package/citest}/test3/build.sbt (100%) rename {citest => launcher-package/citest}/test3/test3.bat (100%) rename {integration-test => launcher-package/integration-test}/bin/java (100%) rename {integration-test => launcher-package/integration-test}/bin/java.cmd (100%) rename {integration-test => launcher-package/integration-test}/src/test/scala/InheritInput.scala (100%) rename {integration-test => launcher-package/integration-test}/src/test/scala/PowerAssertions.scala (100%) rename {integration-test => launcher-package/integration-test}/src/test/scala/Process.scala (100%) rename {integration-test => launcher-package/integration-test}/src/test/scala/ProcessImpl.scala (100%) rename {integration-test => launcher-package/integration-test}/src/test/scala/RunnerTest.scala (100%) rename {integration-test => launcher-package/integration-test}/src/test/scala/ScriptTest.scala (100%) rename {integration-test => launcher-package/integration-test}/src/test/scala/SyncVar.scala (100%) rename {project => launcher-package/project}/PackageSignerPlugin.scala (100%) rename {project => launcher-package/project}/build.properties (100%) rename {project => launcher-package/project}/plugins.sbt (100%) rename {src => launcher-package/src}/debian/changelog (100%) rename {src => launcher-package/src}/debian/usr/share/doc/sbt/copyright (100%) rename {src => launcher-package/src}/linux/usr/share/doc/sbt/copyright (100%) rename {src => launcher-package/src}/linux/usr/share/man/man1/sbt.1 (100%) rename {src => launcher-package/src}/universal/bin/sbt (100%) rename {src => launcher-package/src}/universal/bin/sbt.bat (100%) rename {src => launcher-package/src}/universal/conf/sbtconfig.txt (100%) rename {src => launcher-package/src}/universal/conf/sbtopts (100%) rename {src => launcher-package/src}/windows/License.rtf (100%) rename {src => launcher-package/src}/windows/sbt (100%) rename {upload => launcher-package/upload}/sbt-upload.sh (100%) diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 09be01613..000000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -src/windows/sbtconfig.txt eol=crlf diff --git a/.github/ISSUE_TEMPLATE/no-new-issues.md b/.github/ISSUE_TEMPLATE/no-new-issues.md deleted file mode 100644 index a3fc484f9..000000000 --- a/.github/ISSUE_TEMPLATE/no-new-issues.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -name: No new issues -about: Use https://github.com/sbt/sbt/issues/new/choose instead - ---- - -No new issues should be opened against this repo. - -Please use https://github.com/sbt/sbt/issues/new/choose to file an issue against sbt. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index f00f86426..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: CI -on: - pull_request: - push: - -jobs: - test: - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-latest - java: 8 - jobtype: 1 - - os: macos-latest - java: 8 - jobtype: 2 - - os: windows-latest - java: 8 - jobtype: 3 - runs-on: ${{ matrix.os }} - env: - JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 - SBT_VER: 1.4.2 - SBT_ETC_FILE: $HOME/etc/sbt/sbtopts - JDK11: adopt@1.11.0-9 - steps: - - name: Checkout - uses: actions/checkout@v1 - - name: Setup - uses: olafurpg/setup-scala@v10 - with: - java-version: "adopt@1.${{ matrix.java }}" - - name: Set up Python 3.7 - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - name: Coursier cache - uses: coursier/cache-action@v5 - - name: Cache sbt - uses: actions/cache@v1 - with: - path: ~/.sbt - key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - name: Build and test - shell: bash - run: | - case ${{ matrix.jobtype }} in - 1) - echo build using JDK 8 test using JDK 8 and JDK 11 - sbt -Dsbt.build.version=$SBT_VER rpm:packageBin debian:packageBin - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - cd citest && ./test.sh - $HOME/bin/jabba install $JDK11 && exec $HOME/bin/jabba which --home $JDK11 - java -Xmx32m -version - ./test.sh - ;; - 2) - echo build using JDK 8, test using JDK 8, on macOS - bin/coursier resolve - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - cd citest && ./test.sh - ;; - 3) - echo build using JDK 8, test using JDK 8, on Windows - bin/coursier.bat resolve - sbt -Dsbt.build.version=$SBT_VER universal:packageBin universal:stage integrationTest/test - cd citest - ./test.bat - test3/test3.bat - ;; - *) - echo unknown jobtype - exit 1 - esac - rm -rf "$HOME/.ivy2/local" || true - rm -r $(find $HOME/.sbt/boot -name "*-SNAPSHOT") || true - find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true - find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true - find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true - find $HOME/.sbt -name "*.lock" -delete || true diff --git a/.gitignore b/.gitignore deleted file mode 100644 index aa7261561..000000000 --- a/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -/SbtTemplateProject.scala -target -/project/boot -/project/metals.sbt -/.metals -/project/plugins -lib_managed -src_managed -/ext -.lib -/template-project/project/boot -*~ -/citest/freshly-baked/ -/upload/cookies -.bsp diff --git a/.idea/runConfigurations/Run_integrationTest_test.xml b/.idea/runConfigurations/Run_integrationTest_test.xml deleted file mode 100644 index 3d96baea8..000000000 --- a/.idea/runConfigurations/Run_integrationTest_test.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - \ No newline at end of file diff --git a/CONTRIBUTING.md b/launcher-package/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to launcher-package/CONTRIBUTING.md diff --git a/LICENSE b/launcher-package/LICENSE similarity index 100% rename from LICENSE rename to launcher-package/LICENSE diff --git a/NOTICE b/launcher-package/NOTICE similarity index 100% rename from NOTICE rename to launcher-package/NOTICE diff --git a/README.md b/launcher-package/README.md similarity index 100% rename from README.md rename to launcher-package/README.md diff --git a/bin/coursier b/launcher-package/bin/coursier similarity index 100% rename from bin/coursier rename to launcher-package/bin/coursier diff --git a/bin/coursier.bat b/launcher-package/bin/coursier.bat similarity index 100% rename from bin/coursier.bat rename to launcher-package/bin/coursier.bat diff --git a/build.sbt b/launcher-package/build.sbt similarity index 100% rename from build.sbt rename to launcher-package/build.sbt diff --git a/citest/Hello.scala b/launcher-package/citest/Hello.scala similarity index 100% rename from citest/Hello.scala rename to launcher-package/citest/Hello.scala diff --git a/citest/build.sbt b/launcher-package/citest/build.sbt similarity index 100% rename from citest/build.sbt rename to launcher-package/citest/build.sbt diff --git a/citest/project/build.properties b/launcher-package/citest/project/build.properties similarity index 100% rename from citest/project/build.properties rename to launcher-package/citest/project/build.properties diff --git a/citest/src/test/scala/HelloTest.scala b/launcher-package/citest/src/test/scala/HelloTest.scala similarity index 100% rename from citest/src/test/scala/HelloTest.scala rename to launcher-package/citest/src/test/scala/HelloTest.scala diff --git a/citest/test.bat b/launcher-package/citest/test.bat similarity index 100% rename from citest/test.bat rename to launcher-package/citest/test.bat diff --git a/citest/test.sh b/launcher-package/citest/test.sh similarity index 100% rename from citest/test.sh rename to launcher-package/citest/test.sh diff --git a/citest/test3/.jvmopts b/launcher-package/citest/test3/.jvmopts similarity index 100% rename from citest/test3/.jvmopts rename to launcher-package/citest/test3/.jvmopts diff --git a/citest/test3/build.sbt b/launcher-package/citest/test3/build.sbt similarity index 100% rename from citest/test3/build.sbt rename to launcher-package/citest/test3/build.sbt diff --git a/citest/test3/test3.bat b/launcher-package/citest/test3/test3.bat similarity index 100% rename from citest/test3/test3.bat rename to launcher-package/citest/test3/test3.bat diff --git a/integration-test/bin/java b/launcher-package/integration-test/bin/java similarity index 100% rename from integration-test/bin/java rename to launcher-package/integration-test/bin/java diff --git a/integration-test/bin/java.cmd b/launcher-package/integration-test/bin/java.cmd similarity index 100% rename from integration-test/bin/java.cmd rename to launcher-package/integration-test/bin/java.cmd diff --git a/integration-test/src/test/scala/InheritInput.scala b/launcher-package/integration-test/src/test/scala/InheritInput.scala similarity index 100% rename from integration-test/src/test/scala/InheritInput.scala rename to launcher-package/integration-test/src/test/scala/InheritInput.scala diff --git a/integration-test/src/test/scala/PowerAssertions.scala b/launcher-package/integration-test/src/test/scala/PowerAssertions.scala similarity index 100% rename from integration-test/src/test/scala/PowerAssertions.scala rename to launcher-package/integration-test/src/test/scala/PowerAssertions.scala diff --git a/integration-test/src/test/scala/Process.scala b/launcher-package/integration-test/src/test/scala/Process.scala similarity index 100% rename from integration-test/src/test/scala/Process.scala rename to launcher-package/integration-test/src/test/scala/Process.scala diff --git a/integration-test/src/test/scala/ProcessImpl.scala b/launcher-package/integration-test/src/test/scala/ProcessImpl.scala similarity index 100% rename from integration-test/src/test/scala/ProcessImpl.scala rename to launcher-package/integration-test/src/test/scala/ProcessImpl.scala diff --git a/integration-test/src/test/scala/RunnerTest.scala b/launcher-package/integration-test/src/test/scala/RunnerTest.scala similarity index 100% rename from integration-test/src/test/scala/RunnerTest.scala rename to launcher-package/integration-test/src/test/scala/RunnerTest.scala diff --git a/integration-test/src/test/scala/ScriptTest.scala b/launcher-package/integration-test/src/test/scala/ScriptTest.scala similarity index 100% rename from integration-test/src/test/scala/ScriptTest.scala rename to launcher-package/integration-test/src/test/scala/ScriptTest.scala diff --git a/integration-test/src/test/scala/SyncVar.scala b/launcher-package/integration-test/src/test/scala/SyncVar.scala similarity index 100% rename from integration-test/src/test/scala/SyncVar.scala rename to launcher-package/integration-test/src/test/scala/SyncVar.scala diff --git a/project/PackageSignerPlugin.scala b/launcher-package/project/PackageSignerPlugin.scala similarity index 100% rename from project/PackageSignerPlugin.scala rename to launcher-package/project/PackageSignerPlugin.scala diff --git a/project/build.properties b/launcher-package/project/build.properties similarity index 100% rename from project/build.properties rename to launcher-package/project/build.properties diff --git a/project/plugins.sbt b/launcher-package/project/plugins.sbt similarity index 100% rename from project/plugins.sbt rename to launcher-package/project/plugins.sbt diff --git a/src/debian/changelog b/launcher-package/src/debian/changelog similarity index 100% rename from src/debian/changelog rename to launcher-package/src/debian/changelog diff --git a/src/debian/usr/share/doc/sbt/copyright b/launcher-package/src/debian/usr/share/doc/sbt/copyright similarity index 100% rename from src/debian/usr/share/doc/sbt/copyright rename to launcher-package/src/debian/usr/share/doc/sbt/copyright diff --git a/src/linux/usr/share/doc/sbt/copyright b/launcher-package/src/linux/usr/share/doc/sbt/copyright similarity index 100% rename from src/linux/usr/share/doc/sbt/copyright rename to launcher-package/src/linux/usr/share/doc/sbt/copyright diff --git a/src/linux/usr/share/man/man1/sbt.1 b/launcher-package/src/linux/usr/share/man/man1/sbt.1 similarity index 100% rename from src/linux/usr/share/man/man1/sbt.1 rename to launcher-package/src/linux/usr/share/man/man1/sbt.1 diff --git a/src/universal/bin/sbt b/launcher-package/src/universal/bin/sbt similarity index 100% rename from src/universal/bin/sbt rename to launcher-package/src/universal/bin/sbt diff --git a/src/universal/bin/sbt.bat b/launcher-package/src/universal/bin/sbt.bat similarity index 100% rename from src/universal/bin/sbt.bat rename to launcher-package/src/universal/bin/sbt.bat diff --git a/src/universal/conf/sbtconfig.txt b/launcher-package/src/universal/conf/sbtconfig.txt similarity index 100% rename from src/universal/conf/sbtconfig.txt rename to launcher-package/src/universal/conf/sbtconfig.txt diff --git a/src/universal/conf/sbtopts b/launcher-package/src/universal/conf/sbtopts similarity index 100% rename from src/universal/conf/sbtopts rename to launcher-package/src/universal/conf/sbtopts diff --git a/src/windows/License.rtf b/launcher-package/src/windows/License.rtf similarity index 100% rename from src/windows/License.rtf rename to launcher-package/src/windows/License.rtf diff --git a/src/windows/sbt b/launcher-package/src/windows/sbt similarity index 100% rename from src/windows/sbt rename to launcher-package/src/windows/sbt diff --git a/upload/sbt-upload.sh b/launcher-package/upload/sbt-upload.sh similarity index 100% rename from upload/sbt-upload.sh rename to launcher-package/upload/sbt-upload.sh